Skip to content

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

Open
sea-snake wants to merge 1 commit 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 1 commit 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 (docs/ongoing/revocable-app-sessions.md §8.2, §9.3 — S16, S20). Overview: #4230.

Ships with #4249, which is the UI for it.

Motivation

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; the bundle rides as caller info
The II frontend an anchor access method any session of that anchor (origin, account, created_at), or a whole device_id

Changes

  • 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 — 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.
  • Doing the sweep 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. 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. Deleting a device
    record is a separate operation and is 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 mixing 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

New session_revocation_tests (5): signing a browser out sweeps every application, leaves
another anchor alone, writes nothing when there is nothing to revoke, revoking by creation
time covers same-round siblings, and revoking at an unknown origin is a no-op.

PocketIC (3): revoking one session from settings stops its refresh, revocation by another
anchor is Unauthorized, and signing a whole browser out kills its sessions across two
apps while leaving a second browser working and leaving the device record listed.

All 770 canister unit tests pass, plus the sessions suite.

@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 154bb92.

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 endpoints in test API calls
► src/frontend/src/lib/generated/internet_identity_idl.js
    Add RevokeAccountSessionRequest, SessionRevokeError, RevokeDeviceSessionsRequest types and methods
► src/frontend/src/lib/generated/internet_identity_types.d.ts
    Add RevokeAccountSessionRequest, RevokeDeviceSessionsRequest, SessionRevokeError types
► src/internet_identity/internet_identity.did
    Declare RevokeAccountSessionRequest, RevokeDeviceSessionsRequest, SessionRevokeError in DID interface
► 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 functions
► src/internet_identity/src/storage.rs
    Add revoke_account_sessions method to storage layer and integrate removal logic
► src/internet_identity/src/storage/tests.rs
    Add session revocation tests
► src/internet_identity/tests/integration/sessions.rs
    Update integration tests to include revoke_account_session and revoke_device_sessions usage
► src/internet_identity_interface/src/internet_identity/types.rs
    Add RevokeAccountSessionRequest, RevokeDeviceSessionsRequest, SessionRevokeError definitions

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 1389f4b to a55a18f Compare August 20, 2026 16:10
@sea-snake
sea-snake force-pushed the feat/revoke-sessions-from-settings branch from a55a18f to 451b36d Compare August 20, 2026 17: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
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 0cce254 to 154bb92 Compare August 21, 2026 17:06
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.

2 participants