vw_small

Hardened fork of Vaultwarden (https://github.com/dani-garcia/vaultwarden) with fewer features.
git clone https://git.philomathiclife.com/repos/vw_small
Log | Files | Refs | README

commit 0dadd7b31887706d3653243742b87a9221b7ff50
parent 87d98b46b2b8fb51922efce5c7eff09c2fbe944a
Author: Zack Newman <zack@philomathiclife.com>
Date:   Sun,  5 May 2024 15:03:04 -0600

update deps. add more and address lints

Diffstat:
MCargo.toml | 30+++++++++++++++---------------
Msrc/api/core/accounts.rs | 2+-
Msrc/auth.rs | 3++-
Msrc/db/models/device.rs | 3++-
Msrc/db/models/user.rs | 1+
Msrc/main.rs | 16++++++++++------
6 files changed, 31 insertions(+), 24 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml @@ -9,33 +9,33 @@ license = "AGPL-3.0-only" name = "vw_small" publish = false repository = "https://git.philomathiclife.com/repos/vw_small/" -version = "2.0.0" +version = "2.0.1" [features] priv_sep = ["dep:priv_sep"] [target.'cfg(target_os = "openbsd")'.dependencies] -priv_sep = { version = "0.8.1", default-features = false, features = ["openbsd"], optional = true } +priv_sep = { version = "1.0.1", default-features = false, features = ["openbsd"], optional = true } [dependencies] -chrono = { version = "0.4.31", default-features = false, features = ["serde"] } -data-encoding = { version = "2.5.0", default-features = false } -diesel = { version = "2.1.4", default-features = false, features = ["32-column-tables", "chrono", "r2d2", "sqlite"] } -jsonwebtoken = { version = "9.2.0", default-features = false, features = ["use_pem"] } -libsqlite3-sys = { version = "0.27.0", default-features = false, features = ["bundled"] } -openssl = { version = "0.10.62", default-features = false } +chrono = { version = "0.4.38", default-features = false, features = ["serde"] } +data-encoding = { version = "2.6.0", default-features = false } +diesel = { version = "2.1.6", default-features = false, features = ["32-column-tables", "chrono", "r2d2", "sqlite"] } +jsonwebtoken = { version = "9.3.0", default-features = false, features = ["use_pem"] } +libsqlite3-sys = { version = "0.28.0", default-features = false, features = ["bundled"] } +openssl = { version = "0.10.64", default-features = false } paste = { version = "1.0.14", default-features = false } rand = { version = "0.8.5", default-features = false, features = ["small_rng"] } -ring = { version = "0.17.7", default-features = false } +ring = { version = "0.17.8", default-features = false } rocket = { version = "0.5.0", default-features = false, features = ["json", "tls"] } -semver = { version = "1.0.21", default-features = false } -serde = { version = "1.0.195", default-features = false } -serde_json = { version = "1.0.111", default-features = false } -tokio = { version = "1.35.1", default-features = false } -toml = { version = "0.8.8", default-features = false, features = ["parse"] } +semver = { version = "1.0.22", default-features = false } +serde = { version = "1.0.200", default-features = false } +serde_json = { version = "1.0.116", default-features = false } +tokio = { version = "1.37.0", default-features = false } +toml = { version = "0.8.12", default-features = false, features = ["parse"] } totp-lite = { version = "2.0.1", default-features = false } url = { version = "2.5.0", default-features = false } -uuid = { version = "1.6.1", default-features = false, features = ["v4"] } +uuid = { version = "1.8.0", default-features = false, features = ["v4"] } webauthn-rs = { version = "0.4.8", default-features = false, features = ["danger-allow-state-serialisation", "danger-user-presence-only-security-keys"] } [patch.crates-io] diff --git a/src/api/core/accounts.rs b/src/api/core/accounts.rs @@ -471,7 +471,7 @@ async fn delete_account( #[allow(clippy::needless_pass_by_value)] #[get("/accounts/revision-date")] fn revision_date(headers: Headers) -> Json<Value> { - Json(json!(headers.user.updated_at.timestamp_millis())) + Json(json!(headers.user.updated_at.and_utc().timestamp_millis())) } #[derive(Deserialize)] diff --git a/src/auth.rs b/src/auth.rs @@ -87,6 +87,7 @@ fn init_ed_keys() -> Result<(), Error> { let mut file = File::options() .create(true) .read(true) + .truncate(false) .write(true) .open(Config::PRIVATE_ED25519_KEY)?; let mut priv_pem = Vec::with_capacity(128); @@ -369,7 +370,7 @@ impl<'r> FromRequest<'r> for Headers { // Check if the stamp exception has expired first. // Then, check if the current route matches any of the allowed routes. // After that check the stamp in exception matches the one in the claims. - if u64::try_from(Utc::now().naive_utc().timestamp()).expect("underflow") + if u64::try_from(Utc::now().naive_utc().and_utc().timestamp()).expect("underflow") > stamp_exception.expire { // If the stamp exception has been expired remove it from the database. diff --git a/src/db/models/device.rs b/src/db/models/device.rs @@ -65,9 +65,10 @@ impl Device { // Create the JWT claims struct, to send to the client use crate::auth::{self, encode_jwt, LoginJwtClaims}; let claims = LoginJwtClaims { - nbf: time_now.timestamp(), + nbf: time_now.and_utc().timestamp(), exp: (time_now.checked_add_signed(*auth::get_default_validity())) .expect("Duration add overflowed") + .and_utc() .timestamp(), iss: auth::get_jwt_login_issuer().to_owned(), sub: user.uuid.clone(), diff --git a/src/db/models/user.rs b/src/db/models/user.rs @@ -234,6 +234,7 @@ impl User { .naive_utc() .checked_add_signed(Duration::minutes(2))) .expect("Duration add overflowed") + .and_utc() .timestamp(), ) .expect("underflow"), diff --git a/src/main.rs b/src/main.rs @@ -1,4 +1,11 @@ #![deny( + future_incompatible, + let_underscore, + nonstandard_style, + rust_2018_compatibility, + rust_2018_idioms, + rust_2021_compatibility, + rust_2024_compatibility, unsafe_code, unused, warnings, @@ -147,12 +154,9 @@ async fn create_db_pool() -> db::DbPool { u32::from(config::get_config().db_connection_retries.get()), ) .await) - .map_or_else( - |_| { - process::exit(1); - }, - |p| p, - ) + .unwrap_or_else(|_| { + process::exit(1); + }) } async fn launch_rocket(pool: db::DbPool) -> Result<(), Error> {