You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Used by verify_oauth_access_token() during MCP access-token verification
A structurally identical pair already exists in mcpgateway/services/sso_service.py for id_token verification during SSO callback. The two caches:
Serve different request paths (SSO callback vs MCP transport)
Have different lifecycles (one is used during interactive login, the other on every MCP request)
Implement the same discovery + JWKS retrieval pattern
This duplication was acknowledged in the PR #3715 description as a deliberate short-term decision so the access-token path could land without touching the SSO code path. This issue tracks the follow-up consolidation.
Proposal
Extract a shared module (e.g. mcpgateway/utils/oidc_discovery.py) that exposes:
Context
PR #3715 (OAuth access-token JWKS verification for virtual-server MCP endpoints) added OIDC discovery and JWKS client caches to
mcpgateway/utils/verify_credentials.py:_oauth_oidc_metadata_cache+_discover_oidc_metadata()_oauth_jwks_client_cacheverify_oauth_access_token()during MCP access-token verificationA structurally identical pair already exists in
mcpgateway/services/sso_service.pyfor id_token verification during SSO callback. The two caches:This duplication was acknowledged in the PR #3715 description as a deliberate short-term decision so the access-token path could land without touching the SSO code path. This issue tracks the follow-up consolidation.
Proposal
Extract a shared module (e.g.
mcpgateway/utils/oidc_discovery.py) that exposes:async def discover_oidc_metadata(issuer: str) -> Optional[dict]— shared success/negative-TTL cacheget_jwks_client(jwks_uri: str) -> jwt.PyJWKClient— shared lazy client cacheCallers:
mcpgateway/utils/verify_credentials.py::verify_oauth_access_token— OAuth access-token path (PR feat(auth): verify OAuth access tokens via JWKS for virtual server MCP #3715).mcpgateway/services/sso_service.py— SSO id_token verification path.Acceptance criteria
jwks_uri.tests/unit/mcpgateway/test_auth.py::TestVerifyOauthAccessTokenand the SSO id_token test suites continue to pass unchanged.Non-goals
References
verify_credentials.pymcpgateway/services/sso_service.py— existing SSO id_token discovery cache