fix(idp): invalidate other sessions on password reset and change#1297
fix(idp): invalidate other sessions on password reset and change#1297laskevych wants to merge 1 commit into
Conversation
| // Revoke the OWOX platform refresh token carried by this request (if | ||
| // any) so the acting device's platform session is invalidated at the | ||
| // OWOX Identity level, not only the Better Auth UI session. | ||
| await this.revokePlatformSession?.(req, res); |
There was a problem hiding this comment.
🔴 Blocking: This reset flow still leaves the user’s other Better Auth sessions valid. better-auth@1.6.13 only deletes sessions during resetPassword when emailAndPassword.revokeSessionsOnPasswordReset is enabled; the OWOX config does not set it, and the new callback only revokes or clears the current request platform cookie. A reset from a logged-out browser or while another Better Auth session exists will keep that other session usable. Please enable Better Auth reset-session revocation or explicitly delete the user’s Better Auth sessions before redirecting.
🤖 Reviewed by Codex (GPT-5.5)
| enabled: true, | ||
| requireEmailVerification: false, | ||
| }, | ||
| hooks: { |
There was a problem hiding this comment.
🔴 Blocking: This hook only covers @owox/idp-better-auth. @owox/idp-owox-better-auth has a separate createBetterAuthConfig, and BetterAuthProxyHandler forwards every /auth/better-auth/* route there, so /auth/better-auth/change-password can still omit revokeOtherSessions and keep other sessions alive. Please add the same hook to the OWOX Better Auth config or centralize this config behavior.
🤖 Reviewed by Codex (GPT-5.5)
| * session. Revocation failures are non-fatal (logged, not thrown) so they | ||
| * never block completing the password flow. | ||
| * | ||
| * Scope note: this only revokes the token present in the request (the acting |
There was a problem hiding this comment.
🔴 Blocking: This scope note means password reset still does not invalidate other active OWOX platform sessions. Only the refresh token on the current request is revoked; another device refreshToken can still refresh through accessTokenMiddleware. Since this PR is meant to invalidate other sessions on reset, it needs a revoke-by-user or session-family path or another mechanism that prevents old platform refresh tokens from continuing after reset.
🤖 Reviewed by Codex (GPT-5.5)
Why
A security assessment found that some password reset/change paths left a user's
other active sessions valid. After a successful password reset or change, every
other session for that user should be invalidated (the session performing the
change may remain valid). Scope:
idp-better-authandidp-owox-better-auth.First-time password setup is out of scope.
What changed
idp-better-auth— complete fixHere a "session" is a Better Auth session: the
refreshTokencookie is theBetter Auth session token, and access tokens are short-lived (≈1h), so deleting
session rows immediately cuts off other devices' refresh ability.
/change-password— ahooks.beforemiddleware sets
revokeOtherSessions: true, so a password change alwaysrevokes the user's other sessions while Better Auth issues a fresh session for
the current one (clients can no longer skip it by omitting the flag).
resetUserPassword(userId, adminUserId, currentSessionToken?):revokeOtherUserSessions(userId, exceptSessionToken)(
DELETE FROM session WHERE userId = ? AND token != ?) on the SQLite andMySQL stores + interface.
idp-owox-better-auth— partial, platform-levelHere a real session is an OWOX Identity token (issued by an external service,
30-day refresh), not a Better Auth session — so deleting Better Auth rows alone
does not cut platform access.
carried by the request (
extractRefreshToken → revokeToken, best-effort,non-fatal) and clear its cookie, via a callback injected into
PasswordFlowController.Tests
idp-better-auth: integration tests on a real Better Auth + in-memory SQLiteinstance assert surviving
sessionrows for change-password; unit tests coverall
resetUserPasswordbranches and the new revoke SQL.idp-owox-better-auth: controller tests assert the platform token is revokedon successful reset and NOT revoked when the reset fails.
Not in scope
idp-owox(blocked on the OWOX Identitybackend endpoint above).
🤖 Generated with Claude Code