Skip to content

fix(users): sign out other sessions when a passkey is removed - #638

Open
Bccorb wants to merge 2 commits into
mainfrom
fix/credential-delete-ends-sessions
Open

Bccorb wants to merge 2 commits into
mainfrom
fix/credential-delete-ends-sessions

Conversation

@Bccorb

@Bccorb Bccorb commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

Part of #600 (L-API-1).

DELETE /users/credentials already requires a fresh step-up (#620). This adds the other half of L-API-1: removing a passkey now signs out every other session on the account.

What changes

  • New revokeOtherSessions in src/services/sessionRevocation.ts revokes the user's chain-head sessions, except the head of the caller's own sign-in. Exchanged sessions end with their parent, as they already do.
  • The caller's sign-in is followed to its current head: through the parent an exchanged session was minted from, then forward through rotations. A caller on an exchanged session, or one refreshing during the delete, is not signed out.
  • A rotation inserts its replacement before it claims the row it replaces. So the update runs at least two passes, and keeps going while a pass still finds something (at most five). A replacement that one pass's snapshot missed is caught by the next.
  • The revoke runs before the credential is destroyed. If it fails, the passkey stays and a retry can remove it.
  • Revoked rows carry the reason credential_deleted. The credentials_deleted audit event records revokedSessions.

Contract

No route, schema or status code changes. Only the route's OpenAPI description changes, and openapi.json and src/generated/api.ts are regenerated. Access tokens that an adapter verifies locally stay valid until they expire, as they do for any revoke.

Tests

  • Unit: the pass bounds, the exclusion of the caller's head (including an exchanged caller), and the passkey being kept when the revoke fails.
  • Postgres (tests/postgres/sessionRevocation.spec.ts): other heads are revoked and the caller's chain and other users are kept, a racing rotation cannot claim its session, and an exchanged caller keeps its parent's rotated head.

Removing a passkey left every session signed in from that device valid until
it expired. DELETE /users/credentials now revokes the account's other sessions
and keeps the one that made the request, which has just passed a step-up.
…passkey

Follows the caller to the current head of its sign-in, including the parent an
exchanged session came from, runs at least two passes so a replacement a
racing rotation inserted is caught, and revokes before the delete so a failure
leaves the passkey in place for a retry.
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