Skip to content

feat: add unwired existing-account MCP actor verification - #1270

Merged
sidneyswift merged 2 commits into
mainfrom
codex/mcp-existing-application-actor
Nov 18, 2026
Merged

sidneyswift merged 2 commits into
mainfrom
codex/mcp-existing-application-actor

Conversation

@sidneyswift

@sidneyswift sidneyswift commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem and result

App2104 needs original-actor identity evidence without onboarding an unknown Privy account. Existing MCP authentication can provision before tool dispatch. This adds an unwired, standard-Bearer helper that independently verifies the original server request with fixed existing-account options and reuses the strict application actor guard. Valid delegated OAuth and classification failures deny before standard verification; only copied internal actor/workspace/evidence is returned, never credentials.

No route, tool registration, allowlist, shared auth leaf or Sites create/read/storage implementation changes. Current MCP onboarding remains unchanged. A future trusted request handoff must run before legacy authentication and receives a separate review; this helper is not an execution grant or public result.

Controlled validation

The real OAuth classifier/authentication/actor guard run with controlled runtime, SDK and DB leaves. Sixteen new cases cover disabled runtime import traps, full/limited denial, undefined independent verification, runtime/store failures, existing/unknown Privy identity, exact profile predicates, headers/body spoofing, fresh observations and secret-free output. All 61 tests pass: 16 new plus 45 existing harness compatibility tests. Parent loader/env and dotenv poison isolation and separate child-env filtering pass with owned-process cleanup. Scoped TypeScript, changed-file lint/format and diff whitespace pass. Independent exact-commit Spec 0 / Standards 0.

The shared runner/setup/network/config/golden remain byte-identical. CI launch now uses absolute Node under env-i; source bindings change only the Vercel hash for the new false branch deployment guard. No real credentials, authenticated clients or network/provider effects used.

Boundaries

No personal enrollment, entitlement, SQL atomic revocation, provider cryptographic OAuth proof, client acceptance or runtime availability is claimed. Branch deployments disabled; coordinator retains the merge gate. No policy or storage activation.

Final revision qualification

Head dddf29749401a687bde71ae5b8f4f0f93492463a, tree 1f7842339fe78bfcab528f560a6731f6a6a1780d. All eight Actions jobs pass, including required test/format/lint. The Node 22.23.4 dedicated job checks out this exact head and passes all 61 controlled tests with verified bindings and cleanup. Unit Tests actually checks out synthetic merge 7196ea9f4b5ecfacb34c53ae352da4dac2e2a054, whose tree matches this candidate; all workflow and type-check steps pass.

Independent exact-successor Spec and Standards reviews: zero findings. Four original Cubic findings fixed; raw exception logging rejected to preserve the credential boundary. The successor file-length suggestion is dispositioned as nonblocking; all six threads are resolved. Cubic completed successfully with that style finding; CodeRabbit skipped review. Codex's no-findings review applies to the earlier 32728fe revision, not the successor.

Source-only qualification. No merge, deployment activation, authenticated client acceptance or runtime wiring is included.

@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Passed 1

Check name Status Explanation
Solid & Clean Code Passed The PR adds one production file, lib/mcp/applications/verifyExistingApplicationMcpActor.ts (27 lines), plus a test file, docs and config. I read the production file at head dddf2974. - **SRP / fil…
Full details: Solid & Clean Code

Explanation

The PR adds one production file, lib/mcp/applications/verifyExistingApplicationMcpActor.ts (27 lines), plus a test file, docs and config. I read the production file at head dddf2974. - SRP / file-function match: The file exports one function, verifyExistingApplicationMcpActor, and the file name matches it. The function body is about 18 lines, under the 20-line limit. Its steps (Bearer parse, API-key rejection, OAuth classification, standard auth, actor guard, evidence copy) form one cohesive "verify existing actor" flow. Nesting stays within 2 levels (try → if). - OCP / DRY / KISS: The helper reuses validateAuthContext, validateProposedRegistrationActor, verifyOAuthBearer and errorResponse rather than duplicating them. It adds no abstraction layers and does not modify shared auth code. - Clean code: Names are descriptive. Error handling is explicit, and the comments explain the security reasons rather than restating the code. - Minor observations (non-blocking): The inline Bearer regex and the status/message literals could be named constants. The auth.verificationEvidence! non-null assertion relies on the prior call's option. The 260-line test file is long, though it is not a class and has no god-object concern. No explicit failure condition in the check is met. The SRP, DRY and clean-code concerns are limited to the minor notes above.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T03:55:20.430610Z 32728fe PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files

Architecture diagram
sequenceDiagram
    participant Caller as Future MCP Handoff Caller
    participant Helper as verifyExistingApplicationMcpActor
    participant OAuth as verifyOAuthBearer
    participant AuthCtx as validateAuthContext
    participant ActorGuard as validateProposedRegistrationActor
    participant Keys as Account API Keys
    participant Privy as Privy Profile/Email Lookup
    participant DB as Supabase Storage

    Note over Caller,DB: Unwired Existing-Identity Verification Flow
    
    Caller->>Helper: Original NextRequest (Bearer token)
    
    alt Missing/malformed Bearer OR x-api-key present
        Helper-->>Caller: 401 Standard Bearer required
    else Valid Bearer header
        Helper->>OAuth: verifyOAuthBearer(bearer)
        
        alt Delegated OAuth grant valid
            OAuth-->>Helper: Grant result
            Helper-->>Caller: 403 Delegated authentication unsupported
        else OAuth classification fails/undefined
            OAuth-->>Helper: null/error
            Note over Helper: Disabled runtime import or classification failure
            Helper->>AuthCtx: validateAuthContext(allowAccountCreation:false, includeVerificationEvidence:true)
        end
    end
    
    alt OAuth disabled or undefined
        AuthCtx->>Keys: Query account_api_keys
        Keys-->>AuthCtx: Key/actor mapping
        AuthCtx->>Privy: GET /v1/users/{subject}
        Privy->>DB: Fetch account_emails
        DB-->>Privy: Profile + linked accounts
        Privy-->>AuthCtx: Existing account identity
    end
    
    AuthCtx->>ActorGuard: validateProposedRegistrationActor(auth)
    
    alt Actor guard passes
        ActorGuard-->>Helper: {actor, workspace}
        Helper->>Helper: structuredClone(verificationEvidence)
        Helper-->>Caller: {actor, workspace, verificationEvidence}
    else Actor guard rejects
        ActorGuard-->>Helper: NextResponse error
        Helper-->>Caller: Authenticated error (401/403)
    end
    
    alt Unexpected runtime/store failure
        Helper-->>Caller: 503 Verified identity unavailable
    end
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@sidneyswift
sidneyswift merged commit a2a6d6b into main Nov 18, 2026
10 checks passed
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