aboutsummaryrefslogtreecommitdiff
path: root/src/auth.rs
diff options
context:
space:
mode:
authorDaniel García <[email protected]>2020-07-14 18:00:09 +0200
committerDaniel García <[email protected]>2020-07-14 18:34:22 +0200
commit668d5c23dc084b778496b655e93196bdfe007953 (patch)
treea0ac086e1e42970a6931529193fe6905663e5a27 /src/auth.rs
parentfb6f96f5c3bbe2ab281738a1c9a30a690d9bef0b (diff)
downloadvaultwarden-668d5c23dc084b778496b655e93196bdfe007953.tar.gz
vaultwarden-668d5c23dc084b778496b655e93196bdfe007953.zip
Removed try_trait and some formatting, particularly around imports
Diffstat (limited to 'src/auth.rs')
-rw-r--r--src/auth.rs34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/auth.rs b/src/auth.rs
index 38425306..2a775ebf 100644
--- a/src/auth.rs
+++ b/src/auth.rs
@@ -1,17 +1,19 @@
//
// JWT Handling
//
-use crate::util::read_file;
use chrono::{Duration, Utc};
-use once_cell::sync::Lazy;
use num_traits::FromPrimitive;
+use once_cell::sync::Lazy;
-use jsonwebtoken::{self, Algorithm, Header, EncodingKey, DecodingKey};
+use jsonwebtoken::{self, Algorithm, DecodingKey, EncodingKey, Header};
use serde::de::DeserializeOwned;
use serde::ser::Serialize;
-use crate::error::{Error, MapResult};
-use crate::CONFIG;
+use crate::{
+ error::{Error, MapResult},
+ util::read_file,
+ CONFIG,
+};
const JWT_ALGORITHM: Algorithm = Algorithm::RS256;
@@ -213,11 +215,15 @@ pub fn generate_admin_claims() -> AdminJWTClaims {
//
// Bearer token authentication
//
-use rocket::request::{self, FromRequest, Request};
-use rocket::Outcome;
+use rocket::{
+ request::{self, FromRequest, Request},
+ Outcome,
+};
-use crate::db::models::{Device, User, UserOrgStatus, UserOrgType, UserOrganization};
-use crate::db::DbConn;
+use crate::db::{
+ models::{Device, User, UserOrgStatus, UserOrgType, UserOrganization},
+ DbConn,
+};
pub struct Headers {
pub host: String,
@@ -366,7 +372,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for OrgHeaders {
}
},
})
- },
+ }
_ => err_handler!("Error getting the organization id"),
}
}
@@ -404,14 +410,14 @@ impl<'a, 'r> FromRequest<'a, 'r> for AdminHeaders {
}
}
-impl Into<Headers> for AdminHeaders {
- fn into(self) -> Headers {
+impl Into<Headers> for AdminHeaders {
+ fn into(self) -> Headers {
Headers {
host: self.host,
device: self.device,
- user: self.user
+ user: self.user,
}
- }
+ }
}
pub struct OwnerHeaders {