Skip to content

feature(MCD): Add MCD support#791

Open
aks96 wants to merge 10 commits into
masterfrom
feat/multiple-custom-domains
Open

feature(MCD): Add MCD support#791
aks96 wants to merge 10 commits into
masterfrom
feat/multiple-custom-domains

Conversation

@aks96

@aks96 aks96 commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Description

This PR implements Multiple Custom Domains (MCD) support, enabling application to dynamically authenticate users against multiple Auth0 tenants or custom domains based on request context.

Changes

Dynamic Issuer Resolution: issuerBaseURL now accepts a function (context: { req }) => string | Promise in addition to a static string
Per-Issuer Metadata Caching: New IssuerManager class caches OIDC discovery metadata per issuer URL
Session-Bound Issuers: Sessions store session.issuer to ensure token refresh and logout use the correct issuer

Usage Examples

Dynamic Resolver

const { auth } = require('express-openid-connect');

const tenantConfig = {
  'tenant-a': 'https://tenant-a.us.auth0.com',
  'tenant-b': 'https://tenant-b.eu.auth0.com',
  'default': 'https://default.auth0.com',
};

app.use(auth({
  issuerBaseURL: async (context) => {
    const tenantId = context.req.query.tenant || 'default';
    return tenantConfig[tenantId];
  },
  authRequired: false,
}));

Test

Added sample test multiple-custom-domain.js.

@aks96 aks96 requested a review from a team as a code owner February 17, 2026 16:14
Comment thread examples/multiple-custom-domains.js Fixed
Comment thread examples/multiple-custom-domains.js Fixed
Comment thread examples/multiple-custom-domains.js Fixed
Comment thread examples/multiple-custom-domains.js Fixed
Comment thread examples/multiple-custom-domains.js Fixed
Comment thread examples/multiple-custom-domains.js Fixed
Comment thread lib/issuerManager.js
Comment thread lib/issuerManager.js Outdated
Comment thread lib/context.js
Comment thread lib/context.js
Comment thread lib/context.js Outdated
Comment thread lib/issuerManager.js Outdated
Comment thread test/login.tests.js
Comment thread lib/appSession.js
Comment thread lib/context.js
Comment thread lib/context.js
@aks96 aks96 requested a review from kishore7snehil February 20, 2026 05:43
Comment thread examples/multiple-custom-domains.js Outdated
Comment thread lib/issuerManager.js
Comment thread lib/context.js Outdated
Comment thread lib/context.js Outdated
Comment thread lib/context.js Outdated
Comment thread lib/context.js Outdated
@aks96 aks96 requested a review from kishore7snehil February 26, 2026 19:25
Comment thread lib/context.js
Comment thread lib/context.js Outdated
Comment thread lib/context.js
Comment thread lib/context.js
@aks96 aks96 requested a review from kishore7snehil March 5, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants