feat: adjust digest auth timeout to 1day (#110)

This commit is contained in:
sigoden 2022-07-21 11:47:47 +08:00 committed by GitHub
parent b791549ec7
commit 9cfd66dab9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -12,6 +12,7 @@ use crate::utils::encode_uri;
use crate::BoxResult; use crate::BoxResult;
const REALM: &str = "DUFS"; const REALM: &str = "DUFS";
const DIGEST_AUTH_TIMEOUT: u32 = 86400;
lazy_static! { lazy_static! {
static ref NONCESTARTHASH: Context = { static ref NONCESTARTHASH: Context = {
@ -317,8 +318,7 @@ fn validate_nonce(nonce: &[u8]) -> Result<bool, ()> {
h.consume(secs_nonce.to_be_bytes()); h.consume(secs_nonce.to_be_bytes());
let h = format!("{:x}", h.compute()); let h = format!("{:x}", h.compute());
if h[..26] == n[8..34] { if h[..26] == n[8..34] {
return Ok(dur < 300); // from the last 5min return Ok(dur < DIGEST_AUTH_TIMEOUT);
//Authentication-Info ?
} }
} }
} }