diff options
author | Daniel García <[email protected]> | 2020-07-14 18:00:09 +0200 |
---|---|---|
committer | Daniel García <[email protected]> | 2020-07-14 18:34:22 +0200 |
commit | 668d5c23dc084b778496b655e93196bdfe007953 (patch) | |
tree | a0ac086e1e42970a6931529193fe6905663e5a27 /src/auth.rs | |
parent | fb6f96f5c3bbe2ab281738a1c9a30a690d9bef0b (diff) | |
download | vaultwarden-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.rs | 34 |
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 { |