diff options
author | Daniel GarcĂa <[email protected]> | 2024-11-15 18:38:16 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-11-15 18:38:16 +0100 |
commit | 2393c3f3c08f451a04643fd9fed5027f491dc12d (patch) | |
tree | 8f9ce3878429eafb3890adbe053e948cc07c84c4 /src/auth.rs | |
parent | 0d16b38a68c702e7f300a64f9e55d897916ae238 (diff) | |
download | vaultwarden-2393c3f3c08f451a04643fd9fed5027f491dc12d.tar.gz vaultwarden-2393c3f3c08f451a04643fd9fed5027f491dc12d.zip |
Support SSH keys on desktop 2024.12 (#5187)
* Support SSH keys on desktop 2024.12
* Document flags in .env.template
* Validate key rotation contents
Diffstat (limited to 'src/auth.rs')
-rw-r--r-- | src/auth.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/auth.rs b/src/auth.rs index b1a743da..809ef9fd 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -615,7 +615,6 @@ pub struct AdminHeaders { pub device: Device, pub user: User, pub org_user_type: UserOrgType, - pub client_version: Option<String>, pub ip: ClientIp, } @@ -625,14 +624,12 @@ impl<'r> FromRequest<'r> for AdminHeaders { async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> { let headers = try_outcome!(OrgHeaders::from_request(request).await); - let client_version = request.headers().get_one("Bitwarden-Client-Version").map(String::from); if headers.org_user_type >= UserOrgType::Admin { Outcome::Success(Self { host: headers.host, device: headers.device, user: headers.user, org_user_type: headers.org_user_type, - client_version, ip: headers.ip, }) } else { @@ -900,3 +897,24 @@ impl<'r> FromRequest<'r> for WsAccessTokenHeader { }) } } + +pub struct ClientVersion(pub semver::Version); + +#[rocket::async_trait] +impl<'r> FromRequest<'r> for ClientVersion { + type Error = &'static str; + + async fn from_request(request: &'r Request<'_>) -> Outcome<Self, Self::Error> { + let headers = request.headers(); + + let Some(version) = headers.get_one("Bitwarden-Client-Version") else { + err_handler!("No Bitwarden-Client-Version header provided") + }; + + let Ok(version) = semver::Version::parse(version) else { + err_handler!("Invalid Bitwarden-Client-Version header provided") + }; + + Outcome::Success(ClientVersion(version)) + } +} |