T13.11: session limit defaults to 8 hours (D25)
This commit is contained in:
@@ -24,7 +24,7 @@ In the stack's **Environment variables** section, add:
|
|||||||
| Name | Value | Notes |
|
| Name | Value | Notes |
|
||||||
|------|-------|-------|
|
|------|-------|-------|
|
||||||
| `AUTH_SECRET_KEY` | a long random string | **Required.** Signs the login session cookies. |
|
| `AUTH_SECRET_KEY` | a long random string | **Required.** Signs the login session cookies. |
|
||||||
| `AUTH_SESSION_HOURS` | `12` | *Optional.* Hours a login lasts before re-auth (defaults to 12). |
|
| `AUTH_SESSION_HOURS` | `8` | *Optional.* Hours a login lasts before re-auth (defaults to 8). |
|
||||||
|
|
||||||
Generate the secret on the host with:
|
Generate the secret on the host with:
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ services:
|
|||||||
# REQUIRED — compose fails fast if it's unset, and the API refuses to
|
# REQUIRED — compose fails fast if it's unset, and the API refuses to
|
||||||
# start in production without it (see server/auth.py).
|
# start in production without it (see server/auth.py).
|
||||||
AUTH_SECRET_KEY: ${AUTH_SECRET_KEY:?set AUTH_SECRET_KEY in .env (see server/.env.example)}
|
AUTH_SECRET_KEY: ${AUTH_SECRET_KEY:?set AUTH_SECRET_KEY in .env (see server/.env.example)}
|
||||||
AUTH_SESSION_HOURS: ${AUTH_SESSION_HOURS:-12}
|
AUTH_SESSION_HOURS: ${AUTH_SESSION_HOURS:-8}
|
||||||
# Okta OIDC — the only sign-in path (D15/D16). Not marked required the
|
# Okta OIDC — the only sign-in path (D15/D16). Not marked required the
|
||||||
# way AUTH_SECRET_KEY is: the API starts without these, it just refuses
|
# way AUTH_SECRET_KEY is: the API starts without these, it just refuses
|
||||||
# every sign-in and says so in the startup log (server/okta_auth.py
|
# every sign-in and says so in the startup log (server/okta_auth.py
|
||||||
|
|||||||
@@ -94,3 +94,22 @@ status and Okta's short error code only. The SSWS token path is unchanged.
|
|||||||
|
|
||||||
**Not verified:** this has been tested only against a fake Okta that follows the RFC. The
|
**Not verified:** this has been tested only against a fake Okta that follows the RFC. The
|
||||||
first run against the real tenant is the real test.
|
first run against the real tenant is the real test.
|
||||||
|
|
||||||
|
## D25: the session limit is 8 hours for now
|
||||||
|
|
||||||
|
**Decided by:** Matt Mabrey, 2026-10-17. **Closes:** the 2-versus-8 question in `wave-13.md`. **Task:** T13.11.
|
||||||
|
|
||||||
|
**The conflict:** the wave 13 exit criteria said `AUTH_SESSION_HOURS` defaults to 2. T13.1's own text and
|
||||||
|
the T13.1 code say 8. The shipped default on `main` was 12.
|
||||||
|
|
||||||
|
**Decision:** The default is **8 hours**. This replaces the exit criterion of 2 hours.
|
||||||
|
|
||||||
|
- `AUTH_SESSION_HOURS` defaults to 8 in `server/auth.py`, `docker-compose.yml`, `server/.env.example` and
|
||||||
|
`DEPLOY-login-portal.md`. A value that is set still wins.
|
||||||
|
- Until T13.1 lands, 8 hours is one flat limit from the moment of sign-in, with no sliding. Once T13.1 lands, the
|
||||||
|
same variable is the absolute ceiling and an idle timer sits under it. The default does not change then.
|
||||||
|
- A person who signs in at the start of a shift is signed out 8 hours later, whatever they were doing. Signing in
|
||||||
|
again needs Okta to be reachable.
|
||||||
|
|
||||||
|
**Open, for wave 14:** how the limit works for a crew that is offline. `wave-14.md` sets that rule.
|
||||||
|
**Not decided here:** the idle time (T13.1 proposes 30 minutes). It is a proposed value, not a decision.
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ introduce a path that swallows the client's error and proceeds anyway.
|
|||||||
|
|
||||||
## Wave 13 exit criteria
|
## Wave 13 exit criteria
|
||||||
|
|
||||||
- [ ] `AUTH_SESSION_HOURS` defaults to 2, documented
|
- [x] `AUTH_SESSION_HOURS` defaults to 8, documented (D25 replaced the 2 hours in this line; T13.1's idle timer is still held back)
|
||||||
- [x] the sync job runs on a schedule and correctly disables accounts Okta no
|
- [x] the sync job runs on a schedule and correctly disables accounts Okta no
|
||||||
longer shows as active
|
longer shows as active
|
||||||
- [x] every auto-disable is individually audited with a clearly non-human actor
|
- [x] every auto-disable is individually audited with a clearly non-human actor
|
||||||
@@ -463,3 +463,17 @@ console of `wp_api` (no `docker compose exec` prefix). `promote` changes an exis
|
|||||||
by sync", item `admin`, detail `okta_status: MISSING, via: okta_sync`, at 11:46 AM local (18:46 UTC).
|
by sync", item `admin`, detail `okta_status: MISSING, via: okta_sync`, at 11:46 AM local (18:46 UTC).
|
||||||
- `D18` cannot be called fully accounted for while T13.1 is outstanding.
|
- `D18` cannot be called fully accounted for while T13.1 is outstanding.
|
||||||
- `BL-069` (a cap on one run and a last-admin guard) is open.
|
- `BL-069` (a cap on one run and a last-admin guard) is open.
|
||||||
|
|
||||||
|
## T13.11: D25 the session limit is 8 hours
|
||||||
|
|
||||||
|
**Item:** D25 (`docs/waves/decisions-2026-10-16.md`).
|
||||||
|
|
||||||
|
**Done when:**
|
||||||
|
|
||||||
|
- [x] `AUTH_SESSION_HOURS` defaults to 8 in `server/auth.py`, `docker-compose.yml`, `server/.env.example`, `DEPLOY-login-portal.md` (`tests/session_default_check.py`)
|
||||||
|
- [x] the token expiry and the cookie max-age follow it; a set value overrides it
|
||||||
|
- [x] mutation check: putting the default back to 12 makes the test fail
|
||||||
|
- [x] the wave 13 exit criterion that said 2 is updated
|
||||||
|
|
||||||
|
Effect on the live system: after the next deploy, sessions last 8 hours instead of 12. To get the same result
|
||||||
|
before a deploy, set `AUTH_SESSION_HOURS` to `8` in the Portainer stack variables.
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ DATABASE_URL=postgresql+psycopg://wpsuite:CHANGE_ME@localhost:5432/wpsuite
|
|||||||
# python -c "import secrets; print(secrets.token_urlsafe(48))"
|
# python -c "import secrets; print(secrets.token_urlsafe(48))"
|
||||||
AUTH_SECRET_KEY=CHANGE_ME_run_the_command_above
|
AUTH_SECRET_KEY=CHANGE_ME_run_the_command_above
|
||||||
|
|
||||||
# How long a login lasts before re-authentication (hours). Default 12.
|
# How long a login lasts before re-authentication (hours). Default 8 (D25).
|
||||||
# AUTH_SESSION_HOURS=12
|
# AUTH_SESSION_HOURS=8
|
||||||
|
|
||||||
# ── Okta OIDC (required — this is the only sign-in path) ───────────────────────
|
# ── Okta OIDC (required — this is the only sign-in path) ───────────────────────
|
||||||
# The Okta *authorization server* issuer, e.g. https://yourorg.okta.com/oauth2/default
|
# The Okta *authorization server* issuer, e.g. https://yourorg.okta.com/oauth2/default
|
||||||
|
|||||||
@@ -59,8 +59,10 @@ log = logging.getLogger("wpsuite.auth")
|
|||||||
|
|
||||||
COOKIE_NAME = "wp_session"
|
COOKIE_NAME = "wp_session"
|
||||||
JWT_ALG = "HS256"
|
JWT_ALG = "HS256"
|
||||||
# How long a session lasts before the person must sign in again.
|
# How long a session lasts before the person must sign in again. Default 8 hours (D25).
|
||||||
SESSION_HOURS = int(os.getenv("AUTH_SESSION_HOURS", "12"))
|
# One flat limit from the moment of sign-in. When T13.1 lands, the same variable becomes
|
||||||
|
# the absolute ceiling and an idle timer is added under it.
|
||||||
|
SESSION_HOURS = int(os.getenv("AUTH_SESSION_HOURS", "8"))
|
||||||
|
|
||||||
# ── permissions roles ─────────────────────────────────────────────────────────
|
# ── permissions roles ─────────────────────────────────────────────────────────
|
||||||
ROLE_ADMIN = "admin"
|
ROLE_ADMIN = "admin"
|
||||||
|
|||||||
66
tests/session_default_check.py
Normal file
66
tests/session_default_check.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Is the session limit 8 hours by default? - D25 / T13.11.
|
||||||
|
|
||||||
|
The default of AUTH_SESSION_HOURS is 8. The token expiry and the cookie max-age both
|
||||||
|
follow it, a set value overrides it, and the shipped files name the same default.
|
||||||
|
|
||||||
|
Self-contained: no network, no server, no browser. Exit 0 all passed, 1 a failure.
|
||||||
|
"""
|
||||||
|
import importlib
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
sys.path.insert(0, ROOT)
|
||||||
|
os.environ["DATABASE_URL"] = "sqlite://"
|
||||||
|
os.environ["AUTH_SECRET_KEY"] = "session-default-check-secret-0123456789abcdef"
|
||||||
|
|
||||||
|
fails = 0
|
||||||
|
|
||||||
|
|
||||||
|
def chk(label, ok, extra=""):
|
||||||
|
global fails
|
||||||
|
print(("PASS " if ok else "FAIL ") + label + (f" [{extra}]" if (extra and not ok) else ""))
|
||||||
|
if not ok:
|
||||||
|
fails += 1
|
||||||
|
|
||||||
|
|
||||||
|
def load(value):
|
||||||
|
if value is None:
|
||||||
|
os.environ.pop("AUTH_SESSION_HOURS", None)
|
||||||
|
else:
|
||||||
|
os.environ["AUTH_SESSION_HOURS"] = value
|
||||||
|
from server import auth
|
||||||
|
return importlib.reload(auth)
|
||||||
|
|
||||||
|
|
||||||
|
import jwt # noqa: E402
|
||||||
|
|
||||||
|
user = SimpleNamespace(id="u1", username="a", role="project_user", token_version=0)
|
||||||
|
|
||||||
|
auth = load(None)
|
||||||
|
chk("default is 8 hours", auth.SESSION_HOURS == 8, str(auth.SESSION_HOURS))
|
||||||
|
claims = jwt.decode(auth.create_token(user), auth.SECRET_KEY, algorithms=["HS256"])
|
||||||
|
hours = (datetime.fromtimestamp(claims["exp"], timezone.utc) - datetime.fromtimestamp(claims["iat"], timezone.utc)).total_seconds() / 3600
|
||||||
|
chk("a new token lasts 8 hours", abs(hours - 8) < 0.01, str(hours))
|
||||||
|
|
||||||
|
auth = load("2")
|
||||||
|
chk("AUTH_SESSION_HOURS=2 overrides the default", auth.SESSION_HOURS == 2)
|
||||||
|
auth = load("12")
|
||||||
|
chk("AUTH_SESSION_HOURS=12 overrides the default", auth.SESSION_HOURS == 12)
|
||||||
|
load(None)
|
||||||
|
|
||||||
|
def read(p):
|
||||||
|
return open(os.path.join(ROOT, p), encoding="utf-8").read()
|
||||||
|
|
||||||
|
chk("docker-compose.yml defaults to 8", "AUTH_SESSION_HOURS: ${AUTH_SESSION_HOURS:-8}" in read("docker-compose.yml"))
|
||||||
|
chk(".env.example says 8", re.search(r"^# AUTH_SESSION_HOURS=8$", read("server/.env.example"), re.M) is not None)
|
||||||
|
chk("DEPLOY-login-portal.md says 8", "defaults to 8" in read("DEPLOY-login-portal.md"))
|
||||||
|
for p in ("docker-compose.yml", "server/.env.example", "DEPLOY-login-portal.md", "server/auth.py"):
|
||||||
|
chk(f"no leftover default of 12 in {p}", not re.search(r"AUTH_SESSION_HOURS[^\n]{0,30}\b12\b", read(p)))
|
||||||
|
|
||||||
|
print("\nDONE" if fails == 0 else f"\n{fails} FAILED")
|
||||||
|
sys.exit(1 if fails else 0)
|
||||||
Reference in New Issue
Block a user