feat(auth): propagate end-user identity to upstream MCP servers#3152
Open
crivetimihai wants to merge 1 commit intomainfrom
Open
feat(auth): propagate end-user identity to upstream MCP servers#3152crivetimihai wants to merge 1 commit intomainfrom
crivetimihai wants to merge 1 commit intomainfrom
Conversation
Add secure, configurable identity propagation from the gateway to upstream MCP servers. When enabled, the authenticated user's identity (email, groups, roles, admin status, auth method) is forwarded via HTTP headers (X-Forwarded-User-*) and/or MCP _meta fields. Key changes: - UserContext model on GlobalContext, always populated from all auth paths - Identity propagation utility (headers, meta, HMAC signing, filtering) - Per-gateway config overrides via identity_propagation JSON field - Audit trail enriched with auth_method, acting_as, delegation_chain - RFC 8693 token exchange on OAuthManager for on-behalf-of flows - Session pool identity isolation via forwarded user headers - Plugin convenience helpers (user_context, user_email, user_groups) - ADR-041, dedicated docs page, full configuration surface coverage - 77 unit tests with comprehensive diff coverage Closes #1436 Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
ced09d4 to
f4f1f60
Compare
Collaborator
|
@crivetimihai I have the pen on this one. Need to extend to other areas of the codebase. |
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
X-Forwarded-User-*) and/or MCP_metafieldsUserContextmodel populated unconditionally from all auth paths (JWT, API key, basic, SSO, proxy), removing theinclude_user_infogateauth_method,acting_as, anddelegation_chainfieldsIDENTITY_PROPAGATION_ENABLED(default:false) — zero behavioral change for existing deploymentsChanges
Core Implementation (8 phases)
GlobalContext+ always-on identity population from all auth pathsconfig.py, per-gateway JSON override onGatewaymodelmcpgateway/utils/identity_propagation.py): headers, meta, HMAC signing, filteringtool_service,resource_service,streamablehttp_transport(all code paths)auth_method,acting_as,delegation_chain) + 2 Alembic migrationsPluginContext.user_context,.user_email,.user_groupsDEFAULT_IDENTITY_HEADERSfor user isolationidentityMetafield on execution plans for_metapropagation via RMCPDocumentation & Configuration Surfaces
docs/docs/manage/identity-propagation.mdconfiguration.mdconfig.schema.jsonfilesvalues.yaml+values.schema.jsondocker-compose.yml+.env.exampleTests
Future Work
OAuthManagerfor on-behalf-of flows (deferred to a follow-up PR)Closes #1436