Conversation
There was a problem hiding this comment.
Pull request overview
Adds configurable user-login session expiry (TTL) to the Identity Server, aligning DB session expiry and auth cookie lifetime, and enforcing session expiry when exchanging/using OAuth tokens.
Changes:
- Introduces
is.user-login.session-ttlconfig and wires it into OAuth/Account server runtime config. - Persists session
ExpiresAton login when TTL > 0 and issues cookies with matchingMax-Age. - Rejects refresh-token exchange (OAuth server) and access-token authentication (Identity Server) when the linked session is expired; adds tests and changelog entry.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/oauth/storage.go | Adds session-expiry enforcement during refresh-token loading. |
| pkg/oauth/server_test.go | Extends token-exchange tests to cover expired-session refresh behavior. |
| pkg/oauth/server.go | Configures session cookie Max-Age via shared login TTL. |
| pkg/oauth/config.go | Adds internal LoginConfig to carry session TTL from IS. |
| pkg/identityserver/identityserver.go | Wires IS user-login.session-ttl into OAuth/Account server config. |
| pkg/identityserver/entity_access.go | Rejects OAuth access tokens when the linked user session is expired/missing. |
| pkg/identityserver/config.go | Adds is.user-login.session-ttl configuration knob. |
| pkg/account/user.go | Sets UserSession.ExpiresAt at session creation when TTL > 0. |
| pkg/account/session/session.go | Adds cookie max-age support to the session helper. |
| pkg/account/server_test.go | Adds test for session ExpiresAt persistence + _session cookie Max-Age. |
| pkg/account/server.go | Configures Account session cookie Max-Age via shared login TTL. |
| CHANGELOG.md | Documents the new configurable session TTL behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "error:pkg/oauth:no_access_token": "提供されたトークンはアクセストークンではありません", | ||
| "error:pkg/oauth:no_refresh_token": "提供されたトークンは更新トークンではありません", | ||
| "error:pkg/oauth:parse": "リクエストボディの解析", | ||
| "error:pkg/oauth:session_expired": "", |
There was a problem hiding this comment.
The new error:pkg/oauth:session_expired Japanese translation is an empty string. In the Web UI locale loader, an empty string is treated as an explicit translation, so users will see a blank error message instead of falling back to the default message. Please provide a Japanese translation (e.g., consistent with error:pkg/account/session:session_expired) or remove the key so fallback behavior applies.
| "error:pkg/oauth:session_expired": "", | |
| "error:pkg/oauth:session_expired": "セッション有効期間切れ", |
nicholaspcr
left a comment
There was a problem hiding this comment.
LGTM.
Since there is no tracking issue for this PR, its probably worth having it noted in another issue (maybe the internal issue to organize deployments) to test this in staging.
Good point, I think it's best to create a tracking issue specifically for this. I will link this PR to it. |
Summary
is.user-login.session-ttl. Default0preserves the current "never expire" behavior.When set to a non-zero duration:
ExpiresAt = now + TTLMax-AgeTesting
Steps
TTN_LW_IS_USER_LOGIN_SESSION_TTL=1h(oris.user-login.session-ttl: 1hin the config)./oauth/api/auth/login. Inspect the_sessioncookie —Max-Ageshould be 3600.SELECT expires_at FROM user_sessions ORDER BY created_at DESC LIMIT 1;— should be ≈now() + 1h.session_expired.0and confirm new sessions persistexpires_at = NULLand the cookie has noMax-Age(browser-session cookie). This matches pre-PR behavior.Regressions
Max-Ageto avoid drift.Notes for Reviewers
None.
Checklist
README.mdfor the chosen target branch.lorawan-stack-docs.)CHANGELOG.md.CONTRIBUTING.md, there are no fixup commits left.