feat(auth): deny-by-default HTTP layer
A global middleware wraps the router and its fallback: only PUBLIC_ROUTES answer without a credential, and unknown paths look like protected ones. Adds cookie sessions with per-session CSRF, scoped Bearer tokens, the /api/auth and /api/admin handlers, Transport for client IP and Secure, and pending-token enrollment re-checked inside one store update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a90ff81650
commit
2b1bc63340
11 files changed
+2455
-79
No files matched your search
@@ -85,6 +85,17 @@ pub struct TokenView {
|
||||
pub expires_at: u64,
|
||||
}
|
||||
|
||||
/// The anti-CSRF value of a session. Derived from the session token with a
|
||||
/// domain prefix, so it needs no storage, dies with the session, and differs
|
||||
/// from the digest kept in the store.
|
||||
pub fn csrf_token(session_token: &str) -> String {
|
||||
hash_token(&format!("acaua-csrf:{session_token}"))
|
||||
}
|
||||
|
||||
pub fn csrf_matches(session_token: &str, candidate: &str) -> bool {
|
||||
ct_eq(&csrf_token(session_token), candidate)
|
||||
}
|
||||
|
||||
fn ct_eq(a: &str, b: &str) -> bool {
|
||||
a.as_bytes().ct_eq(b.as_bytes()).into()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user