Skip to content

Report when the saved login ends; keep 403 apart from sign-in failures (0.3.15) - #27

Open
MainSequenceDev wants to merge 1 commit into
mainfrom
claude/session-end
Open

MainSequenceDev wants to merge 1 commit into
mainfrom
claude/session-end

Conversation

@MainSequenceDev

Copy link
Copy Markdown
Contributor

Why

MainSequence CLI/desktop logins end a fixed time after sign-in (CLI_LOGIN_SESSION_LIFETIME_SECONDS, five days by default; ADR-0006 in tdag-django). The backend does not rotate refresh tokens, so the refresh token's exp is when the login ends. devtools' offline status ignored that claim, so the Claude, Codex and VS Code hosts, and the CLI, all showed the user as signed in until a request failed. devtools also treated a 403 like a dead login: it renewed, retried, then said "Sign in again" for what was really a missing permission.

What changes

  • status() reads the refresh token's expiry. It returns sessionEndsAt. Once that time has passed, it returns authenticated: false without contacting the backend.
  • Ended session: a checked status, every request and refresh-token answer "The saved session for … ended on … UTC. Sign in again." and send nothing. The saved session is kept, so the next sign-in replaces it.
  • auth-status summary names the end: "usable until …" or "ended on … Sign in again."
  • 403 is FORBIDDEN, a new error code, for the platform API and for project MCP endpoints. It triggers no renewal, no retry and no sign-in prompt. 401 stays AUTH_REJECTED. The backend answers 401 for every expired, revoked or unknown login, and so does the MCP gateway (mcp_gateway/authentication/asgi.py).
  • The README describes this.

Verification

  • npm run release:check passes: 186 tests, docs check, pack and package verification.
  • New tests:
    • An ended session: no request is sent and the session is kept.
    • A live session reports when it ends.
    • A revoked session is refused by the backend and says so.
    • The 403 split.
  • The existing MCP test where a 403 stood for withdrawn access now expects FORBIDDEN.
  • Live run on the owner's machine against http://local-backend:8000: auth-status reports sessionEndsAt: 2026-11-06T12:30:58Z, the same expiry measured on the refresh token, both offline and with --check.

Hosts

Claude Desktop 0.4.25 (mainsequence-claude-desktop, branch claude/expired-login-visible) builds on this. It warns a day ahead, shows the session as signed out at the end, and raises one notice across sessions. The Codex plugin and VS Code extension already treat only AUTH_REJECTED and NOT_AUTHENTICATED as sign-in failures, so a 403 stops asking them to sign in as soon as they take this version.

🤖 Generated with Claude Code

…s (0.3.15)

The backend ends a CLI/desktop login a fixed time after sign-in (five days by default,
ADR-0006 in tdag-django) and does not rotate refresh tokens, so the refresh token's `exp`
is the login's end. Until now the offline status ignored it: every host showed the user
signed in until a request failed.

- `status()` reads the refresh token's expiry: it returns `sessionEndsAt` and, once that
  has passed, `authenticated: false` without contacting the backend. A checked status,
  every request and `refresh-token` answer "The saved session for … ended on … UTC.
  Sign in again." and send nothing. An access token still inside its five minutes does
  not outlive the login it belongs to.
- `auth-status` names the end in its summary ("usable until …", "ended on … Sign in
  again.").
- HTTP 403 is `FORBIDDEN` (a new error code), for the platform API and project MCP
  endpoints: no renewal, no retry and no sign-in prompt. 401 stays `AUTH_REJECTED`; the
  backend answers 401 for every expired, revoked or unknown login, including the MCP
  gateway.

Tests cover the ended session (no request sent, session kept), the live session's end
date, a revoked session refused by the backend, and the 403 split.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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