diff options
author | Daniel García <[email protected]> | 2018-12-07 02:05:45 +0100 |
---|---|---|
committer | Daniel García <[email protected]> | 2018-12-07 02:05:45 +0100 |
commit | 94810c106a96adab678434a93c9defe125fc8809 (patch) | |
tree | 5dd3a45deed97d2733d7594bc245451b79c35ca0 /src/api | |
parent | 2fde4e693363266a93d450f26ad0b5cc9cebb53a (diff) | |
download | vaultwarden-94810c106a96adab678434a93c9defe125fc8809.tar.gz vaultwarden-94810c106a96adab678434a93c9defe125fc8809.zip |
Migrate to rust 2018 edition
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/core/accounts.rs | 12 | ||||
-rw-r--r-- | src/api/core/ciphers.rs | 12 | ||||
-rw-r--r-- | src/api/core/folders.rs | 8 | ||||
-rw-r--r-- | src/api/core/mod.rs | 10 | ||||
-rw-r--r-- | src/api/core/organizations.rs | 10 | ||||
-rw-r--r-- | src/api/core/two_factor.rs | 12 | ||||
-rw-r--r-- | src/api/icons.rs | 2 | ||||
-rw-r--r-- | src/api/identity.rs | 16 | ||||
-rw-r--r-- | src/api/mod.rs | 2 | ||||
-rw-r--r-- | src/api/notifications.rs | 14 | ||||
-rw-r--r-- | src/api/web.rs | 4 |
11 files changed, 51 insertions, 51 deletions
diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs index ce8572b7..fbe00796 100644 --- a/src/api/core/accounts.rs +++ b/src/api/core/accounts.rs @@ -1,13 +1,13 @@ use rocket_contrib::json::Json; -use db::models::*; -use db::DbConn; +use crate::db::models::*; +use crate::db::DbConn; -use api::{EmptyResult, JsonResult, JsonUpcase, NumberOrString, PasswordData, UpdateType, WebSocketUsers}; -use auth::Headers; -use mail; +use crate::api::{EmptyResult, JsonResult, JsonUpcase, NumberOrString, PasswordData, UpdateType, WebSocketUsers}; +use crate::auth::Headers; +use crate::mail; -use CONFIG; +use crate::CONFIG; use rocket::{Route, State}; diff --git a/src/api/core/ciphers.rs b/src/api/core/ciphers.rs index 41e704dc..e5a7c59e 100644 --- a/src/api/core/ciphers.rs +++ b/src/api/core/ciphers.rs @@ -12,15 +12,15 @@ use multipart::server::{Multipart, SaveResult}; use data_encoding::HEXLOWER; -use db::models::*; -use db::DbConn; +use crate::db::models::*; +use crate::db::DbConn; -use crypto; +use crate::crypto; -use api::{self, EmptyResult, JsonResult, JsonUpcase, PasswordData, UpdateType, WebSocketUsers}; -use auth::Headers; +use crate::api::{self, EmptyResult, JsonResult, JsonUpcase, PasswordData, UpdateType, WebSocketUsers}; +use crate::auth::Headers; -use CONFIG; +use crate::CONFIG; pub fn routes() -> Vec<Route> { routes![ diff --git a/src/api/core/folders.rs b/src/api/core/folders.rs index e60c281f..4c1cdff6 100644 --- a/src/api/core/folders.rs +++ b/src/api/core/folders.rs @@ -2,11 +2,11 @@ use rocket::State; use rocket_contrib::json::Json; use serde_json::Value; -use db::DbConn; -use db::models::*; +use crate::db::DbConn; +use crate::db::models::*; -use api::{JsonResult, EmptyResult, JsonUpcase, WebSocketUsers, UpdateType}; -use auth::Headers; +use crate::api::{JsonResult, EmptyResult, JsonUpcase, WebSocketUsers, UpdateType}; +use crate::auth::Headers; use rocket::Route; diff --git a/src/api/core/mod.rs b/src/api/core/mod.rs index d4b4d2e7..46ee76e2 100644 --- a/src/api/core/mod.rs +++ b/src/api/core/mod.rs @@ -34,11 +34,11 @@ use rocket::Route; use rocket_contrib::json::Json; use serde_json::Value; -use db::DbConn; -use db::models::*; +use crate::db::DbConn; +use crate::db::models::*; -use api::{JsonResult, EmptyResult, JsonUpcase}; -use auth::Headers; +use crate::api::{JsonResult, EmptyResult, JsonUpcase}; +use crate::auth::Headers; #[put("/devices/identifier/<uuid>/clear-token")] fn clear_device_token(uuid: String, headers: Headers, conn: DbConn) -> EmptyResult { @@ -72,7 +72,7 @@ fn put_device_token(uuid: String, data: JsonUpcase<Value>, headers: Headers, con // This should save the push token, but we don't have push functionality - use util::format_date; + use crate::util::format_date; Ok(Json(json!({ "Id": device.uuid, diff --git a/src/api/core/organizations.rs b/src/api/core/organizations.rs index f38876dd..0350b2e1 100644 --- a/src/api/core/organizations.rs +++ b/src/api/core/organizations.rs @@ -3,12 +3,12 @@ use rocket::request::Form; use rocket_contrib::json::Json; use serde_json::Value; -use CONFIG; -use db::DbConn; -use db::models::*; +use crate::CONFIG; +use crate::db::DbConn; +use crate::db::models::*; -use api::{PasswordData, JsonResult, EmptyResult, NumberOrString, JsonUpcase, WebSocketUsers, UpdateType}; -use auth::{Headers, AdminHeaders, OwnerHeaders}; +use crate::api::{PasswordData, JsonResult, EmptyResult, NumberOrString, JsonUpcase, WebSocketUsers, UpdateType}; +use crate::auth::{Headers, AdminHeaders, OwnerHeaders}; use serde::{Deserialize, Deserializer}; diff --git a/src/api/core/two_factor.rs b/src/api/core/two_factor.rs index a2361384..d25a6b42 100644 --- a/src/api/core/two_factor.rs +++ b/src/api/core/two_factor.rs @@ -4,15 +4,15 @@ use serde_json; use serde_json::Value; -use db::{ +use crate::db::{ models::{TwoFactor, TwoFactorType, User}, DbConn, }; -use crypto; +use crate::crypto; -use api::{ApiResult, JsonResult, JsonUpcase, NumberOrString, PasswordData}; -use auth::Headers; +use crate::api::{ApiResult, JsonResult, JsonUpcase, NumberOrString, PasswordData}; +use crate::auth::Headers; use rocket::Route; @@ -74,7 +74,7 @@ struct RecoverTwoFactor { fn recover(data: JsonUpcase<RecoverTwoFactor>, conn: DbConn) -> JsonResult { let data: RecoverTwoFactor = data.into_inner().data; - use db::models::User; + use crate::db::models::User; // Get the user let mut user = match User::find_by_mail(&data.Email, &conn) { @@ -252,7 +252,7 @@ use u2f::messages::{RegisterResponse, SignResponse, U2fSignRequest}; use u2f::protocol::{Challenge, U2f}; use u2f::register::Registration; -use CONFIG; +use crate::CONFIG; const U2F_VERSION: &str = "U2F_V2"; diff --git a/src/api/icons.rs b/src/api/icons.rs index 585a2c2b..a3ff1d39 100644 --- a/src/api/icons.rs +++ b/src/api/icons.rs @@ -7,7 +7,7 @@ use rocket::http::ContentType; use reqwest; -use CONFIG; +use crate::CONFIG; pub fn routes() -> Vec<Route> { routes![icon] diff --git a/src/api/identity.rs b/src/api/identity.rs index 940fcbf9..8236b1d7 100644 --- a/src/api/identity.rs +++ b/src/api/identity.rs @@ -8,14 +8,14 @@ use serde_json::Value; use num_traits::FromPrimitive; -use db::models::*; -use db::DbConn; +use crate::db::models::*; +use crate::db::DbConn; -use util::{self, JsonMap}; +use crate::util::{self, JsonMap}; -use api::{ApiResult, EmptyResult, JsonResult}; +use crate::api::{ApiResult, EmptyResult, JsonResult}; -use CONFIG; +use crate::CONFIG; pub fn routes() -> Vec<Route> { routes![login] @@ -194,13 +194,13 @@ fn twofactor_auth( } Some(TwoFactorType::U2f) => { - use api::core::two_factor; + use crate::api::core::two_factor; two_factor::validate_u2f_login(user_uuid, &twofactor_code, conn)?; } Some(TwoFactorType::YubiKey) => { - use api::core::two_factor; + use crate::api::core::two_factor; two_factor::validate_yubikey_login(user_uuid, twofactor_code, conn)?; } @@ -217,7 +217,7 @@ fn twofactor_auth( } fn _json_err_twofactor(providers: &[i32], user_uuid: &str, conn: &DbConn) -> ApiResult<Value> { - use api::core::two_factor; + use crate::api::core::two_factor; let mut result = json!({ "error" : "invalid_grant", diff --git a/src/api/mod.rs b/src/api/mod.rs index 332b3cf0..9c8e49eb 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -20,7 +20,7 @@ type ApiResult<T> = Result<T, BadRequest<Json<Value>>>; type JsonResult = ApiResult<Json<Value>>; type EmptyResult = ApiResult<()>; -use util; +use crate::util; type JsonUpcase<T> = Json<util::UpCase<T>>; // Common structs representing JSON data received diff --git a/src/api/notifications.rs b/src/api/notifications.rs index df40cf89..6e4f216a 100644 --- a/src/api/notifications.rs +++ b/src/api/notifications.rs @@ -2,11 +2,11 @@ use rocket::Route; use rocket_contrib::json::Json; use serde_json::Value as JsonValue; -use api::JsonResult; -use auth::Headers; -use db::DbConn; +use crate::api::JsonResult; +use crate::auth::Headers; +use crate::db::DbConn; -use CONFIG; +use crate::CONFIG; pub fn routes() -> Vec<Route> { routes![negotiate, websockets_err] @@ -19,7 +19,7 @@ fn websockets_err() -> JsonResult { #[post("/hub/negotiate")] fn negotiate(_headers: Headers, _conn: DbConn) -> JsonResult { - use crypto; + use crate::crypto; use data_encoding::BASE64URL; let conn_id = BASE64URL.encode(&crypto::get_random(vec![0u8; 16])); @@ -52,7 +52,7 @@ use chashmap::CHashMap; use chrono::NaiveDateTime; use serde_json::from_str; -use db::models::{Cipher, Folder, User}; +use crate::db::models::{Cipher, Folder, User}; use rmpv::Value; @@ -139,7 +139,7 @@ impl Handler for WSHandler { let _id = &query_split[1][3..]; // Validate the user - use auth; + use crate::auth; let claims = match auth::decode_jwt(access_token) { Ok(claims) => claims, Err(_) => { diff --git a/src/api/web.rs b/src/api/web.rs index 53b7d9a4..8db632a9 100644 --- a/src/api/web.rs +++ b/src/api/web.rs @@ -9,7 +9,7 @@ use rocket::Route; use rocket_contrib::json::Json; use serde_json::Value; -use CONFIG; +use crate::CONFIG; pub fn routes() -> Vec<Route> { if CONFIG.web_vault_enabled { @@ -74,7 +74,7 @@ fn attachments(uuid: String, file: PathBuf) -> io::Result<NamedFile> { #[get("/alive")] fn alive() -> Json<String> { - use util::format_date; + use crate::util::format_date; use chrono::Utc; Json(format_date(&Utc::now().naive_utc())) |