Skip to content

[DevOps]: Extend browser login lifetime to 7 days - #500

Merged
tomvothecoder merged 3 commits into
E3SM-Project:mainfrom
tomvothecoder:devops/487-session-lifetime
Nov 17, 2026
Merged

tomvothecoder merged 3 commits into
E3SM-Project:mainfrom
tomvothecoder:devops/487-session-lifetime

Conversation

@tomvothecoder

Copy link
Copy Markdown
Collaborator

Description

Browser logins expired after 1 hour because the JWT lifetime was hardcoded to 3600 and ignored config.

  • Browser (GitHub OAuth cookie) JWTs now expire with the cookie, using COOKIE_MAX_AGE, which defaults to 7 days (604800). I removed the unused lifetime_seconds setting.
  • Admin password-login bearer JWTs (/auth/jwt/login) keep a fixed 1-hour lifetime because they carry superuser privileges.
  • Compose, the env examples and the NERSC Spin runbook use 604800. The runbook now documents how to revoke access for one user or end all browser sessions.

Approach: fixed lifetime on stateless JWTs. Sliding refresh and server-side sessions were left out on purpose. Revisit them, using fastapi-users DatabaseStrategy, if we need per-user session revocation or SimBoard starts holding sensitive data.

Validation:

  • make backend-test: 2561 passed, 26 skipped
  • make pre-commit-run: all hooks passed
  • New tests: browser JWT lifetime follows COOKIE_MAX_AGE; bearer JWT lifetime stays at 1 hour

Risks:

  • Logout only clears the cookie, so a copied token stays valid for up to 7 days. The cookie is httpOnly, Secure and SameSite=Lax. The runbook covers revocation.
  • GitHub org membership is re-checked only at login, so edit rights can be up to 7 days stale.

Checklist

  • Code follows project style guidelines
  • Self-reviewed code
  • No new warnings
  • Tests added or updated (if needed)
  • All tests pass (locally and CI/CD)
  • Documentation/comments updated (if needed)
  • Breaking change noted (if applicable)

Deployment Notes (if any)

  • In each NERSC Spin environment, set COOKIE_MAX_AGE=604800 in the simboard-backend-env secret and redeploy the backend. Until then, the deployed value (3600) keeps the 1-hour lifetime.

The JWT lifetime was hardcoded to 1 hour and ignored config. Derive it from cookie_max_age so token and cookie expire together, drop the unused lifetime_seconds setting, and default to 7 days.
Raise COOKIE_MAX_AGE to 604800 in compose and env examples, and document in the NERSC Spin runbook how to revoke one user's or all browser sessions.
Password-login bearer JWTs shared the browser strategy and would have inherited the 7-day COOKIE_MAX_AGE. Give them their own 1-hour strategy. Make runbook revocation steps directly actionable.
@tomvothecoder
tomvothecoder marked this pull request as ready for review November 17, 2026 21:48
@tomvothecoder tomvothecoder added the devops DevOps task (e.g., DOE site ingestion, CI/CD, Docker) label Nov 17, 2026
@tomvothecoder tomvothecoder added this to the 3. Ongoing: DevOps milestone Nov 17, 2026
@tomvothecoder
tomvothecoder merged commit 6ec8bd8 into E3SM-Project:main Nov 17, 2026
1 of 3 checks passed
@tomvothecoder
tomvothecoder deleted the devops/487-session-lifetime branch November 17, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps task (e.g., DOE site ingestion, CI/CD, Docker)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DevOps]: Increase or refresh browser login token lifetime

1 participant