Repository navigation
Conversation
An OAuth share persisted its client but retired grants and minted a fresh random session subject on every start, forcing reauthorization for an ordinary restart. Add an explicit --oauth-persist-on-restart opt-in that keeps the validated client and its unexpired, unrevoked grants via a session subject derived from the persisted client id. Expiry, revocation, scope and replay rules are unchanged and the default behaviour is identical.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
webcodex share --auth oauthpersists its OAuth client ID/secret, but every start retires the previous run's grants and mints a fresh random session subject. An ordinary restart of the same share therefore forces the MCP client to reauthorize even when the persisted client, the grant audience and the grant lifetime are unchanged. Operators restart a share for many ordinary reasons (configuration, binary upgrade, host reboot), and every restart breaks an otherwise valid connection.Change
An explicit, opt-in restart policy for OAuth shares:
--oauth-persist-on-restart(requires--auth oauth) keeps the validated persisted OAuth client and its unexpired, unrevoked grants across ordinary restarts of the same share.Default behavior without the flag is byte-for-byte the current behavior: persist the client, retire the previous run's grants, mint a new random session subject.
Compatibility
Validation
In-process regressions (Linux x86_64, Rust 1.99.1):
project_share_restart_preserves_client_and_only_retires_default_mode_grantscovers, against a real isolated SQLite store: client id/secret continuity across repeated persisting restarts, stable derived session subject, retained access and refresh grants, a revoked grant staying unusable after a persisting restart, and the default mode still retiring retained grants.Real-process loopback E2E (
scripts/e2e_share_oauth_restart.py): a realwebcodex shareprocess (real Server + WebSocket Runner, loopback, temporary state dir, real OAuth authorization-code + PKCE S256 with the share's own client) is authorized, stopped, restarted with the flag (client identity, access token and refresh rotation verified), then restarted without the flag to prove the default mode still invalidates the pre-restart grants.The harness starts a real share, completes PKCE S256, checks an authorized MCP
tools/list, stops only its own process group, restarts with the flag (same client id/secret, retained access token accepted, refresh rotation accepted, rotated token accepted), then restarts without the flag and requires401for the pre-restart access token and a refused refresh. Temporary state is removed after a passing run.Not run here: Windows and macOS lanes (no environment available; the harness is POSIX-only like the existing share E2E). No deployment, service restart or production state is involved.
Design questions