Skip to content

feat(be): let an app sign its own session out - #4245

Open
sea-snake wants to merge 1 commit into
feat/session-refresh-stampsfrom
feat/app-revoke-session
Open

feat(be): let an app sign its own session out#4245
sea-snake wants to merge 1 commit into
feat/session-refresh-stampsfrom
feat/app-revoke-session

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.1 — S14, S15). Overview: #4230.

Motivation

Signing out of an app cleared browser state and invalidated nothing already issued. This is
what a user pressing "log out" should actually trigger.

Changes

app_revoke_session : () -> (). It removes the session record, so the app's access ends
within one delegation lifetime instead of running to the original expiry.

  • No authorization check beyond the match refresh already performs, because a caller
    cannot produce another session's principal, so it can only ever remove its own.
  • Returns nothing and always succeeds, which makes sign-out idempotent: a client that
    retries, or that signs out twice, gets the same answer without having to reason about
    whether its session was already gone.
  • It matches without the expiry check, so signing out of an already-expired session still
    clears the record.

The app deliberately cannot revoke anything else. "Sign out everywhere" is the II
frontend's operation (#4246), not something a dapp can trigger.

Revocation latency is exactly the app-delegation TTL, by construction: revoking stops new
mints, and one already issued runs out. mcp.rs documents the same residue for its grants.

Tests

New session_removal_tests (3): removing one session leaves the others, removing twice
reports nothing removed, and removing the last session keeps the account reference.

PocketIC (3): a refresh that worked before sign-out returns NoMatchingSession after,
signing out three times in a row succeeds every time, and signing one browser out leaves
another browser's session on the same account working.

All 765 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:27
@zeropath-ai

zeropath-ai Bot commented Aug 19, 2026

Copy link
Copy Markdown

No security or compliance issues detected. Reviewed everything up to 52b32db.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► src/canister_tests/src/api/internet_identity/api_v2.rs
    Add app_revoke_session function and update wiring
► src/frontend/src/lib/generated/internet_identity_idl.js
    Add app_revoke_session здFunction descriptor
► src/frontend/src/lib/generated/internet_identity_types.d.ts
    Declare app_revoke_session method in _SERVICE
Enhancement ► src/internet_identity/internet_identity.did
    Extend service interface with app_revoke_session
► src/internet_identity/src/main.rs
    Expose app_revoke_session update call
► src/internet_identity/src/sessions.rs
    Implement app_revoke_session logic to revoke caller's session
Enhancement ► src/internet_identity/src/storage.rs
    Add remove_session functionality and adjust session count management for revocation
► src/internet_identity/src/storage/tests.rs
    Add tests for session removal scenarios
Enhancement ► src/internet_identity/tests/integration/sessions.rs
    Add integration tests for app_revoke_session behavior

Copilot AI lite review requested due to automatic review settings August 19, 2026 01:48
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 0c075d2 to 9ce7a2c 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/app-revoke-session branch from 9ce7a2c to 354343e Compare August 19, 2026 02:57
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 354343e to a650a94 Compare August 19, 2026 03:47
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from a650a94 to 2b70415 Compare August 19, 2026 06:28
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 2b70415 to 678bf30 Compare August 19, 2026 07:07
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 678bf30 to 783da5a Compare August 19, 2026 08:17
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 783da5a to 69ab376 Compare August 19, 2026 08:37
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 69ab376 to 4919341 Compare August 19, 2026 10:21
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 4919341 to 1b98bba Compare August 20, 2026 10:57
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 1b98bba to b943144 Compare August 20, 2026 13:08
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from b943144 to 418c0f2 Compare August 20, 2026 13:52
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 418c0f2 to 6aea53c Compare August 20, 2026 15:24
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 6aea53c to 74e2eb4 Compare August 20, 2026 16:10
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch 2 times, most recently from 60d1855 to 6b7e6f3 Compare August 21, 2026 08:54
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 6b7e6f3 to 81e4d21 Compare August 21, 2026 10:38
Signing out of an app cleared browser state and invalidated nothing. Now it
removes the session record, so the app's access ends within one delegation
lifetime instead of running to the delegation's original expiry.

The method needs no authorization check beyond the match refresh already
performs: a caller cannot produce another session's principal, so it can only
ever remove its own. It returns nothing and always succeeds, so a client that
retries, or that signs out twice, does not have to reason about whether its
session was already gone. Revoking anything else is the II frontend's operation,
not something a dapp can trigger.

Implements docs/ongoing/revocable-app-sessions.md §8.1 (S14, S15).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sea-snake
sea-snake force-pushed the feat/app-revoke-session branch from 81e4d21 to 52b32db 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