Repository navigation
[3512 by Claude Opus 5.5] OAuth sign-in for MCP servers: connect from Settings in the browser, tokens held and refreshed by Core - #3536
Conversation
…ed contract through Core, the API, Settings and the docs. The new and related tests pass. I didn't run the full repository suite, and nothing has been tried against a real OAuth provider: all OAuth tests use a synthetic authorization server and MCP server. What it does - Contract: an `https` server can use `authentication: 'oauth'`, with optional `scopes`, a `clientId` and a write-only client secret. The secret is stored like a Bearer token, and changing the URL, authentication type or client id never carries it over. - Discovery: ProPR reads the server's `401` challenge, falling back to the well-known location, then the authorization server's metadata, and requires PKCE `S256`. Every discovery, registration, token and revocation request goes through the existing endpoint policy, so private and loopback addresses are refused. - Sign-in: authorization code with PKCE and the `resource` parameter. The `state` is single-use, expires after 10 minutes and is bound to the session, the administrator, the item and its endpoint. The callback checks `iss` and stores nothing unless the code exchange succeeds. The redirect URI and the public client metadata URL come from the same public base URL ProPR's own MCP server uses; without one, Connect is disabled with an explanation. - Token custody: tokens are sealed in a new `extension_oauth_connections` table, with pending sign-ins and an audit trail in their own tables. Connecting, refreshing and disconnecting create no library revision. Native exports erase connections and pending sign-ins and keep the audit trail. - Refresh: tokens are refreshed a minute before they expire and after an upstream `401`. Refresh is single-flight within a process and across processes, and a rotated refresh token is saved together with the new access token. A refused refresh moves the item to Needs sign-in once and sends one notification; network errors are retried and change nothing. - Gateway and launch: the gateway asks Core for the current token on every call, refreshes and retries once on `401`, and redacts the token from output. Unconnected or Needs-sign-in servers are skipped with the reason `oauth_not_connected` or `oauth_needs_sign_in`, and the run continues. Changing the URL, authentication or client id, or renaming or removing the server, discards the connection; disabling it keeps the connection. - API: check, start, callback, disconnect and audit routes, plus the public client metadata document. The OpenAPI spec and client types are regenerated. - Settings: the server form adds OAuth sign-in with scopes, client id and secret, the redirect URI, the shared-identity warning and Check. Server rows show the connection state, who connected and when, the granted scopes, and Connect, Reconnect and Disconnect. Connect opens the provider in a new tab, and the row refreshes when you come back to Settings. - Docs: `agent-extensions.md` has a new "OAuth servers" section covering everything the issue asked for. Two choices that differ from the issue's wording - Registration order: if an administrator enters a client id, ProPR uses that pre-registered client even when the server also supports a metadata document or dynamic registration. Otherwise it tries the metadata document, then dynamic registration. Ignoring a client id someone typed in seemed wrong; the Check result and the docs both say which method will be used. - Notification category: the Needs-sign-in notification uses the existing `system_failure` kind with component `extensions.oauth`. A new kind would need schema changes, because the allowed kinds are fixed in the notification tables. I checked that the event passes the notification validator. Tests - Core: 8 tests cover every backend acceptance criterion except API admin-only access and the callback's session binding, which the API route test covers. The sentinel test also captures logger calls, and the existing export test now includes OAuth data. The existing extension suites pass, 131 tests in total. - API: one route test covers administrator-only access, the session-bound callback, the public metadata document, token-free responses and the case with no public base URL. - UI: 7 new component tests cover the three states and the actions, and all 286 Settings and extension UI tests pass. - Playwright: a new spec drives Connect through the synthetic provider page and the callback; it and the existing extension spec pass (8 tests). - Checks: typecheck and zero-warning lint pass on the touched packages, and the OpenAPI up-to-date check passes. - Two root tests (`test/claudeExtensionEnvironment.test.ts` and `test/extensionLaunchIntegration.test.ts`) failed when run together with others because they share one test database file. Each passes when run on its own database. Screenshots of the connected server row and the OAuth server form are attached as previews.
|
/ultrafix goal=8 max=10 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThis PR implements OAuth discovery, sign-in, token custody, refresh, gateway integration, Settings controls and documentation. It needs significant rework around concurrent credential lifecycle operations before merge. ✅ Credential isolation — Tokens and PKCE verifiers are sealed with identity bindings, and native exports explicitly erase connections and pending sign-ins. ✅ Session-bound sign-in — Callback handling checks single-use state, expiry, administrator identity, browser session and issuer before exchanging the code. ✅ Gateway integration — Each OAuth call obtains a current token, retries once after an upstream 401, and redacts the tokens used. This is a static review of the supplied code; no commands or tests were run. The authoritative checks show no failures and two pending checks. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 In-flight callbacks can undo Disconnect
F2: 🔴 Old refreshes can overwrite new connections
F3: 🔴 Refresh retries can disclose replacement secrets
F4: 🔴 Refresh lease expires during supported retries
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Exercise the real browser callbackThe Playwright test intercepts both the start endpoint and callback, while the API test supplies session identity through test headers. A browser integration test using the actual session middleware and callback would strengthen confidence in cookie and route composition. This is additional coverage, separate from the demonstrated lifecycle defects. ScoreThe implementation covers the feature broadly and includes useful tests, but credential disclosure and concurrent lifecycle failures prevent merging. Passing checks do not cover these demonstrated interleavings. Score: 5/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 7b0bb08
Summary of ChangesI've fixed F1–F4 in Core's OAuth store and added a regression test for each. All 12 tests in F1 – A sign-in still in progress can no longer undo Disconnect
F2 – An old refresh can no longer overwrite a new connection
F3 – A retry can no longer send a replacement secret to the old server
F4 – The refresh lease now lasts through every retry
Schema: the PR's own migration, New tests (in
Other results:
Not tested: the revocation side of F3, meaning a mismatched connection reaching Disconnect. It uses the same check as refresh. I couldn't set it up without forcing an inconsistent database row. Nothing visible changed, so there are no previews. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…on test for each. All 12 tests in `packages/core/test/extensionOAuth.test.ts` pass, and the 4 new ones all fail when run against the original code. Typecheck and zero-warning lint pass on Core. I didn't run the full repository suite. Nothing here has been tried against a real OAuth provider, only the synthetic one. I've fixed F1–F4 in Core's OAuth store and added a regression test for each. All 12 tests in `packages/core/test/extensionOAuth.test.ts` pass, and the 4 new ones all fail when run against the original code. Typecheck and zero-warning lint pass on Core. I didn't run the full repository suite. Nothing here has been tried against a real OAuth provider, only the synthetic one. **F1 – A sign-in still in progress can no longer undo Disconnect** - The callback no longer deletes its pending row when it starts. It marks the row as claimed and keeps it until it finishes, so the row now stands for that sign-in attempt. - Disconnect and library saves that change or remove the server delete that row, which cancels the attempt. - The final transaction first deletes the claimed row and refuses with "The sign-in was cancelled; connect again" if it is already gone. It then reads the current library inside the same transaction and checks the server's URL, authentication and client id again before storing anything. - Library saves now also cancel pending sign-ins when only the client id changes; before, they only reacted to URL and authentication changes. Disconnect now cancels pending rows before deleting the connection. - Expiry cleanup leaves a claimed row alone for one extra minute, so cleanup can't cancel an exchange that is still running. **F2 – An old refresh can no longer overwrite a new connection** - Every sign-in gives the connection a new random `generation`. Refresh writes, the Needs-sign-in change, lease release and the in-process single-flight key all include it. - A refresh result for a replaced connection is thrown away with a new error type. The gateway also no longer falls back to the old connection's token after a network error once the connection has been replaced. **F3 – A retry can no longer send a replacement secret to the old server** - Refresh and revocation now get the client only if the current server still matches the connection's URL, authentication and client id. Otherwise they stop before sending anything. - Before each retry, the refresh also renews its lease, and that renewal only succeeds if the connection is still the same one. A connection discarded during the retry delay therefore never gets the retry. **F4 – The refresh lease now lasts through every retry** - Each lease has its own owner id. Completion, the Needs-sign-in change and release only apply to the owner's lease. - The lease is renewed to 30 seconds before every token request. - The HTTPS transport now counts DNS lookup within its 10-second limit and won't send a request once that limit has passed. So no single request can outlast a renewed lease. **Schema:** the PR's own migration, `20261113120000_extension_oauth.js`, gains `generation` and `refresh_lease_owner` on connections and `claim` on pending sign-ins. I edited it in place because it hasn't been released. A database that already ran the earlier version of this migration won't get the new columns. **New tests** (in `packages/core/test/extensionOAuth.test.ts`): - Disconnect, a URL change, removing the server and a client id change during the code exchange each cancel the sign-in and leave nothing stored. - An old refresh neither overwrites a new connection that restarted at version 1 nor holds up that connection's own refresh. - For both a client id change and a URL change during a transient failure, the replacement secret is never sent. - The finding's timing (two slow failures, then a rotating response that arrives late) runs against a second copy of the module standing in for another process. The second process waits and uses the first one's result, without a second token exchange or a Needs-sign-in change. **Other results:** - The API route test for OAuth passes. - In `extensionProfiles.test.ts`, the test "catalog stdio is callable through both selected authorized launcher policies…" fails, and it fails the same way on the original code. - All tests in `extensionTaskAutoApply.test.ts` pass, but the process never exits; I stopped it with a time limit. - Both suites need `PROPR_DEMO_MODE=true` to run here. **Not tested:** the revocation side of F3, meaning a mismatched connection reaching Disconnect. It uses the same check as refresh. I couldn't set it up without forcing an inconsistent database row. Nothing visible changed, so there are no previews. PR: #3536 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
|
/review |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThis PR adds OAuth discovery, sign-in, encrypted token custody, refresh, API routes and Settings controls. The implementation is substantial, but needs changes before merge because proactive refresh can immediately invalidate a usable connection that has no refresh token. ✅ Session-bound sign-in — Pending authorization binds the state to the administrator, session and server configuration; completion rechecks authorization and configuration before committing. ✅ Refresh fencing — Connection generations, versions and lease owners prevent an outstanding refresh from overwriting a replacement connection. ✅ Export custody — Native exports explicitly delete OAuth connections and pending sign-ins while preserving audit records. This review uses static tracing of the supplied code; no commands or tests were run. The authoritative checks report 28 passed, five pending and no failures. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F5: 🔴 Keep valid tokens without refresh tokens
SuggestionsThese are optional follow-ups and are not sent to S2: 🟢 Exercise the real browser boundaryThe Playwright test mocks the start route, provider and callback, while the API test injects session identity directly. A follow-up integration test using the real session middleware and callback would validate cookie delivery and session continuity across browser navigation. This would strengthen coverage beyond the existing component and protocol tests; no additional session defect is established by the supplied code. ScoreThe implementation has strong credential custody and concurrency protections, but a supported token-response shape can produce an unusable connection immediately after successful sign-in. The remaining checks are pending, with no reported current-head failures. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements OAuth across credential storage, discovery, gateway calls, Settings, and documentation. It needs changes before merge: token expiry handling and disconnect coordination leave two reachable correctness defects. ✅ Credential custody — Tokens and PKCE verifiers are sealed; native exports explicitly erase connections and pending sign-ins. ✅ Callback binding — Single-use state checks bind completion to the initiating administrator, session, server endpoint, and client. ✅ Refresh fencing — Generation, version, and lease-owner checks prevent an old refresh result from overwriting a replacement connection. This review used static tracing only; no commands were run. The supplied current checks show 34 passed, none failed, and one pending. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F6: 🔴 Keep unrefreshable tokens usable until expiry
F7: 🔴 Coordinate disconnect with token rotation
SuggestionsThese are optional follow-ups and are not sent to S3: 🟢 Exercise the actual browser sessionThe Playwright test mocks both the start endpoint and callback, while the API test injects session identity through headers. A browser integration test using the actual session middleware would strengthen confidence in cookie-bound callbacks. This is additional coverage, not a demonstrated authentication defect. ScoreThe implementation has substantial security controls and broad passing coverage, but the two credential lifecycle defects require correction before merge. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 6c9e796
Summary of ChangesI've fixed F5, F6 and F7 in Core's OAuth store ( F5 / F6 (tokens without a refresh token): when a connection has no refresh token, F7 (disconnect during token rotation):
Two tests cover this:
Existing test I changed: "a refresh of a replaced connection…" used Disconnect to replace a connection while a refresh was still outstanding. With F7, Disconnect now waits for that refresh, so the test would hang. It now replaces the connection through a library change, which still exercises the successor fencing it was written for. Problems I found but didn't fix (outside the selected findings):
This change has no visible effect in the UI, so I didn't create previews. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…ore/src/extensions/extensionOAuthStore.ts`) and added a regression test for each. The 3 new tests fail against the previous code and pass now. All 15 tests in `packages/core/test/extensionOAuth.test.ts` pass. So do 198 tests across the Core extension suites, the database export test and the API OAuth route test, which I ran with `PROPR_DEMO_MODE=true` because without it two suites fail on the GitHub-auth check. Core typecheck and zero-warning lint pass. I didn't run the full repository suite, and nothing has been tried against a real OAuth provider. I've fixed F5, F6 and F7 in Core's OAuth store (`packages/core/src/extensions/extensionOAuthStore.ts`) and added a regression test for each. The 3 new tests fail against the previous code and pass now. All 15 tests in `packages/core/test/extensionOAuth.test.ts` pass. So do 198 tests across the Core extension suites, the database export test and the API OAuth route test, which I ran with `PROPR_DEMO_MODE=true` because without it two suites fail on the GitHub-auth check. Core typecheck and zero-warning lint pass. I didn't run the full repository suite, and nothing has been tried against a real OAuth provider. **F5 / F6 (tokens without a refresh token):** when a connection has no refresh token, `accessToken` now keeps using the access token until it actually expires. It no longer tries to refresh during the last minute. After expiry, or when the upstream server refuses the token, the connection moves to Needs sign-in as before. Connections that have a refresh token still refresh a minute early. The new test uses a 30-second token with no refresh token: gateway calls work, nothing is refreshed and no one is notified. Then, both after real expiry and after an upstream rejection, it checks the move to Needs sign-in with one notification. **F7 (disconnect during token rotation):** - **Fence before revoking.** Disconnect now takes the connection's refresh lease and marks it `disconnecting` before contacting the provider. If a refresh holds the lease, Disconnect waits for it, then revokes the tokens that are current after it finishes. The wait is bounded; if it runs out, Disconnect returns a 409 asking to try again. - **No new refresh.** While a connection is `disconnecting`, the gateway can't get a token and no refresh can start. - **No replacement by a callback.** A sign-in callback refuses with a 409 instead of overwriting a `disconnecting` connection. It checks before exchanging the code, and again inside the save transaction. Pending sign-ins are cancelled both when Disconnect starts and when it finishes. - **Fenced deletion.** The final delete only removes the connection Disconnect fenced, and the audit entry is written only if that delete happened. - **What Settings shows.** A `disconnecting` connection appears as Needs sign-in, so if a Disconnect stops halfway, Disconnect is still available to finish it. Two tests cover this: - **Refresh already in flight:** Disconnect waits and revokes the rotated tokens. - **Revocation held open:** no refresh reaches the provider, and a callback is refused without exchanging its code. In both cases only the fenced tokens are revoked and nothing is left behind. **Existing test I changed:** "a refresh of a replaced connection…" used Disconnect to replace a connection while a refresh was still outstanding. With F7, Disconnect now waits for that refresh, so the test would hang. It now replaces the connection through a library change, which still exercises the successor fencing it was written for. **Problems I found but didn't fix (outside the selected findings):** - When a sign-in callback is cancelled after its code exchange (by Disconnect or a server change), the tokens the provider just issued are never revoked. This was already true before this change. - When a library save discards a connection (new URL, authentication type, client id, rename or removal), it deletes the tokens without revoking them. This change has no visible effect in the UI, so I didn't create previews. PR: #3536 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements OAuth across storage, discovery, gateway calls, API routes, Settings, and documentation. It needs localized corrections before merge. ✅ Credential custody — Tokens and pending verifiers are sealed with identity bindings, and native exports remove both custody tables. ✅ Refresh fencing — Generation, version, and lease-owner checks prevent an obsolete refresh from overwriting a replacement connection. ✅ Callback validation — Completion checks session, administrator, expiry, single-use state, server binding, and issuer before storing a connection. This review is a static trace of the supplied code; no commands or tests were run. Current checks report 31 passed, none failed, and three pending. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F8: 🔴 Clear draft secrets when changing clients
F9: 🔴 Keep reconnect refresh listeners active
SuggestionsThese are optional follow-ups and are not sent to S4: 🟢 Exercise the composed browser flowThe Playwright fixture mocks start, provider consent, and callback processing, while the API test injects session identity directly. A browser test against the actual API and session middleware would strengthen confidence in cookies, callback routing, and refresh notifications. This is additional integration coverage rather than a separately demonstrated blocker. ScoreThe implementation has substantial custody and concurrency protections, but two reproducible Settings defects remain. Both appear fixable without changing the backend architecture. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 3d80f8f
Summary of ChangesI fixed F8 and F9 and added a regression test for each. Both new tests fail on the previous code and pass now. All 288 Settings UI tests pass, and typecheck and zero-warning lint on the UI package are clean. I only ran UI tests, not Core, API or Playwright, and nothing has been tried against a real OAuth provider. F8: the secret no longer carries over to a new client id
F9: Reconnect keeps refreshing until the new connection arrives
Found separately, not changed: none. There are no previews: the only visible change is that the client-secret field empties when the client id changes. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…h new tests fail on the previous code and pass now. All 288 Settings UI tests pass, and typecheck and zero-warning lint on the UI package are clean. I only ran UI tests, not Core, API or Playwright, and nothing has been tried against a real OAuth provider. I fixed F8 and F9 and added a regression test for each. Both new tests fail on the previous code and pass now. All 288 Settings UI tests pass, and typecheck and zero-warning lint on the UI package are clean. I only ran UI tests, not Core, API or Playwright, and nothing has been tried against a real OAuth provider. **F8: the secret no longer carries over to a new client id** - In `ExtensionServerForm.tsx`, `change` now clears the typed token or client secret whenever the client id changes, including from one non-empty id to another. It already did this for URL and authentication changes. - The client-id input in `ExtensionOAuthFields.tsx` no longer clears the secret itself, so all the clearing happens in one place. - **Test:** enter client `client-a` and its secret, change the id to `client-b`, save. The secret field is empty and A's secret is not sent. - I checked the other places that can change the client id. Switching authentication or picking a catalog entry already cleared the secret. Renaming keeps the secret you typed, since you typed it for this server; the "won't carry over" notice is about the secret already stored under the old name. **F9: Reconnect keeps refreshing until the new connection arrives** - When a sign-in starts, `useExtensionLibrary.ts` now records the server's connection time at that moment (`connectedAt`, or none if it has no connection). The server only counts as signed in once Settings shows a connection with a different time. - Core sets that time only when a sign-in completes, not when tokens are refreshed. So coming back to Settings before finishing consent no longer drops the server from tracking, and the focus, visibility and BroadcastChannel listeners stay on. - **Test:** start Reconnect on a connected server and come back to Settings before finishing. The row still shows the old connection and tracking continues. Then come back again after the provider reports another account and other scopes: the row shows them, and the listeners are removed. - If an administrator abandons a Reconnect, the listeners stay on until they leave Settings. Each one only re-reads the library when the tab regains focus. **Found separately, not changed:** none. There are no previews: the only visible change is that the client-secret field empties when the client id changes. PR: #3536 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThis PR implements OAuth discovery, browser sign-in, encrypted token custody, refresh, gateway integration and Settings controls. It needs a localized recovery fix before merge. ✅ Credential isolation — OAuth tokens remain outside library revisions, and native exports explicitly erase connections and pending sign-ins. ✅ Callback fencing — Session binding, single-use state and transactional checks prevent a cancelled code exchange from restoring a connection. ✅ Refresh coordination — Generation and owner checks prevent an outstanding refresh from overwriting a replacement connection. This review used static tracing of the supplied code; no commands were run. Current checks report zero failures, with five still pending. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F10: 🔴 Reconnect cannot recover invalid dynamic clients
SuggestionsThese are optional follow-ups and are not sent to S5: 🟢 Exercise the actual browser callbackThe Playwright test intercepts both the start API and callback, while the API test injects session identity through test headers. A browser test using the actual session middleware and callback would strengthen confidence in cookie delivery and session continuity across provider redirects. This is additional integration coverage, not a demonstrated defect. ScoreThe implementation has substantial security and concurrency coverage, but the dynamic-client recovery failure prevents merge readiness. The supplied current checks show no failures; five remain pending. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 8224945
Summary of ChangesI fixed F10: Reconnect now gets a new client registration when the connection is in Needs sign-in, so a server whose provider deleted its dynamic client can be recovered without disconnecting it first. The new regression test fails on the previous code and passes now. The fix ( Other paths checked:
Regression test (in To support the test, I added Verification:
Separate finding, not changed: if a provider deletes a dynamic client while the connection still shows Connected, the first Reconnect reuses the dead client. The provider rejects it on its own page and never redirects back, so ProPR has nothing to detect. The connection recovers once the access token expires or the server returns 401, which moves it to Needs sign-in and makes the next Reconnect work. Re-registering on every Reconnect would close this gap but would leave more unused registrations with the provider. There's no visible UI change, so I didn't capture previews. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…hen the connection is in **Needs sign-in**, so a server whose provider deleted its dynamic client can be recovered without disconnecting it first. The new regression test fails on the previous code and passes now.
I fixed F10: Reconnect now gets a new client registration when the connection is in **Needs sign-in**, so a server whose provider deleted its dynamic client can be recovered without disconnecting it first. The new regression test fails on the previous code and passes now.
**The fix** (`packages/core/src/extensions/extensionOAuthStore.ts`, `dynamicClient`): the stored dynamic client is reused only while its connection is **Connected**. A refused refresh doesn't record whether the provider rejected the refresh token or the client itself, so I took the cautious option from the finding. Any dynamic connection in Needs sign-in registers again on Reconnect, and the callback then saves the new client id over the old row. When the client was still valid (for example, the refresh token had simply expired), this leaves one unused registration with the provider. Reconnecting a server that is still Connected keeps reusing its registration.
**Other paths checked:**
- Both ways a refused refresh reaches Needs sign-in go through the same code: a refresh before expiry, and a refresh after the server returns 401. The fix covers both.
- A connection whose stored tokens can't be decrypted already registered again.
- The pre-registered and metadata-document methods aren't affected: the first uses the client id the administrator entered, and the second uses ProPR's own URL as the client id.
**Regression test** (in `packages/core/test/extensionOAuth.test.ts`): it runs once for each of those two refresh paths. The synthetic provider deletes the registered client and refuses the refresh with `401 invalid_client`, and the test checks the server moves to Needs sign-in. Reconnect must then create a second registration with a different client id, complete sign-in, serve a run and refresh with the new client. A further Reconnect while Connected must create no extra registration. Against the old code it fails because the provider refuses the reused client ("Unregistered redirect URI").
To support the test, I added `invalidateClient` to the synthetic provider in `test/fixtures/extensionOAuthFixture.ts`. It now returns `401 invalid_client` for an unknown client at the token endpoint, as a strict provider does; it used to return `400 invalid_grant`. I also updated the dynamic-registration row in `docs/docs/features/agent-extensions.md` to describe the new behaviour.
**Verification:**
- All 16 tests in `packages/core/test/extensionOAuth.test.ts` pass.
- The API OAuth route test, which shares the fixture, passes.
- Core typecheck and zero-warning lint pass. The test and fixture files are outside the lint configuration, so lint skips them.
- I didn't run the full repository suite, and nothing was tried against a real OAuth provider.
**Separate finding, not changed:** if a provider deletes a dynamic client while the connection still shows **Connected**, the first Reconnect reuses the dead client. The provider rejects it on its own page and never redirects back, so ProPR has nothing to detect. The connection recovers once the access token expires or the server returns 401, which moves it to Needs sign-in and makes the next Reconnect work. Re-registering on every Reconnect would close this gap but would leave more unused registrations with the provider.
There's no visible UI change, so I didn't capture previews.
PR: #3536
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements OAuth across credential storage, discovery, refresh, gateway calls, Settings, and documentation. It needs a localized protocol correction before merge. ✅ Credential custody — Tokens and PKCE verifiers are sealed, public projections exclude credentials, and native exports erase connections and pending sign-ins. ✅ Refresh fencing — Connection generations, versions, and lease owners prevent an old refresh from overwriting a replacement connection. ✅ Failure coverage — The added tests exercise callback binding, refresh rotation, disconnect interleavings, and credential redaction. This review used static analysis only, as requested. The supplied current checks show no failures and two pending checks. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F11: 🔴 Preserve the discovered resource identifier
SuggestionsThese are optional follow-ups and are not sent to S6: 🟢 Exercise the real browser callbackThe Playwright test intercepts both OAuth start and callback, while the API test injects session identity through headers. A browser integration test against the actual session middleware and callback would strengthen confidence in cookie handling and deployment-origin behavior. This is optional additional coverage; the supplied code does not establish a separate session defect. ScoreThe implementation has substantial credential safeguards and targeted tests, but the resource-identifier mismatch blocks valid discovered configurations. The supplied checks have no current failures, with two still pending. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit a66a6c8
Summary of ChangesF11 is fixed. When a server's metadata names a parent resource (for example What changed
Same defect elsewhere: none. These are the only places that build a Regression test
Verification
Nothing visible changed in the UI, so there are no previews. I found no separate problems to report. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…rce (for example `https://tools.example.com` for `https://tools.example.com/mcp`), ProPR now sends that same identifier in the sign-in request, the code exchange and every refresh. Previously all three sent the endpoint URL. The endpoint stays the binding for credential custody, gateway routing and deciding when a connection is stale. F11 is fixed. When a server's metadata names a parent resource (for example `https://tools.example.com` for `https://tools.example.com/mcp`), ProPR now sends that same identifier in the sign-in request, the code exchange and every refresh. Previously all three sent the endpoint URL. The endpoint stays the binding for credential custody, gateway routing and deciding when a connection is stale. **What changed** - **Discovery** (`extensionOAuth.ts`): `discoverOAuth` returns the resource the metadata declares instead of `serverUrl`. The same-origin check is unchanged, so a resource on another origin or a non-parent path is still refused. - **Sign-in** (`extensionOAuthStore.ts`): `startSignIn` uses that resource for both the authorization URL and the pending details. The code exchange already read the pending details, so it now sends it too. - **Refresh**: the connection row has a new `resource` column, written when sign-in completes. `refreshOnce` uses `row.resource`, not `row.endpoint`. - **Migration**: I added the column to this PR's own unreleased OAuth migration rather than a new one, so it only exists on fresh databases. A dev database that already ran this branch's migration won't get it; drop the three `extension_oauth_*` tables there to recreate them. - **Check**: the Check result now reports the declared resource. - **Docs**: `agent-extensions.md` now says which resource is sent and that a refresh sends the same one as the sign-in. **Same defect elsewhere:** none. These are the only places that build a `resource` value. Revocation and the gateway's upstream calls don't send one. **Regression test** - The test fixture can now declare a parent resource. It then accepts only that exact value in the sign-in request, the code exchange and refresh, and answers a mismatch with `invalid_target`. By default it still declares the endpoint, so existing tests behave the same. - The new test in `packages/core/test/extensionOAuth.test.ts` covers both discovery paths, the 401 challenge and the well-known location. For each, it checks the resource the Check reports, the authorization URL, the `resource` sent in the code exchange and in refresh, and the stored row (`resource` is the parent, `endpoint` is unchanged). It also checks that the refreshed call still reaches the endpoint, and that resources on another path or origin are still refused. - It fails against the previous source files. With only the refresh line reverted it also fails, so the refresh part is checked on its own. **Verification** - All 17 tests in the OAuth file pass. - So do the other Core extension suites (96 tests), the database export test (103) and the API OAuth route test, all run with `PROPR_DEMO_MODE=true`. - Core typecheck passes, and zero-warning lint passes on the changed source files. - I didn't run the full repository suite or Playwright, and nothing has been tried against a real OAuth provider. Nothing visible changed in the UI, so there are no previews. I found no separate problems to report. PR: #3536 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements OAuth discovery, sign-in, encrypted token custody, refresh, gateway integration, and Settings controls comprehensively. It needs changes before merge because an in-progress sign-in can escape Disconnect’s cancellation. ✅ Credential isolation — OAuth tokens are sealed separately from library revisions, removed from native exports, and included in gateway output redaction. ✅ Refresh fencing — Generation, version, and lease-owner checks prevent an old refresh from overwriting a replacement connection. ✅ Callback validation — Completion checks session, administrator, expiry, issuer, PKCE exchange, and current server binding. This review used static analysis only; no commands were run. The supplied current-head status reports 32 passed checks, two pending, and no failures. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F12: 🔴 Register sign-in attempts before discovery
SuggestionsThese are optional follow-ups and are not sent to S7: 🟢 Exercise real browser session handlingThe Playwright test mocks the start endpoint and callback, while the API test injects session identity through headers. A browser integration test using the actual session middleware and callback would strengthen confidence in cookie delivery and session binding across the provider redirect. This is additional coverage, not a separately demonstrated blocker. ScoreThe implementation has substantial safeguards and focused coverage, but the sign-in cancellation gap requires correction. Pending checks alone do not reduce the score. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 7f4fb7a
Summary of ChangesF12 is fixed: a Disconnect or a library change that happens while a sign-in is still discovering or registering now cancels that sign-in, so it can no longer reconnect the server afterwards. The new regression test fails on the previous code and passes now. What was wrong. I confirmed the bug on the previous code by running each case through to the callback:
The fix is in
Disconnect and library saves didn't need changing. Both already delete pending rows, and those now include sign-ins still in progress. That covers the library binding changes too. I also updated the comment on the Tests
There is no visual change, so I made no preview. Two things I noticed but didn't change, since neither is a defect I can fix here:
🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
… while a sign-in is still discovering or registering now cancels that sign-in, so it can no longer reconnect the server afterwards. The new regression test fails on the previous code and passes now. F12 is fixed: a Disconnect or a library change that happens while a sign-in is still discovering or registering now cancels that sign-in, so it can no longer reconnect the server afterwards. The new regression test fails on the previous code and passes now. **What was wrong.** I confirmed the bug on the previous code by running each case through to the callback: | Change made while discovery or registration was waiting | Previous code | Now | |---|---|---| | Disconnect during discovery (the Reconnect case in the finding) | server reconnected | sign-in cancelled | | Disconnect during dynamic registration | server reconnected | sign-in cancelled | | URL changed and then changed back | server reconnected | sign-in cancelled | | New URL, server removed, or new client id | refused only later, at the callback | sign-in cancelled at the start | **The fix** is in `startSignIn` in `packages/core/src/extensions/extensionOAuthStore.ts`: - **Record first:** the sign-in now writes its pending row before it sends any discovery request. It does this in the same transaction that reads the server's settings. - **Not usable yet:** while discovery and registration run, the row is marked as owned by the start, so no callback can use it. It already holds the endpoint and client id that a library save compares against. - **Finish only if it still exists:** at the end, the start fills in the sign-in details and releases the row for the callback, but only if the row is still there. If it's gone, the start fails with "The sign-in was cancelled; connect again", so it never writes a replacement row. - **Clean up on failure:** a start that fails for any reason deletes its row. Disconnect and library saves didn't need changing. Both already delete pending rows, and those now include sign-ins still in progress. That covers the library binding changes too. I also updated the comment on the `claim` column in the migration. **Tests** - **New test:** covers each row of the table above. A control case checks that a save which doesn't change the server's binding leaves the sign-in intact and lets it complete. - **Runs:** all 18 tests in `extensionOAuth.test.ts` pass. So do 201 tests across the Core extension suites, the database export test and the API OAuth route test, run with `PROPR_DEMO_MODE=true`. - **Checks:** Core typecheck and zero-warning lint on Core `src` are clean. - **Not run:** the full repository suite, UI, Playwright, and anything against a real OAuth provider. There is no visual change, so I made no preview. Two things I noticed but didn't change, since neither is a defect I can fix here: - **Leftover registration at the provider:** if a sign-in is cancelled after dynamic registration has finished, the client stays registered at the provider. Removing it would need a deregistration call, which isn't part of this flow. - **Ordering:** a Connect whose first write lands after Disconnect has finished is treated as a new Connect. That ordering can't be avoided. PR: #3536 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR implements OAuth sign-in across credential storage, discovery, refresh, gateway calls, API routes and Settings. Based on static review of the supplied diff and surrounding context, it is merge-ready within scope, conditional on the remaining checks passing. ✅ Credential isolation — Tokens and dynamic client secrets are sealed outside library revisions; database exports explicitly remove connections and pending sign-ins. ✅ Concurrent-operation protection — Pending-attempt claims, connection generations and conditional refresh leases prevent cancelled callbacks and superseded refreshes from overwriting newer connections. ✅ Bounded gateway recovery — OAuth calls obtain current credentials, refresh after an upstream 401, retry once and redact both access tokens used. No commands or tests were run during this review. The supplied current-head status reports 32 passed checks, two pending and no failures. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S8: 🟢 Exercise the complete browser-to-server flowThe Playwright test intercepts the extension API, provider and callback, while backend tests inject the transport and session identity. These provide useful coverage of individual layers, but do not exercise their production composition together. A follow-up integration test using the actual routes, session middleware and HTTPS transport would improve confidence in cookie handling, callback authentication and transport behavior. This is additional validation, not a demonstrated merge blocker. ScoreThe implementation has substantial security and concurrency protections, with focused regression coverage. No actionable defect was established from the supplied code; production integration remains less directly tested than the individual layers. Score: 8/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
AI Implementation Summary
Closes #3512
Branch:
3512/claude-opus-5-5-oauth-sign-in-for-mcp-ser-20261113-1145-cznCommits: ✅ Changes committed (5d09009)
AI Processing Completed
Execution Details:
Summary:
I've implemented OAuth sign-in for library MCP servers, from the shared contract through Core, the API, Settings and the docs. The new and related tests pass. I didn't run the full repository suite, and nothing has been tried against a real OAuth provider: all OAuth tests use a synthetic authorization server and MCP server.
What it does
httpsserver can useauthentication: 'oauth', with optionalscopes, aclientIdand a write-only client secret. The secret is stored like a Bearer token, and changing the URL, authentication type or client id never carries it over.401challenge, falling back to the well-known location, then the authorization server's metadata, and requires PKCES256. Every discovery, registration, token and revocation request goes through the existing endpoint policy, so private and loopback addresses are refused.resourceparameter. Thestateis single-use, expires after 10 minutes and is bound to the session, the administrator, the item and its endpoint. The callback checksissand stores nothing unless the code exchange succeeds. The redirect URI and the public client metadata URL come from the same public base URL ProPR's own MCP server uses; without one, Connect is disabled with an explanation.extension_oauth_connectionstable, with pending sign-ins and an audit trail in their own tables. Connecting, refreshing and disconnecting create no library revision. Native exports erase connections and pending sign-ins and keep the audit trail.401. Refresh is single-flight within a process and across processes, and a rotated refresh token is saved together with the new access token. A refused refresh moves the item to Needs sign-in once and sends one notification; network errors are retried and change nothing.401, and redacts the token from output. Unconnected or Needs-sign-in servers are skipped with the reasonoauth_not_connectedoroauth_needs_sign_in, and the run continues. Changing the URL, authentication or client id, or renaming or removing the server, discards the connection; disabling it keeps the connection.agent-extensions.mdhas a new "OAuth servers" section covering everything the issue asked for.Two choices that differ from the issue's wording
system_failurekind with componentextensions.oauth. A new kind would need schema changes, because the allowed kinds are fixed in the notification tables. I checked that the event passes the notification validator.Tests
test/claudeExtensionEnvironment.test.tsandtest/extensionLaunchIntegration.test.ts) failed when run together with others because they share one test database file. Each passes when run on its own database.Screenshots of the connected server row and the OAuth server form are attached as previews.
Detailed Logs:
443ef1f8-774e-47f2-a507-c36bb8ca3869Log files stored at:
/usr/src/app/logs/executions/issue-3512-2026-11-13T12-29-11-448Z-conversation.json/usr/src/app/logs/executions/issue-3512-2026-11-13T12-29-11-448Z-output.txtLatest Conversation Messages
This PR was created automatically by ProPR after processing issue #3512.
💡 Need changes?
Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!
Visual preview
OAuth MCP server connected
Settings → Skills & MCP servers after Connect: the OAuth server row shows Connected, who connected it and when, the granted scopes, and Reconnect / Disconnect. Captured by the Playwright spec against the synthetic provider.
Connect sign-in required. Original retained until 2027-02-11T12:29:16.661Z.
View the full-resolution original in ProPR Connect
OAuth sign-in settings in the server form
Authentication: OAuth sign-in with the shared-identity warning, scopes, a pre-registered client id and write-only client secret, the redirect URI to register, and Check.
Connect sign-in required. Original retained until 2027-02-11T12:29:17.999Z.
View the full-resolution original in ProPR Connect