fix(mcp): harden tenant isolation and caller identity - #180
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (11)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
Review The direction is right: scoping Must fix
Should address
Minor
Item 1 will break CI. The rest are hardening and coverage. |
ReviewGood, focused hardening. Removing Issues / suggestions
No blocking security flaws found in the diff itself. I'd request tests for #2 and #6 before merge. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54666dd40b
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const { app } = buildApp({ authMethod: 'service' }); | ||
| const res = await app.request('/', { headers: { 'X-Chitty-User-Id': 'user-1' } }); |
There was a problem hiding this comment.
Update the existing caller middleware suite
The new coverage sets authMethod: 'service', but the unchanged server/__tests__/middleware-caller.test.ts still invokes callerContext without that context and expects both X-Chitty-User-Id and the now-removed X-User-Id fallback to work. Running pnpm test:run on this commit therefore fails two tests; update that existing suite to establish the service-auth context for the Chitty header case and to expect rejection for the generic header.
Useful? React with 👍 / 👎.
| const storage = c.get('storage'); | ||
| const user = await storage.getUserByChittyId(claims.sub); | ||
| if (!user) return null; |
There was a problem hiding this comment.
Reject inactive local users in the bearer resolver
When a locally deactivated user still has a valid ChittyAuth JWT, this resolver accepts the user and the new bearer path proceeds to every protected route. Local account status is an established authentication control—the password login rejects inactive users in server/routes/session.ts:99-101, and the ChittyID callback rejects them in server/routes/chittyid-auth.ts:153-155—so the new direct bearer lane bypasses deactivation unless this lookup also rejects !user.isActive.
Useful? React with 👍 / 👎.
| * Hybrid auth: | ||
| * - Path 1a: service Bearer token → service-to-service compatibility | ||
| * - Path 1b: ChittyAuth Bearer JWT → cryptographically bound end-user/agent caller | ||
| * - Path 2a: ChittyAuth JWT cookie → browser session | ||
| * - Path 2b: KV cookie → legacy browser session |
There was a problem hiding this comment.
Document the new JWT bearer authentication lane
This adds ChittyAuth JWTs as valid Authorization bearer credentials, but the published contract in docs/contracts/chittybooks-chittyfinance.md:34 still explicitly says bearer authentication is service-to-service only, while the MCP registry still advertises only a bearer service token. Consumers following those contracts cannot discover the intended channel-neutral flow and may continue sending an impersonation header or cookie instead; update the authentication documentation with this behavior change.
AGENTS.md reference: AGENTS.md:L48-L48
Useful? React with 👍 / 👎.
|
Review Solid, well-scoped hardening. Scoping Issues / suggestions
Tests
Docs The hybridAuth JWT tests and the audience-check confirmation are the main items I'd want before merging. 🤖 Generated with Claude Code |
Closes #179.
Changes
finance://tenantstostorage.getUserTenants(userId)rather than globalgetTenants()X-User-Idand?userId=caller impersonation pathsX-Chitty-User-Idonly for the existing service-token compatibility laneArchitecture
No new auth service, database, or schema. ChittyID/ChittyAuth remain identity authority;
tenant_usersremains financial authorization authority. This is the prerequisite for projecting the same ChittyFinance MCP capability into ChatGPT, Claude, and ChittyClaw/OpenClaw.Validation
Branch-level diff reviewed. Repository CI is the execution proof for typecheck/tests; no deployment is included.
Summary by CodeRabbit
/mcpand clarify supported authentication methods.