feat(auth): Universal Multi-Provider JIT Dynamic Discovery Bridge (CIMD / Auth0 / Okta / Zitadel / Keycloak) - #345
Draft
hemantj-cloud wants to merge 5 commits into
Draft
hemantj-cloud wants to merge 5 commits into
hemantj-cloud wants to merge 5 commits into
Conversation
- Add mountCimdEndpoint, createCimdHandler, and validateRedirectUriWithCimd in cimd.ts - Implement CimdCache with in-flight request deduplication and TTL caching - Add initiateCimdConnect and supportsClientIdMetadataDocument to OAuth2Client in client.ts - Update exchangeCodeForToken, refreshToken, and revokeToken to support CIMD URL as client_id - Add setupCimdHosting and setupAuth0CimdClient quick-setup helpers in quick-setup.ts - Advertise client_id_metadata_document_supported in OAuthModule metadata discovery endpoints - Add comprehensive test suite in src/auth/__tests__/cimd-jit.test.ts
hemantj-cloud
requested a review
from abhishekpanditofficial
as a code owner
September 4, 2026 13:48
…al/nitrostack into feat/cimd-jit-dynamic-discovery
…, and CIMD cache bounding
…ncoded and basic auth support
hemantj-cloud
marked this pull request as draft
September 6, 2026 21:21
…ent registration across adapters
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.
Description
This PR implements the Universal Multi-Provider Just-in-Time (JIT) Dynamic Discovery Bridge (
JitBridge) in@nitrostack/coreper the OAuth Client ID Metadata Document (draft-ietf-oauth-client-id-metadata-document) specification.This bridge enables dynamic AI agents (ChatGPT, Claude Desktop, Cursor, Claude Code, custom agents) with dynamic CIMD client URLs (e.g.
https://chatgpt.com/oauth/<id>/client.json) and dynamic desktop loopback ports (http://127.0.0.1:<port>) to authenticate seamlessly with enterprise Identity Providers (Auth0, Okta, Zitadel, Keycloak, Ory Hydra, Stytch) with zero manual pre-registration or DCR onboarding bottlenecks.Key Architecture & Features
1. Multi-Provider JIT Bridge (
src/auth/jit/)JitBridgeController (jit-bridge.ts):GET /oauth/v2/authorize): Intercepts authorization requests with CIMD URLclient_id, auto-provisions or resolves the client in the upstream IdP, maps RFC 8707resourceto IdPaudience, and issues a302 Redirectto the IdP login screen.POST /oauth/v2/token): Proxies authorization code and refresh token exchanges, translating dynamic CIMD identifiers to upstream IdP credentials across JSON,application/x-www-form-urlencoded, andAuthorization: Basic <base64>formats.src/auth/jit/adapters/):Auth0JitAdapter: Manages Auth0 Management API M2M client provisioning, dynamic SPA/Public PKCE client configuration, API scope grant attachments (cgr_*), and ephemeral desktop loopback callback merging.OktaJitAdapter: Dynamic Client Registration (DCR) and Apps API integration for Okta authorization servers.GenericDcrJitAdapter: Universal RFC 7591 Dynamic Client Registration adapter for Zitadel, Keycloak, and Ory Hydra.PassthroughJitAdapter: Native CIMD passthrough for providers with built-in CIMD support (Stytch).2. CIMD Resolvers & SSRF Security (
src/auth/cimd.ts)127.0.0.1,10.0.0.0/8,192.168.0.0/16,172.16.0.0/12, cloud metadata169.254.169.254).validateRedirectUriWithCimd()matching against authorizedredirect_uris.3. Server-Side Discovery Gateway & Transports (
src/core/oauth-module.ts,transports/)authorization_serverin/.well-known/oauth-protected-resourceand path-scoped/.well-known/oauth-protected-resource/mcp./oauth/v2/authorizeand/oauth/v2/tokenin/.well-known/oauth-authorization-serverand/.well-known/openid-configuration.express.urlencoded({ extended: true })inHttpServerTransportandStreamableHttpTransportfor RFC 6749 form-encoded token exchanges.Verification & Testing
src/auth/jit/__tests__/jit-bridge.test.ts(12/12 tests passing).src/auth/__tests__/cimd-jit.test.ts(14/14 tests passing).@nitrostack/core.