feat(auth): org session policies — lifetime/idle limits, org-wide revocation#5862
Conversation
…ocation, cookie-cache versioning
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Backend: Auth integration: Better Auth hooks re-clamp sliding 30-day refreshes; migration 0265 adds the two org columns. Docs, audit actions, contracts, tests, and Reviewed by Cursor Bugbot for commit ba7c70d. Configure here. |
Greptile SummaryThis PR adds organization-wide session policies and member session revocation. The main changes are:
Confidence Score: 5/5The latest fixes look safe to merge.
Important Files Changed
Reviews (12): Last reviewed commit: "fix(session-policy): unify join paths on..." | Re-trigger Greptile |
…curity-policy version module, canonical bounds, docs
|
@cursor review |
…set, state tracker, response-seeded baseline, comment trims
|
@cursor review |
…oke cookie-cache hole), normalize createdAt, remount on org switch, sync audit mock
|
@cursor review |
…rmalize expiresAt, sync unified nav test
385bca2 to
7902c2d
Compare
|
@cursor review |
… spare impersonator sessions in revoke-all, raise idle floor to 2x cookie window
…bership TTL, admin-add cache invalidation
|
@cursor review |
|
@cursor review |
…op enforcing automatically
|
@cursor review |
…all sites bump transactionally
|
@cursor review |
…r; final audit polish (dead exports, response bound, test name)
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit ba7c70d. Configure here.
Summary
maxSessionHours(absolute lifetime cap) andidleTimeoutHours(min 24h — session activity is only recorded once per cookie-cache window), plus a Sign out all members actionsession.create.beforeclamps new sessions, and a newsession.update.beforehook re-clamps on every sliding refresh (Better Auth rewritesexpiresAtto now+30d on refresh, which would silently stretch shortened sessions back out)organization.securityPolicyVersioncounter wired intosession.cookieCache.version(async fn): bumping it on policy save / revoke-all invalidates every cached session cookie in the org on its next request — revocation latency drops from the 24h cookie-cache lifetime to the ~60s policy-cache TTL. This machinery is shared groundwork for the upcoming IP-allowlisting and MFA-enforcement PRsLEAST(expires_at, created_at + max, now() + idle)) so tightening applies without waiting for each session's next refreshorganization(session_policy_settingsjson,security_policy_versionint default 1)NEXT_PUBLIC_SESSION_POLICIES_ENABLEDoverride on self-hostorganization.session_policy.updated,organization.sessions.revokedRequires better-auth 1.6.23 (#5857, merged) for
cookieCache.versionand the update-hook context.Known limitation (documented in code): live Socket.IO connections authenticate once at handshake, so revoke-all doesn't disconnect already-open sockets — they die on their next HTTP interaction.
Type of Change
Testing
update.beforehook context availability against a real refreshChecklist