Repository navigation
feat: bind write approvals to the authenticated principal (1.4.0) - #72
Open
bitclicklabs wants to merge 1 commit into
Open
bitclicklabs wants to merge 1 commit into
bitclicklabs wants to merge 1 commit into
Conversation
On Streamable HTTP with the OAuth resource server enabled, many clients share one server process and its write_approvals store. Approval tokens are a deterministic hash of the payload, so client B could execute a write that client A validated by replaying the same payload. validate_write now stores the caller principal (token client_id, issuer, subject, and MCP session id) in the approval record, and execute_approved_write refuses any other caller without consuming the record. chatter_post mixes the principal into its stateless token. stdio and unauthenticated HTTP keep the per-process behavior. The introspection verifier now forwards sub and iss so users sharing one OAuth client are distinct principals. Audit JSONL lines carry a principal object, with the session id digested.
This branch has not been deployed
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.
Summary
With the OAuth resource server enabled (
ODOO_MCP_AUTH_*), many Streamable HTTP clients share one server process and its in-memorywrite_approvalsstore. Approval tokens are a deterministic hash of the payload with no caller identity, so client B could execute a write that client A ranvalidate_writefor, just by sending the same payload.This PR binds approvals to the authenticated caller:
validate_writestores the principal (tokenclient_id,iss,sub, plus themcp-session-idwhen the transport has one) in the validation record.execute_approved_writerefuses any other caller withapproval was validated by a different authenticated principal or MCP session. The refused attempt does not consume or evict the original caller's approval.chatter_post(stateless preview) mixes the principal into its approval token on authenticated calls.IntrospectionTokenVerifiernow forwardssubandissto the SDKAccessToken, so users sharing one OAuth client are distinct principals.ODOO_MCP_AUDIT_LOGlines gain aprincipalobject (client_id,issuer,subject,session_sha256),nullwhen unauthenticated.The principal check sits after the token/payload checks and before
confirm/ODOO_MCP_ENABLE_WRITES; no existing write gate or field-ACL choke point changed.Behavior note: an authenticated client that reconnects (new MCP session) between
validate_writeandexecute_approved_writemust re-validate. Stateless HTTP has no session id, so binding there is principal-only.Version bumped to 1.4.0 with a CHANGELOG entry; README and
docs/claude-desktop-connector.mdupdated.Coverage
mcp-session-idrequest header (tests/test_write_principal_binding.py)Verification
uv run python -m ruff check . uv run python -m mypy src uv run python -m pytest uv run --with import-linter lint-importstest_from_path_rejects_file_swapped_for_symlink_after_root_check, which fails identically onmainon Windows (symlink semantics);test_list_tasks_newest_firstis intermittently flaky on Windows timer resolution, also pre-existing.scripts/odoo_compose_smoke.pyand a live OAuth end-to-end session.