Skip to content

Add longer web-session and issue a web refresh token - #77

Merged
tekrajchhetri merged 2 commits into
improve-ingestion-query-servicefrom
ui-session-refresh
Aug 11, 2026
Merged

Add longer web-session and issue a web refresh token#77
tekrajchhetri merged 2 commits into
improve-ingestion-query-servicefrom
ui-session-refresh

Conversation

@tekrajchhetri

Copy link
Copy Markdown
Collaborator

This PR adds longer web-session token so the UI stops 401-ing mid-session and issue a web refresh token at OAuth login for silent renew.

…session

The OAuth callback handed the UI a 30-min HS256 token that NextAuth stores and
never refreshes, so after 30 min /api/users/me (and the profile/activity routes
that reuse the session token) returned 401/404. Make create_access_token_v2 take
an expires_minutes override and have the OAuth callback mint the web-session token
with USERMANAGEMENT_WEB_SESSION_TTL_MIN (default 720 = 12h). Password-login and
per-service tokens keep their short defaults.
…enew

The OAuth callback now also mints a longer-lived SSO refresh token (aud=brainkb-auth,
USERMANAGEMENT_WEB_REFRESH_TTL_MIN, default 7d) and returns it to the UI as
?refresh=. The UI exchanges it at /api/auth/exchange (audience=usermanagement)
to renew its short access token without re-login. create_refresh_token gains an
expires_minutes override. Verified: refresh -> exchange -> /api/users/me 200.
@tekrajchhetri
tekrajchhetri merged commit 41dcffb into improve-ingestion-query-service Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant