7 Commits

Author SHA1 Message Date
7564702bd5 Update Rust crate askama to 0.15.0
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-23 00:26:53 +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 60 additions and 33 deletions

64
Cargo.lock generated
View File

@@ -422,11 +422,11 @@ checksum = "71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a"
[[package]] [[package]]
name = "askama" name = "askama"
version = "0.14.0" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4" checksum = "21c01049339e624573a8027fe9392219f64d315a0ad24712b469611b3138f042"
dependencies = [ dependencies = [
"askama_derive", "askama_macros",
"itoa", "itoa",
"percent-encoding", "percent-encoding",
"serde", "serde",
@@ -435,9 +435,9 @@ dependencies = [
[[package]] [[package]]
name = "askama_derive" name = "askama_derive"
version = "0.14.0" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f" checksum = "e393a25182a000666df345c2bdaa9ab6b0c243974ec7d29e377d6feea651778d"
dependencies = [ dependencies = [
"askama_parser", "askama_parser",
"basic-toml", "basic-toml",
@@ -451,14 +451,24 @@ dependencies = [
] ]
[[package]] [[package]]
name = "askama_parser" name = "askama_macros"
version = "0.14.0" version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358" checksum = "4e8bb77385d2954705452516f99511835be34b4c4a15a70800623b91406b1db9"
dependencies = [ dependencies = [
"memchr", "askama_derive",
]
[[package]]
name = "askama_parser"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb6401aa356822013db13e8f756011cd5042e7e61d37456bb8b7ef26feb8ebca"
dependencies = [
"rustc-hash",
"serde", "serde",
"serde_derive", "serde_derive",
"unicode-ident",
"winnow", "winnow",
] ]
@@ -560,9 +570,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 +588,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 +655,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 +2068,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",
@@ -3669,9 +3687,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 +3701,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 +3715,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 +3726,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 +3742,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

@@ -21,7 +21,7 @@ serde = { version = "1.0.228", features = ["derive"] }
bcrypt = "0.17.1" bcrypt = "0.17.1"
uuid = { version = "1.19.0", features = ["v4"] } uuid = { version = "1.19.0", features = ["v4"] }
mime_guess = "2.0.5" mime_guess = "2.0.5"
askama = "0.14.0" askama = "0.15.0"
urlencoding = "2.1.3" urlencoding = "2.1.3"
rand = "0.10.0-rc.5" rand = "0.10.0-rc.5"
base64 = "0.22.1" base64 = "0.22.1"
@@ -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};