diff options
| author | tv <tv@krebsco.de> | 2026-11-09 15:34:54 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-09 18:18:50 +0100 |
| commit | c1e750c5f795d4dd659be99f873ab7f98d5a2e83 (patch) | |
| tree | a775d2524a0487340f48922eecd31ca207715e5d /src/access/token.rs | |
| parent | 9e02f103f3472055cb3293e64a43804f0e49195f (diff) | |
api: a stream opened by password or a proxy's header ends with its user
Review 4, F11: only streams answered to a token ended with it (1273); one opened by
password (basic authentication) or a proxy's header went on after its user was
disabled or removed.
`streams_end` now wraps those too, by the user `basic_auth` leaves on the answer: such
a stream ends once the document no longer has its user, enabled
(`token::user_taken`, the part of a token's check about its user, which
`still_taken` uses too), looked at as the stream begins and as protocol data changes.
No expiry: a password has none.
Diffstat (limited to 'src/access/token.rs')
| -rw-r--r-- | src/access/token.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/access/token.rs b/src/access/token.rs index a9fc270..153737e 100644 --- a/src/access/token.rs +++ b/src/access/token.rs @@ -174,11 +174,8 @@ fn issuer_counts(doc: &impl ReadDoc, claims: &Claims) -> Result<(), Refused> { /// In a swarm with a registry: its user registered, enabled, its tokens not revoked /// since it was issued, its session not ended. fn user_counts(doc: &impl ReadDoc, claims: &Claims) -> Result<(), Refused> { - if registry::exists(doc) { - let user = registry::user(doc, &claims.user).ok_or(Refused::UnknownUser)?; - if user.disabled { - return Err(Refused::Disabled); - } + user_taken(doc, &claims.user)?; + if let Some(user) = registry::user(doc, &claims.user) { if claims.iat < user.tokens_not_before { return Err(Refused::Revoked); } @@ -189,6 +186,19 @@ fn user_counts(doc: &impl ReadDoc, claims: &Claims) -> Result<(), Refused> { Ok(()) } +/// In a swarm with a registry: user `name` registered and enabled. What a stream opened +/// by password or a proxy's header is judged by as the document changes +/// (`api::login::streams_end`), as one opened with a token is by `still_taken`. +pub(crate) fn user_taken(doc: &impl ReadDoc, name: &str) -> Result<(), Refused> { + if registry::exists(doc) { + let user = registry::user(doc, name).ok_or(Refused::UnknownUser)?; + if user.disabled { + return Err(Refused::Disabled); + } + } + Ok(()) +} + /// A new session's ID (8 random bytes, hex). pub(crate) fn new_session() -> String { registry::new_id() |
