7 Commits

Author SHA1 Message Date
06ed444210 Update Rust crate serde_json to 1.0.146
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-23 00:26:49 +00:00
98c63056e6 Merge pull request 'Update Rust crate bincode to v3' (#447) from renovate/bincode-3.x into master
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-17 00:27:51 +00:00
f490d314e5 Update Rust crate bincode to v3
Some checks failed
renovate/artifacts Artifact file update failure
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is failing
2025-12-17 00:27:46 +00:00
6efd6a5abd Merge pull request 'Update Rust crate webauthn-rs to 0.5.4' (#446) from renovate/webauthn-rs-0.x into master
All checks were successful
continuous-integration/drone/push Build is passing
2025-12-12 00:27:34 +00:00
cc79501f5a Update Rust crate webauthn-rs to 0.5.4
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2025-12-11 00:28:09 +00:00
9535ab754a Hide real build time of application
All checks were successful
continuous-integration/drone/push Build is passing
2025-12-05 10:10:00 +01:00
b72fa90b67 Fix Hex encoding of assets file digests
All checks were successful
continuous-integration/drone/push Build is passing
2025-12-04 19:21:18 +01:00
4 changed files with 43 additions and 26 deletions

40
Cargo.lock generated
View File

@@ -560,9 +560,9 @@ checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba"
[[package]] [[package]]
name = "base64urlsafedata" name = "base64urlsafedata"
version = "0.5.3" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "215ee31f8a88f588c349ce2d20108b2ed96089b96b9c2b03775dc35dd72938e8" checksum = "42f7f6be94fa637132933fd0a68b9140bcb60e3d46164cb68e82a2bb8d102b3a"
dependencies = [ dependencies = [
"base64 0.21.7", "base64 0.21.7",
"pastey", "pastey",
@@ -578,16 +578,18 @@ dependencies = [
"actix-remote-ip", "actix-remote-ip",
"actix-session", "actix-session",
"actix-web", "actix-web",
"anyhow",
"askama", "askama",
"base32", "base32",
"base64 0.22.1", "base64 0.22.1",
"bcrypt", "bcrypt",
"bincode", "bincode 3.0.0",
"build-time", "build-time",
"chrono", "chrono",
"clap", "clap",
"digest 0.11.0-rc.4", "digest 0.11.0-rc.4",
"env_logger", "env_logger",
"hex",
"httpdate", "httpdate",
"include_dir", "include_dir",
"jwt-simple", "jwt-simple",
@@ -643,6 +645,12 @@ dependencies = [
"unty", "unty",
] ]
[[package]]
name = "bincode"
version = "3.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6a120d2e16b3e1b4a24bd70f23b12d3e16b81f113364a26935f8db7245452d"
[[package]] [[package]]
name = "bincode_derive" name = "bincode_derive"
version = "2.0.1" version = "2.0.1"
@@ -2050,7 +2058,7 @@ checksum = "a6a15777d080e807d5b6b3c0b5a293f7d4680d74a4c66b0cdf9db0441ea9f548"
dependencies = [ dependencies = [
"aes-gcm", "aes-gcm",
"base64 0.22.1", "base64 0.22.1",
"bincode", "bincode 2.0.1",
"log", "log",
"rand 0.9.2", "rand 0.9.2",
"reqwest", "reqwest",
@@ -2974,9 +2982,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.145" version = "1.0.146"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" checksum = "217ca874ae0207aac254aa02c957ded05585a90892cc8d87f9e5fa49669dadd8"
dependencies = [ dependencies = [
"itoa", "itoa",
"memchr", "memchr",
@@ -3669,9 +3677,9 @@ dependencies = [
[[package]] [[package]]
name = "webauthn-attestation-ca" name = "webauthn-attestation-ca"
version = "0.5.3" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f77a2892ec44032e6c48dad9aad1b05fada09c346ada11d8d32db119b4b4f205" checksum = "fafcf13f7dc1fb292ed4aea22cdd3757c285d7559e9748950ee390249da4da6b"
dependencies = [ dependencies = [
"base64urlsafedata", "base64urlsafedata",
"openssl", "openssl",
@@ -3683,9 +3691,9 @@ dependencies = [
[[package]] [[package]]
name = "webauthn-rs" name = "webauthn-rs"
version = "0.5.3" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb7c3a2f9c8bddd524e47bbd427bcf3a28aa074de55d74470b42a91a41937b8e" checksum = "1b24d082d3360258fefb6ffe56123beef7d6868c765c779f97b7a2fcf06727f8"
dependencies = [ dependencies = [
"base64urlsafedata", "base64urlsafedata",
"serde", "serde",
@@ -3697,9 +3705,9 @@ dependencies = [
[[package]] [[package]]
name = "webauthn-rs-core" name = "webauthn-rs-core"
version = "0.5.3" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19f1d80f3146382529fe70a3ab5d0feb2413a015204ed7843f9377cd39357fc4" checksum = "15784340a24c170ce60567282fb956a0938742dbfbf9eff5df793a686a009b8b"
dependencies = [ dependencies = [
"base64 0.21.7", "base64 0.21.7",
"base64urlsafedata", "base64urlsafedata",
@@ -3708,8 +3716,8 @@ dependencies = [
"nom", "nom",
"openssl", "openssl",
"openssl-sys", "openssl-sys",
"rand 0.8.5", "rand 0.9.2",
"rand_chacha 0.3.1", "rand_chacha 0.9.0",
"serde", "serde",
"serde_cbor_2", "serde_cbor_2",
"serde_json", "serde_json",
@@ -3724,9 +3732,9 @@ dependencies = [
[[package]] [[package]]
name = "webauthn-rs-proto" name = "webauthn-rs-proto"
version = "0.5.3" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e786894f89facb9aaf1c5f6559670236723c98382e045521c76f3d5ca5047bd" checksum = "16a1fb2580ce73baa42d3011a24de2ceab0d428de1879ece06e02e8c416e497c"
dependencies = [ dependencies = [
"base64 0.21.7", "base64 0.21.7",
"base64urlsafedata", "base64urlsafedata",

View File

@@ -14,7 +14,7 @@ actix-remote-ip = "0.1.0"
clap = { version = "4.5.53", features = ["derive", "env"] } clap = { version = "4.5.53", features = ["derive", "env"] }
include_dir = "0.7.4" include_dir = "0.7.4"
log = "0.4.29" log = "0.4.29"
serde_json = "1.0.145" serde_json = "1.0.146"
serde_yaml = "0.9.34" serde_yaml = "0.9.34"
env_logger = "0.11.8" env_logger = "0.11.8"
serde = { version = "1.0.228", features = ["derive"] } serde = { version = "1.0.228", features = ["derive"] }
@@ -32,12 +32,14 @@ lazy-regex = "3.4.2"
totp_rfc6238 = "0.6.1" totp_rfc6238 = "0.6.1"
base32 = "0.5.1" base32 = "0.5.1"
qrcode-generator = "5.0.0" qrcode-generator = "5.0.0"
webauthn-rs = { version = "0.5.3", features = ["danger-allow-state-serialisation"] } webauthn-rs = { version = "0.5.4", features = ["danger-allow-state-serialisation"] }
url = "2.5.7" url = "2.5.7"
light-openid = { version = "1.0.4", features = ["crypto-wrapper"] } light-openid = { version = "1.0.4", features = ["crypto-wrapper"] }
bincode = "2.0.1" bincode = "3.0.0"
chrono = "0.4.42" chrono = "0.4.42"
lazy_static = "1.5.0" lazy_static = "1.5.0"
mailchecker = "6.0.19" mailchecker = "6.0.19"
httpdate = "1.0.3" httpdate = "1.0.3"
build-time = "0.1.3" build-time = "0.1.3"
hex = "0.4.3"
anyhow = "1.0.100"

View File

@@ -3,6 +3,7 @@ use crate::utils::time_utils;
use actix_web::http::header; use actix_web::http::header;
use actix_web::{HttpRequest, HttpResponse, web}; use actix_web::{HttpRequest, HttpResponse, web};
use include_dir::{Dir, include_dir}; use include_dir::{Dir, include_dir};
use std::cmp::max;
use std::ops::Add; use std::ops::Add;
use std::path::Path; use std::path::Path;
use std::time::Duration; use std::time::Duration;
@@ -22,14 +23,15 @@ pub async fn assets_route(req: HttpRequest, path: web::Path<String>) -> HttpResp
None => HttpResponse::NotFound().body("404 Not found"), None => HttpResponse::NotFound().body("404 Not found"),
Some(file) => { Some(file) => {
let res = mime_guess::from_path(path).first_or_octet_stream(); let res = mime_guess::from_path(path).first_or_octet_stream();
let digest = format!("{:x?}", sha256(file.contents())); let digest = hex::encode(sha256(file.contents()));
let file_time = max(time_utils::time_start_of_day(), time_utils::build_time());
// Check if the browser already knows the file by date // Check if the browser already knows the file by date
if let Some(c) = req.headers().get(header::IF_MODIFIED_SINCE) { if let Some(c) = req.headers().get(header::IF_MODIFIED_SINCE) {
let date_str = c.to_str().unwrap_or(""); let date_str = c.to_str().unwrap_or("");
if let Ok(date) = httpdate::parse_http_date(date_str) if let Ok(date) = httpdate::parse_http_date(date_str)
&& date.add(Duration::from_secs(1)) && date.add(Duration::from_secs(1))
>= time_utils::unix_to_system_time(time_utils::build_time()) >= time_utils::unix_to_system_time(file_time)
{ {
return HttpResponse::NotModified().finish(); return HttpResponse::NotModified().finish();
} }
@@ -45,10 +47,7 @@ pub async fn assets_route(req: HttpRequest, path: web::Path<String>) -> HttpResp
HttpResponse::Ok() HttpResponse::Ok()
.content_type(res.to_string()) .content_type(res.to_string())
.insert_header(("etag", digest)) .insert_header(("etag", digest))
.insert_header(( .insert_header(("last-modified", time_utils::unix_to_http_date(file_time)))
"last-modified",
time_utils::unix_to_http_date(time_utils::build_time()),
))
.body(file.contents()) .body(file.contents())
} }
} }

View File

@@ -1,4 +1,4 @@
use chrono::DateTime; use chrono::{DateTime, Local, NaiveTime};
use std::time::{Duration, SystemTime, UNIX_EPOCH}; use std::time::{Duration, SystemTime, UNIX_EPOCH};
/// Get the current time since epoch /// Get the current time since epoch
@@ -37,6 +37,14 @@ pub fn build_time() -> u64 {
date.timestamp() as u64 date.timestamp() as u64
} }
/// Get the first second of the day (local time)
pub fn time_start_of_day() -> u64 {
let local: DateTime<Local> = Local::now()
.with_time(NaiveTime::from_hms_opt(0, 0, 0).unwrap())
.unwrap();
local.timestamp() as u64
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use crate::utils::time_utils::{fmt_time, time}; use crate::utils::time_utils::{fmt_time, time};