feat: Add Multiple Custom Domains (MCD) support#106
Merged
kishore7snehil merged 11 commits intomainfrom Apr 8, 2026
Merged
Conversation
…structure README and fix lint issue
…n management for cross-domain logout
…on in MCD deployments
…ient and test files
nandan-bhat
approved these changes
Apr 8, 2026
Merged
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.
This PR adds Multiple Custom Domains (MCD) support to
auth0-fastapi, enabling FastAPI applications to use multiple custom domains configured on the same Auth0 tenant. This wrapper leverages the MCD implementation inauth0-server-pythonwhile handling FastAPI-specific concerns like dynamic redirect URI construction.✨ Features
1. Dynamic Domain Configuration
Callableas domain parameter inAuth0Configredirect_urifrom request host when MCD enabledExample:
2. Request Base URL Builder
x-forwarded-hostandx-forwarded-protoExample:
3. Route Handler Updates
redirect_uriwhen domain is callablereturnToURL for MCD scenarios4. Backchannel Logout (BCLO) Fixes
delete_by_logout_tokennow matches onsidORsub(per OIDC Back-Channel Logout spec). Previously required both to match, which caused sessions to be missed during logout.issis present in logout token claims, it is validated against the session's stored domain before deletion. Prevents a logout token for one custom domain from deleting sessions belonging to another domain in MCD deployments.normalize_urlUtility: Added RFC 3986 compliant URL normalization toutil/__init__.pyfor reliable issuer-to-domain comparison (scheme normalization, lowercase host, default port removal).🔄 Compatibility
Backward Compatible - No breaking changes for existing users.
Existing Usage (Unchanged)
New Usage (Optional)
📊 Testing
Unit Tests
112 tests passing (
poetry run pytest), including MCD-specific tests covering URL building, login/callback/logout routes, dependency injection, and session management.Manual Integration Testing
Prerequisites:
login.brand-1.comandlogin.brand-2.com)/etc/hosts:Setup:
Configure two custom domains in your Auth0 tenant (Settings → Custom Domains)
Register callback URLs in the application:
http://brand-1.yourapp.com:3000/auth/callbackhttp://brand-2.yourapp.com:3000/auth/callbackCreate a FastAPI app with MCD:
python server.pyTest cases:
http://brand-1.yourapp.com:3000/auth/loginlogin.brand-1.com/authorizehttp://brand-2.yourapp.com:3000/auth/loginlogin.brand-2.com/authorizelogin.brand-1.comhttp://brand-2.yourapp.com:3000/redirect_uriin authorize URL matches the request host, notappBaseUrlAuth0Configwithdomain="login.brand-1.com"(string)sidbut nosubsidis deletedsubbut nosidsubis deletedissfor domain A📚 Documentation
examples/MultipleCustomDomains.md