feat: Add Multiple Custom Domains (MCD) support#106
Open
kishore7snehil wants to merge 4 commits intomainfrom
Open
feat: Add Multiple Custom Domains (MCD) support#106kishore7snehil wants to merge 4 commits intomainfrom
kishore7snehil wants to merge 4 commits intomainfrom
Conversation
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 scenarios🔄 Compatibility
** Backward Compatible** - No breaking changes for existing users.
Existing Usage (Unchanged)
New Usage (Optional)
📊 Testing
Unit Tests
14 MCD-specific tests in
TestMCDSupportcovering URL building, login/callback/logout routes, and dependency injection.Manual Integration Testing
Prerequisites:
auth.acme.comandauth.globex.com)/etc/hosts:Setup:
Configure two custom domains in your Auth0 tenant (Settings → Custom Domains)
Register callback URLs in the application:
http://acme.myapp.com:3000/auth/callbackhttp://globex.myapp.com:3000/auth/callbackCreate a FastAPI app with MCD:
python server.pyTest cases:
http://acme.myapp.com:3000/auth/loginauth.acme.com/authorizehttp://globex.myapp.com:3000/auth/loginauth.globex.com/authorizeauth.acme.comhttp://globex.myapp.com:3000/redirect_uriin authorize URL matches the request host, notappBaseUrlAuth0Configwithdomain="auth.acme.com"(string)📚 Documentation
examples/MultipleCustomDomains.md