Compare commits
7 Commits
20251204
...
renovate/s
| Author | SHA1 | Date | |
|---|---|---|---|
| 06ed444210 | |||
| 98c63056e6 | |||
| f490d314e5 | |||
| 6efd6a5abd | |||
| cc79501f5a | |||
| 9535ab754a | |||
| b72fa90b67 |
40
Cargo.lock
generated
40
Cargo.lock
generated
@@ -560,9 +560,9 @@ checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba"
|
||||
|
||||
[[package]]
|
||||
name = "base64urlsafedata"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "215ee31f8a88f588c349ce2d20108b2ed96089b96b9c2b03775dc35dd72938e8"
|
||||
checksum = "42f7f6be94fa637132933fd0a68b9140bcb60e3d46164cb68e82a2bb8d102b3a"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"pastey",
|
||||
@@ -578,16 +578,18 @@ dependencies = [
|
||||
"actix-remote-ip",
|
||||
"actix-session",
|
||||
"actix-web",
|
||||
"anyhow",
|
||||
"askama",
|
||||
"base32",
|
||||
"base64 0.22.1",
|
||||
"bcrypt",
|
||||
"bincode",
|
||||
"bincode 3.0.0",
|
||||
"build-time",
|
||||
"chrono",
|
||||
"clap",
|
||||
"digest 0.11.0-rc.4",
|
||||
"env_logger",
|
||||
"hex",
|
||||
"httpdate",
|
||||
"include_dir",
|
||||
"jwt-simple",
|
||||
@@ -643,6 +645,12 @@ dependencies = [
|
||||
"unty",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "3.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fd6a120d2e16b3e1b4a24bd70f23b12d3e16b81f113364a26935f8db7245452d"
|
||||
|
||||
[[package]]
|
||||
name = "bincode_derive"
|
||||
version = "2.0.1"
|
||||
@@ -2050,7 +2058,7 @@ checksum = "a6a15777d080e807d5b6b3c0b5a293f7d4680d74a4c66b0cdf9db0441ea9f548"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"base64 0.22.1",
|
||||
"bincode",
|
||||
"bincode 2.0.1",
|
||||
"log",
|
||||
"rand 0.9.2",
|
||||
"reqwest",
|
||||
@@ -2974,9 +2982,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.145"
|
||||
version = "1.0.146"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||
checksum = "217ca874ae0207aac254aa02c957ded05585a90892cc8d87f9e5fa49669dadd8"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
@@ -3669,9 +3677,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webauthn-attestation-ca"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f77a2892ec44032e6c48dad9aad1b05fada09c346ada11d8d32db119b4b4f205"
|
||||
checksum = "fafcf13f7dc1fb292ed4aea22cdd3757c285d7559e9748950ee390249da4da6b"
|
||||
dependencies = [
|
||||
"base64urlsafedata",
|
||||
"openssl",
|
||||
@@ -3683,9 +3691,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webauthn-rs"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb7c3a2f9c8bddd524e47bbd427bcf3a28aa074de55d74470b42a91a41937b8e"
|
||||
checksum = "1b24d082d3360258fefb6ffe56123beef7d6868c765c779f97b7a2fcf06727f8"
|
||||
dependencies = [
|
||||
"base64urlsafedata",
|
||||
"serde",
|
||||
@@ -3697,9 +3705,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webauthn-rs-core"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19f1d80f3146382529fe70a3ab5d0feb2413a015204ed7843f9377cd39357fc4"
|
||||
checksum = "15784340a24c170ce60567282fb956a0938742dbfbf9eff5df793a686a009b8b"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"base64urlsafedata",
|
||||
@@ -3708,8 +3716,8 @@ dependencies = [
|
||||
"nom",
|
||||
"openssl",
|
||||
"openssl-sys",
|
||||
"rand 0.8.5",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand 0.9.2",
|
||||
"rand_chacha 0.9.0",
|
||||
"serde",
|
||||
"serde_cbor_2",
|
||||
"serde_json",
|
||||
@@ -3724,9 +3732,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "webauthn-rs-proto"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9e786894f89facb9aaf1c5f6559670236723c98382e045521c76f3d5ca5047bd"
|
||||
checksum = "16a1fb2580ce73baa42d3011a24de2ceab0d428de1879ece06e02e8c416e497c"
|
||||
dependencies = [
|
||||
"base64 0.21.7",
|
||||
"base64urlsafedata",
|
||||
|
||||
@@ -14,7 +14,7 @@ actix-remote-ip = "0.1.0"
|
||||
clap = { version = "4.5.53", features = ["derive", "env"] }
|
||||
include_dir = "0.7.4"
|
||||
log = "0.4.29"
|
||||
serde_json = "1.0.145"
|
||||
serde_json = "1.0.146"
|
||||
serde_yaml = "0.9.34"
|
||||
env_logger = "0.11.8"
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
@@ -32,12 +32,14 @@ lazy-regex = "3.4.2"
|
||||
totp_rfc6238 = "0.6.1"
|
||||
base32 = "0.5.1"
|
||||
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"
|
||||
light-openid = { version = "1.0.4", features = ["crypto-wrapper"] }
|
||||
bincode = "2.0.1"
|
||||
bincode = "3.0.0"
|
||||
chrono = "0.4.42"
|
||||
lazy_static = "1.5.0"
|
||||
mailchecker = "6.0.19"
|
||||
httpdate = "1.0.3"
|
||||
build-time = "0.1.3"
|
||||
hex = "0.4.3"
|
||||
anyhow = "1.0.100"
|
||||
|
||||
@@ -3,6 +3,7 @@ use crate::utils::time_utils;
|
||||
use actix_web::http::header;
|
||||
use actix_web::{HttpRequest, HttpResponse, web};
|
||||
use include_dir::{Dir, include_dir};
|
||||
use std::cmp::max;
|
||||
use std::ops::Add;
|
||||
use std::path::Path;
|
||||
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"),
|
||||
Some(file) => {
|
||||
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
|
||||
if let Some(c) = req.headers().get(header::IF_MODIFIED_SINCE) {
|
||||
let date_str = c.to_str().unwrap_or("");
|
||||
if let Ok(date) = httpdate::parse_http_date(date_str)
|
||||
&& 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();
|
||||
}
|
||||
@@ -45,10 +47,7 @@ pub async fn assets_route(req: HttpRequest, path: web::Path<String>) -> HttpResp
|
||||
HttpResponse::Ok()
|
||||
.content_type(res.to_string())
|
||||
.insert_header(("etag", digest))
|
||||
.insert_header((
|
||||
"last-modified",
|
||||
time_utils::unix_to_http_date(time_utils::build_time()),
|
||||
))
|
||||
.insert_header(("last-modified", time_utils::unix_to_http_date(file_time)))
|
||||
.body(file.contents())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use chrono::DateTime;
|
||||
use chrono::{DateTime, Local, NaiveTime};
|
||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
||||
|
||||
/// Get the current time since epoch
|
||||
@@ -37,6 +37,14 @@ pub fn build_time() -> 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)]
|
||||
mod test {
|
||||
use crate::utils::time_utils::{fmt_time, time};
|
||||
|
||||
Reference in New Issue
Block a user