mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-06-01 00:13:56 +00:00
Updated dependencies to use u2f crate directly, and some style changes
This commit is contained in:
parent
c8af62ed48
commit
5f49ecd7f3
7 changed files with 110 additions and 114 deletions
|
@ -78,7 +78,7 @@ fn register(data: JsonUpcase<RegisterData>, conn: DbConn) -> EmptyResult {
|
|||
};
|
||||
|
||||
let claims: InviteJWTClaims = decode_invite_jwt(&token)?;
|
||||
if &claims.email == &data.Email {
|
||||
if claims.email == data.Email {
|
||||
user
|
||||
} else {
|
||||
err!("Registration email does not match invite email")
|
||||
|
|
|
@ -287,23 +287,22 @@ struct EnableU2FData {
|
|||
}
|
||||
|
||||
// This struct is copied from the U2F lib
|
||||
// because challenge is not always sent
|
||||
// to add an optional error code
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct RegisterResponseCopy {
|
||||
pub registration_data: String,
|
||||
pub version: String,
|
||||
pub challenge: Option<String>,
|
||||
pub error_code: Option<NumberOrString>,
|
||||
pub client_data: String,
|
||||
|
||||
pub error_code: Option<NumberOrString>,
|
||||
}
|
||||
|
||||
impl RegisterResponseCopy {
|
||||
fn into_response(self, challenge: String) -> RegisterResponse {
|
||||
fn into_response(self) -> RegisterResponse {
|
||||
RegisterResponse {
|
||||
registration_data: self.registration_data,
|
||||
version: self.version,
|
||||
challenge,
|
||||
client_data: self.client_data,
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +335,7 @@ fn activate_u2f(data: JsonUpcase<EnableU2FData>, headers: Headers, conn: DbConn)
|
|||
err!("Error registering U2F token")
|
||||
}
|
||||
|
||||
let response = response_copy.into_response(challenge.challenge.clone());
|
||||
let response = response_copy.into_response();
|
||||
|
||||
let registration = U2F.register_response(challenge.clone(), response)?;
|
||||
// TODO: Allow more than one U2F device
|
||||
|
|
|
@ -68,12 +68,12 @@ struct Cached<R>(R, &'static str);
|
|||
impl<R> Cached<R> {
|
||||
fn long(r: R) -> Cached<R> {
|
||||
// 7 days
|
||||
Cached(r, "public, max-age=604800".into())
|
||||
Cached(r, "public, max-age=604800")
|
||||
}
|
||||
|
||||
fn short(r: R) -> Cached<R> {
|
||||
// 10 minutes
|
||||
Cached(r, "public, max-age=600".into())
|
||||
Cached(r, "public, max-age=600")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,17 +76,17 @@ impl Error {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait MapResult<S, E> {
|
||||
fn map_res(self, msg: &str) -> Result<S, E>;
|
||||
pub trait MapResult<S> {
|
||||
fn map_res(self, msg: &str) -> Result<S, Error>;
|
||||
}
|
||||
|
||||
impl<S, E: Into<Error>> MapResult<S, Error> for Result<S, E> {
|
||||
impl<S, E: Into<Error>> MapResult<S> for Result<S, E> {
|
||||
fn map_res(self, msg: &str) -> Result<S, Error> {
|
||||
self.map_err(|e| e.into().with_msg(msg))
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Into<Error>> MapResult<(), Error> for Result<usize, E> {
|
||||
impl<E: Into<Error>> MapResult<()> for Result<usize, E> {
|
||||
fn map_res(self, msg: &str) -> Result<(), Error> {
|
||||
self.and(Ok(())).map_res(msg)
|
||||
}
|
||||
|
|
|
@ -332,9 +332,9 @@ impl Config {
|
|||
attachments_folder: get_env_or("ATTACHMENTS_FOLDER", format!("{}/{}", &df, "attachments")),
|
||||
|
||||
// icon_cache_ttl defaults to 30 days (30 * 24 * 60 * 60 seconds)
|
||||
icon_cache_ttl: get_env_or("ICON_CACHE_TTL", 2592000u64),
|
||||
icon_cache_ttl: get_env_or("ICON_CACHE_TTL", 2_592_000),
|
||||
// icon_cache_negttl defaults to 3 days (3 * 24 * 60 * 60 seconds)
|
||||
icon_cache_negttl: get_env_or("ICON_CACHE_NEGTTL", 259200u64),
|
||||
icon_cache_negttl: get_env_or("ICON_CACHE_NEGTTL", 259_200),
|
||||
|
||||
private_rsa_key: format!("{}.der", &key),
|
||||
private_rsa_key_pem: format!("{}.pem", &key),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue