Repository navigation
Conversation
Hide tracked repositories from canvas pairing, rotate canvas refresh tokens with reuse revocation, and coalesce unknown-credential audits. Require exact agent OAuth redirect URIs, lock and check viewers before agent refresh rotation, and validate registered redirect schemes. End replaced browser sessions, revoke GitHub user tokens after sign-in, audit authentication proof failures by reason, log redacted agent connection errors, share the effective-administrator SQL fragment, and correct authentication docs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Interacting session and refresh-token lifecycle changes require human review of concurrency semantics and compatibility with unobserved Copilot client redirect registrations.
No open issues 🎉
What changed in this PR
This PR hardens Hub’s canvas connections, agent authorization, and browser sign-in before integration into main. It also updates the Copilot canvas extension to retain rotated refresh tokens.
Changes:
- Defers repository lookup until pairing approval, rotates canvas refresh tokens, and limits repeated unknown-credential audits.
- Tightens agent OAuth validation, ends previous browser sessions during sign-in, and adds best-effort GitHub token revocation.
- Shares administrator SQL checks and updates logging, regression coverage, migrations, and authentication documentation.
| File | Description |
|---|---|
hub/test/database/canvas-pairing-names-migration/index.db.test.ts |
Tests pairing migration and approval constraints. |
hub/server/utils/logging/summarize-error/index.ts |
Summarizes errors without their messages. |
hub/server/utils/logging/summarize-error/index.test.ts |
Tests error-summary redaction. |
hub/server/utils/effective-administrator-exists/index.ts |
Centralizes the administrator SQL predicate. |
hub/server/routes/api/canvas/index.ts |
Updates pairing responses and client audit identifiers. |
hub/server/routes/api/canvas/extension.db.test.ts |
Covers pairing privacy, rotation, reuse, and audit limits. |
hub/server/routes/api/auth/types.ts |
Adds previous-session termination to callback dependencies. |
hub/server/routes/api/auth/index.test.ts |
Tests session replacement and contention responses. |
hub/server/routes/api/auth/create-authentication-route-dependencies/index.ts |
Wires session termination and revocation logging. |
hub/server/routes/api/auth/callback/get/index.ts |
Ends previous sessions before replacing cookies. |
hub/server/routes/agent-connections/index.ts |
Logs summarized agent-tool errors. |
hub/server/routes/agent-connections/index.db.test.ts |
Tests refresh rejection and required redirect matching. |
hub/server/repositories/sensitive-authorizations/verify-sensitive-authorization/index.ts |
Uses the shared administrator predicate. |
hub/server/repositories/sensitive-authorizations/get-sensitive-authorization/index.ts |
Uses the shared administrator predicate. |
hub/server/repositories/sensitive-authorizations/create-sensitive-authorization/index.ts |
Uses the shared administrator predicate. |
hub/server/repositories/sensitive-authorizations/cancel-sensitive-authorization/index.ts |
Uses the shared administrator predicate. |
hub/server/repositories/memberships/search-administrator-candidates/index.ts |
Shares administrator exclusion logic. |
hub/server/repositories/memberships/lock-effective-administrators/index.ts |
Shares administrator selection logic. |
hub/server/repositories/hub-sessions/find-administrator-hub-session/index.ts |
Shares administrator session checks. |
hub/server/repositories/copilot-connection-state/disconnect-copilot-connection-without-effective-administrator/index.ts |
Shares administrator connection checks. |
hub/server/repositories/canvas/revoke-reused-canvas-grant/index.ts |
Revokes grants when replaced refresh tokens return. |
hub/server/repositories/canvas/record-audit/index.ts |
Records refresh-token reuse reasons. |
hub/server/repositories/canvas/pairings/index.ts |
Binds repositories during approval. |
hub/server/repositories/canvas/grants/index.ts |
Implements staged refresh-token rotation. |
hub/server/repositories/agent-connections/find-refreshable-agent-connection/index.ts |
Finds live connections before refresh rotation. |
hub/server/integrations/mcp/agent-oauth-provider/index.ts |
Validates registered redirect URI schemes and fragments. |
hub/server/integrations/mcp/agent-oauth-provider/index.test.ts |
Tests accepted and rejected redirect URIs. |
hub/server/integrations/mcp/agent-oauth-provider/constants.ts |
Defines permitted loopback hosts and app schemes. |
hub/server/integrations/github/create-user-authentication-adapter/types.ts |
Adds optional revocation logging. |
hub/server/integrations/github/create-user-authentication-adapter/index.ts |
Revokes GitHub user tokens after use. |
hub/server/integrations/github/create-user-authentication-adapter/index.test.ts |
Tests revocation requests and best-effort failures. |
hub/server/integrations/express/authentication-rate-limit/index.ts |
Names the actual rate-limited operation in logs. |
hub/server/integrations/express/authentication-rate-limit/index.test.ts |
Tests operation-specific logging. |
hub/server/index.ts |
Passes the logger into authentication setup. |
hub/server/index.test.ts |
Updates authentication dependency expectations. |
hub/server/domains/canvas/pairings/index.ts |
Defers repository lookup and limits unknown-device audits. |
hub/server/domains/canvas/connections/index.ts |
Returns rotated tokens and handles token reuse. |
hub/server/domains/canvas/audit-unknown-credential/index.ts |
Limits unknown-credential audits per client and operation. |
hub/server/domains/authentication/create-github-authentication-context/index.ts |
Passes logging into GitHub authentication. |
hub/server/domains/authentication/complete-authentication-proof/index.ts |
Audits the actual proof-failure reason. |
hub/server/domains/authentication/complete-authentication-proof/index.test.ts |
Tests denial-reason mapping. |
hub/server/domains/agent-connections/create-agent-connections/index.ts |
Enforces redirect matching and checks authority before refresh. |
hub/server/domains/admission/authentication-flow.db.test.ts |
Accounts for GitHub token revocation requests. |
hub/schema/migrations/20261229090000_canvas_pairing_names_and_refresh_rotation/migration.sql |
Adds pairing names and refresh-rotation storage. |
hub/schema/canvas-pairing.prisma |
Stores requested names with optional repository binding. |
hub/schema/canvas-grant.prisma |
Adds pending and previous refresh digests. |
hub/docs/prototype-canvas.md |
Documents pairing privacy, rotation, and audit limits. |
hub/docs/learning-foundation.md |
Documents agent redirect and refresh requirements. |
hub/docs/authentication.md |
Clarifies session replacement, revocation, and step-up authentication. |
.github/extensions/replica-prototype/create-hub-client/renewal.test.mjs |
Tests persistence of rotated refresh credentials. |
.github/extensions/replica-prototype/create-hub-client/index.mts |
Validates and stores returned refresh tokens. |
.github/extensions/replica-prototype/create-hub-client/index.mjs |
Updates the runtime client to retain rotated tokens. |
Review effort: Balanced (adaptive)
Keep the digest of every replaced canvas refresh token so presenting any of them revokes the grant, not only the most recent one. Allow the GitHub Copilot app's github-app:// callback, which its published client metadata lists, and document the redirect URIs that VS Code and the Copilot CLI register. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved refresh-token lifecycle flaws can leave disconnected connections active, preserve non-rotating credentials, and let late renewal requests invalidate tokens clients have already saved.
7 open issues
Hold authority locks through refresh-token rotation · New Revoke grants when disconnect uses a retired refresh token · New Prevent late retries from invalidating newer refresh tokens · New Require rotation support before renewing credentials for older clients · New Clean up retired token history for inactive grants · New Clean up replacement sessions when prior-session termination fails · New Add UUID primary key and standard timestamps to the table · New
Review effort: Max (adaptive)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Store pending and retired refresh tokens in canvas_refresh_tokens, cap pending tokens, prune retired ones, revoke on disconnect with a retired token, and issue renewable connections only to extensions that send X-Replica-Canvas-Refresh-Rotation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
weastler
approved these changes
Dec 2, 2026
This was referenced Dec 2, 2026
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.


Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
595379ed947ae9cb3c5422db17f8bf5040bc7d0b↑ All review threads are addressed, including stack-frame-only error logging; migration SQL matches Prisma's diff.
↑ VS Code and Copilot CLI redirect registrations were observed and pass validation.
↓ The Copilot app's registration was inferred from its published client metadata, not observed.
↓ Migration compatibility tests time out under parallel load locally and pass serially; CI passed at the previous head; this head changes only error-summary logging.
↓ Finding 6 was only partly correct.
Why
A review of
build/hub/newfound authorization, session and audit gaps in Hub before it merges tomain. The gaps include canvas pairing revealing tracked repository names, canvas refresh tokens that never rotate, loose agent OAuth checks, and noisy or misleading audit records. This PR fixes them.What changes
Canvas pairing: Starting a canvas pairing now always succeeds, so it no longer reveals whether Hub tracks a private repository. Hub resolves the repository when the signed-in user opens the approval. An untracked repository and one the user can't read show the same not-available page. A migration stores the requested repository name on pending pairings.
Canvas refresh tokens: Each renewal now issues a new refresh token, and the extension stores it.
canvas_refresh_tokenstable. Presenting a replaced token again, to renew or to disconnect, revokes the connection and recordsrefresh_token_reusedin the audit context.X-Replica-Canvas-Refresh-Rotation: 1. Older extensions can't renew and pair again instead.Unknown credentials: Repeated canvas requests with unknown credentials now write at most one audit row per client and operation each hour.
Agent connections:
redirect_uriand it must match exactly. This is stricter than RFC 6749 when a client omits it from both requests.cursor:andgithub-app:redirect URIs, without fragments. I checked what clients register:https://vscode.dev/redirect,https://insiders.vscode.dev/redirect,http://127.0.0.1/andhttp://127.0.0.1:33418/.http://127.0.0.1:<port>/.github-app://oauth/callbackand loopback URIs, sogithub-app:is allowed. I did not observe the app's registration directly.Sign-in and audit:
hub/docs/authentication.mdnow limits the "no refresh tokens" statement to browser sessions and describes provider re-sign-in as step-up authentication.Finding 6 is partly skipped. The
bootstrap_attempt_deniedaudit label is correct, because only the administrator enrollment start route writes that audit. Only the generic rate-limit middleware log was misleading, and it now names the actual operation.The extension keeps its old 404 pairing message so it still works with older Hubs.