Skip to content

feat(be): revoke sessions from the user's own settings - #4246

Open
sea-snake wants to merge 4 commits into
feat/app-revoke-sessionfrom
feat/revoke-sessions-from-settings
Open

feat(be): revoke sessions from the user's own settings#4246
sea-snake wants to merge 4 commits into
feat/app-revoke-sessionfrom
feat/revoke-sessions-from-settings

Conversation

@sea-snake

@sea-snake sea-snake commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Design: #4224. Overview: #4230. An app can sign out only its own session (#4245), so "sign this browser out" has to come from somewhere the anchor itself is authenticated. The two revocation surfaces are split by what each caller can prove:

Caller Authenticated as May revoke Names a session by
The app its own session chain only its own nothing; caller() is looked up in the session index
The II frontend an anchor access method any session of that anchor (origin, account, created_at), or a whole device_id
  • revoke_account_session takes (identity_number, origin, account_number, created_at). Two browsers signing in during the same round share a created_at, so it can match more than one; revoking both is the right outcome, since the user named that moment at that account.
  • revoke_device_sessions takes (identity_number, device_id) and sweeps that anchor's references in one message, writing only rows that hold that device's sessions. Atomic, with no partially-revoked state.
  • Both name sessions by locator, never by principal, so they do not touch the principal index; that stays on the app-facing path only.
  • Sweeping eagerly is what keeps refresh cheap. Marking a device revoked and checking it during refresh would make revocation O(1) but add an anchor read to a call that otherwise never touches the anchor, and refresh happens every few minutes per active session.
  • The device record survives the sweep, so a browser that has been signed out is still one the user recognises, and signing back in from it reuses the same id. Deleting a device record is a separate operation, not specified here.

There is no session listing method, deliberately. A flat "every session of this anchor" call returns a list bounded only by the caps and mixes every origin together. The right decomposition is applications first, then sessions within one, and that wants designing alongside whatever lists applications. Neither exists yet.

Tests: session_revocation_tests (5), including revoking by creation time covering same-round siblings. PocketIC covers revocation by another anchor being Unauthorized, and a whole browser signed out across two apps while a second browser keeps working and the device record stays listed.

@sea-snake
sea-snake requested a review from a team as a code owner August 19, 2026 01:28
@zeropath-ai

zeropath-ai Bot commented Aug 19, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 77fad44.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► src/canister_tests/src/api/internet_identity/api_v2.rs
    Add revoke_account_session and revoke_device_sessions functions
► src/frontend/src/lib/generated/internet_identity_idl.js
    Extend IDL with RevokeAccountSessionRequest, SessionRevokeError, RevokeDeviceSessionsRequest and corresponding functions
► src/frontend/src/lib/generated/internet_identity_types.d.ts
    Add RevokeAccountSessionRequest, RevokeDeviceSessionsRequest, SessionRevokeError types and update _SERVICE with revoke_account_session and revoke_device_sessions
► src/internet_identity/internet_identity.did
    Define RevokeAccountSessionRequest, RevokeDeviceSessionsRequest, and SessionRevokeError in DID
► src/internet_identity/src/main.rs
    Expose revoke_account_session and revoke_device_sessions update calls
► src/internet_identity/src/sessions.rs
    Implement revoke_account_session and revoke_device_sessions in session logic
► src/internet_identity/src/storage.rs
    Add revoke_account_sessions to remove sessions by locator/origin and creation time
► src/internet_identity/src/storage/tests.rs
    Add session_revocation_tests module to validate revocation behavior
► src/internet_identity/tests/integration/sessions.rs
    Add integration tests for revoke_account_session and revoke_device_sessions
► src/internet_identity_interface/src/internet_identity/types.rs
    Add RevokeAccountSessionRequest, RevokeDeviceSessionsRequest, and SessionRevokeError types in interface

Copilot AI lite review requested due to automatic review settings August 19, 2026 01:48
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 18fb88b to 34717f6 Compare August 19, 2026 01:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 34717f6 to b8a64f9 Compare August 19, 2026 02:57
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from b8a64f9 to 90f092f Compare August 19, 2026 03:47
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 90f092f to 2fba0ef Compare August 19, 2026 06:28
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 2fba0ef to dcb3703 Compare August 19, 2026 07:07
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from dcb3703 to d6d8557 Compare August 19, 2026 08:17
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from d6d8557 to c78ef1a Compare August 19, 2026 08:37
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from c78ef1a to 616f549 Compare August 19, 2026 10:21
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 616f549 to 1e76b12 Compare August 20, 2026 10:57
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 1e76b12 to 27cf6f4 Compare August 20, 2026 13:08
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 27cf6f4 to 1205a12 Compare August 20, 2026 13:52
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 1205a12 to 1389f4b Compare August 20, 2026 15:24
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 451b36d to e7f2393 Compare August 21, 2026 08:54
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from e7f2393 to 0cce254 Compare August 21, 2026 10:38
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 0cce254 to 154bb92 Compare August 21, 2026 17:06
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 154bb92 to 613299e Compare August 22, 2026 10:49
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch 2 times, most recently from 5516927 to d3100d3 Compare August 22, 2026 12:52
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from d3100d3 to c2bf0ea Compare August 22, 2026 17:24
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from c2bf0ea to 9a4941c Compare August 22, 2026 17:48
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 9a4941c to d2b3363 Compare August 22, 2026 18:08
@sea-snake sea-snake added the feature:revocable-app-sessions Design: revocable app sessions label Aug 22, 2026
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from d2b3363 to 32d8fb3 Compare August 22, 2026 18:44
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 32d8fb3 to 0664248 Compare August 22, 2026 19:06
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 0664248 to 9d9399d Compare August 22, 2026 19:25
The app can sign out only its own session, so "sign this browser out" has to come
from somewhere the anchor is authenticated. These two are authenticated by an
anchor access method rather than by a session chain, and name sessions by locator
rather than by principal, so the principal index stays on the app-facing path.

Signing a browser out is an eager sweep of that anchor's references in one
message, so refresh never has to read the anchor to find out whether its device
was revoked: refresh happens every few minutes per active session, this happens
rarely. The device record survives the sweep, so a browser that has been signed
out is still one the user recognises and signing back in from it reuses the same
id.

Implements docs/ongoing/revocable-app-sessions.md §8.2, §9.3 (S16, S20).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from 9d9399d to e4f3678 Compare August 22, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature:revocable-app-sessions Design: revocable app sessions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants