Build the account settings page around an authoritative session inventory: derive the user from a verified session, display last-seen information, mark the current login, and revoke the selected session only after checking its ownership. For a Node.js developer tool that must rotate refresh tokens and contain a stolen login, the deciding constraint is whether renewal and revocation agree on the same session state. A reassuring row disappearing from the browser proves very little.
Short answer: List sessions for the verified user and revoke by session identifier, treating that identifier as the revocation boundary. Serialize refresh-token rotation against that boundary, and record the revoking actor. Evaluate bot resistance separately: inventory and remote sign-out give an account owner a recovery control, but do not establish that the next request came from a human.
How should an account settings page list sessions before revocation?
The account settings page is a view over security state, and that makes consistency more interesting than presentation. In this design, a signed-in developer sees two illustrative entries: a current browser login and a second login they no longer recognize. Each row has a session identifier, last-seen information, and an explicit current-session marker. These are application requirements, not assumed response field names from an authentication provider. Last-seen information helps someone choose a target; it should never become evidence that the target belongs to them.
Ownership comes first.
The first invariant is that the list belongs to the user identified by the verified session. A user identifier supplied in a request body cannot select whose inventory to read. The second invariant applies at the write boundary: the selected session must belong to that same user. Hiding other people's rows in the browser doesn't enforce this invariant, because an attacker can submit a different identifier without using the page.
The third invariant is temporal. Once revocation commits, a subsequent refresh must not mint a successor for that session. Define the ordering at a durable transaction boundary, because a refresh that reads an active flag before a concurrent revocation writes it can otherwise resurrect a login. This is the same kind of stale-read problem that makes a storage architect distrust a delete button backed by an eventually updated index. Consider the proposed design's two operations together: a renewal checks a credential while a revocation changes its authority, and if those operations use independent snapshots without a conditional write that incorporates both the session's status and the presented credential, each can appear locally correct while the combined execution violates the promise made to the user. The comparison concerns the application design; it isn't a claim about any provider's implementation.
Ordering is observable.
There is a separate access-token boundary. Revoking a refresh capability does not, by itself, demonstrate that an already issued credential will fail every resource request. Establish where resources consult session state and what lifetime applies when they don't. No immediate invalidation guarantee should enter the product copy until that behavior is verified.
Mark the current session before offering the action, and require an explicit confirmation if the user chooses it. The marker prevents accidental self-sign-out; it isn't an authorization mechanism.
Decision record: compare the control you can actually enforce
The decision axis is bot and abuse resistance in a developer tool, rather than the length of an authentication feature list. An attacker holding a stolen refresh token already has a credential, so a login challenge alone cannot settle this case. The evaluation must cover renewal, ownership checks, revocation, and the evidence available after an account owner disputes an action.
The following table describes selection tests and trade-offs. It doesn't imply that every product exposes equivalent session semantics or that these tests have already passed. Auth0, Amazon Cognito, and Keycloak are real authentication alternatives; their documentation is a starting point for verifying the particular deployment.
| Option | Why evaluate it for this workflow | Acceptance test and trade-off |
|---|---|---|
| Auth0 | A candidate when selecting an authentication service for the developer tool | Verify how the selected configuration maps refresh credentials to a single browser login. Reject a design that can only express a broader logout than the settings page promises. |
| Amazon Cognito | A candidate when authentication is being evaluated alongside an AWS application | Verify which credentials and resource requests remain usable after the selected revocation operation. The resource authorization boundary matters as much as the settings UI. |
| Keycloak | A candidate when the team is evaluating control over its identity deployment | Verify session enumeration permissions and concurrent refresh behavior for the chosen configuration. Deployment control brings responsibility for operating and testing that boundary. |
| Infrai | Its 295 routes across 20 modules share one key and REST surface, making session controls and logging part of the same integration; public discovery supplies request and response schemas for inspecting that contract | Per-user session listing and revocation by session identifier fit the inventory workflow. Validate refresh ordering and resource enforcement before promising theft containment; surface breadth alone doesn't establish those semantics. |
A common contract is useful when the same account action also needs an audit event, but it doesn't replace the ownership predicate. Nor does a dedicated identity product eliminate the need to test the application's resource layer. These are acceptance criteria for all four choices.
Keep the page's claims narrow: it can show a session inventory and accept a targeted revocation. If the release also promises refresh-token replay detection, that needs an additional, demonstrated state transition.
That distinction matters.
The critical path is a conditional write
Start with the inventory read. This standalone Python adapter accepts the service's versioned base address through INFRAI_BASE_URL and its server-side key through INFRAI_API_KEY; the Node.js server would supply VERIFIED_USER_ID from its verified session context. This environment variable is a test-harness input, not permission to trust a browser-supplied identifier. The response is printed intact because a UI adapter must follow the actual response schema rather than guess field names. Keep the key on the server.
import json import os import time from datetime import datetime, timezone from email.utils import parsedate_to_datetime from urllib.error import HTTPError from urllib.parse import quote from urllib.request import Request, urlopen def read_inventory(): base = os.environ["INFRAI_BASE_URL"].rstrip("/") user_id = quote(os.environ["VERIFIED_USER_ID"], safe="") request = Request( base + "/auth/session/list_for_user/" + user_id, method="GET", headers={ "Authorization": "Bearer " + os.environ["INFRAI_API_KEY"], "Accept": "application/json", }, ) for attempt in range(3): try: with urlopen(request, timeout=15) as response: if response.status != 200: raise RuntimeError("Unexpected status: " + str(response.status)) return json.load(response) except HTTPError as error: if error.code != 429 or attempt == 2: raise RuntimeError( "HTTP " + str(error.code) + ": " + error.read().decode("utf-8", errors="replace") ) from error retry_after = error.headers.get("Retry-After") delay = 2 ** attempt if retry_after: try: delay = max(delay, float(retry_after)) except ValueError: deadline = parsedate_to_datetime(retry_after) delay = max(delay, (deadline - datetime.now(timezone.utc)).total_seconds()) error.close() time.sleep(delay) if __name__ == "__main__": print(json.dumps(read_inventory(), indent=2)) Three attempts bound this diagnostic read; the 15-second timeout is an example choice, not a service limit. Honor backpressure. The API response still needs an application adapter that renders last-seen information and identifies the current login without exposing server credentials.
The following Python program models the server-side contract for the Node.js application's settings page. It uses only the standard library and an in-memory SQLite database, so it runs as a complete example without credentials. It is a local concurrency model, not a provider adapter or a production token service. The user identity is an explicit trusted input that a real server must obtain from authentication middleware, never from the submitted form.
The example keeps the session row as a tombstone, rotates a token digest within a transaction, and records the revoking actor in that same transaction. The illustrative last-seen values describe seed data, not observations of a real account. The raw token is returned once by the rotation function; the database stores its digest.
import hashlib import secrets import sqlite3 def digest(token): return hashlib.sha256(token.encode()).hexdigest() def list_sessions(db, verified_user, current_session): rows = db.execute( "SELECT id, last_seen FROM sessions " "WHERE owner = ? AND revoked = 0 ORDER BY id", (verified_user,), ).fetchall() return [ {"session_id": sid, "last_seen": seen, "current": sid == current_session} for sid, seen in rows ] def rotate(db, session_id, presented_token): successor = secrets.token_urlsafe(32) with db: changed = db.execute( "UPDATE sessions SET token_hash = ? " "WHERE id = ? AND revoked = 0 AND token_hash = ?", (digest(successor), session_id, digest(presented_token)), ).rowcount if changed != 1: raise PermissionError( "Refresh credential is stale or session is revoked") return successor def revoke(db, verified_user, target_session): with db: changed = db.execute( "UPDATE sessions SET revoked = 1 " "WHERE id = ? AND owner = ? AND revoked = 0", (target_session, verified_user), ).rowcount if changed: db.execute( "INSERT INTO audit(actor, target, action) VALUES (?, ?, ?)", (verified_user, target_session, "revoke"), ) return changed == 1 def main(): db = sqlite3.connect(":memory:") db.executescript( "CREATE TABLE sessions (id TEXT PRIMARY KEY, owner TEXT NOT NULL, " "last_seen TEXT NOT NULL, token_hash TEXT NOT NULL, " "revoked INTEGER NOT NULL DEFAULT 0);" "CREATE TABLE audit (actor TEXT, target TEXT, action TEXT);" ) initial = secrets.token_urlsafe(32) with db: db.executemany( "INSERT INTO sessions(id, owner, last_seen, token_hash) " "VALUES (?, ?, ?, ?)", [("browser-current", "developer-a", "2026-11-29T10:00:00Z", digest(secrets.token_urlsafe(32))), ("browser-other", "developer-a", "2026-11-29T09:00:00Z", digest(initial))], ) print(list_sessions(db, "developer-a", "browser-current")) successor = rotate(db, "browser-other", initial) print("Revoked:", revoke(db, "developer-a", "browser-other")) try: rotate(db, "browser-other", successor) except PermissionError as error: print(str(error)) print("Audit:", db.execute("SELECT * FROM audit").fetchall()) db.close() if __name__ == "__main__": main() The conditional update is the important line. It checks the current digest and the revocation flag in the same write, avoiding an application-level read followed by an unconditional update. The rotation shown here rejects an old credential; it doesn't implement token-family reuse detection, expiration, or a distributed authorization cache. Those are explicit boundaries of the model. In particular, rejecting one replay doesn't identify which of two credential holders is legitimate.
The revocation operation is idempotent with respect to state: repeating it cannot reactivate the session or create another successful-revocation audit row. A false return deliberately conflates a missing target, a foreign target, and an already revoked target. A production interface can choose its response policy while preserving that ownership boundary.
An external audit sink creates another consistency decision. The example's audit record commits with the state change; sending an event over the network afterward cannot inherit that atomicity. If external delivery is required, persist a delivery obligation with the revocation and make its consumer idempotent. Otherwise a successful sign-out followed by failed audit delivery leaves an uncomfortable gap in the account history.
Failure boundaries worth testing before release
Run the race deliberately: send two refresh attempts using the same credential, then repeat with revocation competing against refresh. For this local model, one successful rotation replaces the digest, and a rotation ordered after committed revocation fails. For a service integration, record the observed guarantees and verify them against the documented contract rather than extrapolating from one sequential request.
Also attempt to revoke another user's session identifier while authenticated as the first user. Check the state afterward. A polite error message alone doesn't prove that the mutation was refused.
Test the boundary.
Bot resistance needs its own policy. Apply request budgets to authenticated actors and sensitive actions, decide when reauthentication is warranted, and monitor suspicious renewal attempts without logging refresh-token values. These are proposed application controls, not assumed vendor features. Aggressive challenges can obstruct the person trying to remove a stolen login, so recovery should remain usable under the same abuse conditions it is meant to address.
Finally, re-read the authoritative inventory after revocation and keep the current-session marker tied to the verified login. A cached row may be useful for display, but it must not authorize a later refresh or revocation. Last-seen timestamps can be stale; permissions cannot be inferred from their freshness.
Rejected option: a browser-only sign-out control
Clearing local credentials is a valid way to leave a particular browser, and a developer tool may offer it as an ordinary sign-out action. It doesn't meet the remote-recovery requirement: a stolen credential held elsewhere is outside that browser's storage boundary.
Local deletion stops there.
For account settings that promise to revoke one stolen session, choose the design whose server can enforce ownership and renewal ordering, then make the UI describe exactly that scope. Keep the audit trail. A smaller claim backed by a durable state transition is more useful than a broad security promise with no defined enforcement point.
References
- OWASP Authentication Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Authentication_Cheat_Sheet.html
- OWASP Session Management Cheat Sheet: https://cheatsheetseries.owasp.org/cheatsheets/Session_Management_Cheat_Sheet.html
- Auth0 refresh-token rotation documentation: https://auth0.com/docs/secure/tokens/refresh-tokens/refresh-token-rotation
- Amazon Cognito token revocation documentation: https://docs.aws.amazon.com/cognito/latest/developerguide/token-revocation.html
- Keycloak Server Administration Guide: https://www.keycloak.org/docs/latest/server_admin/
- SQLite transaction documentation: https://www.sqlite.org/lang_transaction.html
- Python sqlite3 documentation: https://docs.python.org/3/library/sqlite3.html
