diff options
| author | tv <tv@krebsco.de> | 2026-11-07 22:35:09 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-07 22:35:09 +0100 |
| commit | ec70060ae5fa665953741da921e28031b56bc5e0 (patch) | |
| tree | cd1f6f5ae90d3ad87b9667da20d6e85b62394ab1 /src/config | |
| parent | eed8f86912f53f549d9f9068f9bdf2c8e23aa0f7 (diff) | |
auth: logging in, and tokens as bearers
POST /auth/login (by htpasswd or the proxy), /auth/refresh,
/auth/logout, GET /auth/whoami; every request may bring
Authorization: Bearer instead of a password. --token-lifetime and
--session-lifetime.
Auth plan M2.
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/mod.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 5306c5e..60ad413 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -124,6 +124,20 @@ pub(crate) const OPTIONS: &[OptionSpec] = &[ "HTTP API users (from htpasswd or user-header) who may write protocol data under /store/_continuum (remake records, members, forget records), e.g. to repair a stuck remake, in a swarm without a user registry. Such writes act on the whole swarm and are logged. Epoch metadata and the swarm ID are never writable. With a registry its capabilities decide instead (docs/access.md), but for a registry nobody may manage users of any more: then these may do everything on this node, to set it right.", ), option( + "token-lifetime", + Kind::Duration, + "DURATION", + Some("12h"), + "How long a token this node issues (POST /auth/login, /auth/refresh) is taken, by every node of the swarm (docs/access.md, Tokens). Refreshed before it ends, it lasts until the login's end (session-lifetime).", + ), + option( + "session-lifetime", + Kind::Duration, + "DURATION", + Some("7d"), + "How long after a login (POST /auth/login) its tokens may be refreshed; then the user logs in again.", + ), + option( "bootstrap-users", Kind::List, "USER,[USER...]", @@ -543,6 +557,16 @@ pub(crate) struct Settings { pub(crate) protocol_writers: Vec<String>, #[serde(default)] pub(crate) bootstrap_users: Vec<String>, + #[serde( + default = "default_token_lifetime", + with = "crate::units::duration_option" + )] + pub(crate) token_lifetime: Duration, + #[serde( + default = "default_session_lifetime", + with = "crate::units::duration_option" + )] + pub(crate) session_lifetime: Duration, #[serde(default)] pub(crate) debug_api: bool, #[serde(default = "default_log_format")] @@ -700,6 +724,12 @@ fn default_document_append() -> Duration { fn default_document_rewrite() -> Duration { Duration::from_secs(3600) } +fn default_token_lifetime() -> Duration { + Duration::from_secs(12 * 3600) +} +fn default_session_lifetime() -> Duration { + Duration::from_secs(7 * 24 * 3600) +} fn default_keepalive() -> Duration { Duration::from_secs(60) } |
