Adds support for multiple custom domains#206
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 22 changed files in this pull request and generated 15 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| { | ||
| var httpContextAccessor = new Mock<IHttpContextAccessor>(); | ||
| var stateDataFormat = new Mock<ISecureDataFormat<AuthenticationProperties>>(); | ||
| var httpClient = new HttpClient(); |
There was a problem hiding this comment.
Disposable 'HttpClient' is created but not disposed.
Suggested change
| var httpClient = new HttpClient(); | |
| using var httpClient = new HttpClient(); |
| using var response = await client.SendAsync(req); | ||
|
|
||
| var protectedMessage2 = | ||
| new HttpRequestMessage(HttpMethod.Get, $"{TestServerBuilder.Host}/{TestServerBuilder.Protected}"); |
There was a problem hiding this comment.
Disposable 'HttpRequestMessage' is created but not disposed.
Comment on lines
+61
to
+65
| .ReturnsAsync(new HttpResponseMessage() | ||
| { | ||
| StatusCode = HttpStatusCode.OK, | ||
| Content = new StringContent("{\"access_token\":\"new_token\",\"token_type\":\"Bearer\",\"expires_in\":86400}") | ||
| }); |
There was a problem hiding this comment.
Disposable 'HttpResponseMessage' is created but not disposed.
Comment on lines
+107
to
+111
| .ReturnsAsync(new HttpResponseMessage() | ||
| { | ||
| StatusCode = HttpStatusCode.OK, | ||
| Content = new StringContent("{\"access_token\":\"new_token\",\"token_type\":\"Bearer\",\"expires_in\":86400}") | ||
| }); |
There was a problem hiding this comment.
Disposable 'HttpResponseMessage' is created but not disposed.
| nonce = queryParameters["nonce"]; | ||
| var state = queryParameters["state"]; | ||
|
|
||
| var message = new HttpRequestMessage(HttpMethod.Get, $"{TestServerBuilder.Host}/{TestServerBuilder.Callback}?state={state}&nonce={nonce}&code=123"); |
There was a problem hiding this comment.
Disposable 'HttpRequestMessage' is created but not disposed.
Suggested change
| var message = new HttpRequestMessage(HttpMethod.Get, $"{TestServerBuilder.Host}/{TestServerBuilder.Callback}?state={state}&nonce={nonce}&code=123"); | |
| using var message = new HttpRequestMessage(HttpMethod.Get, $"{TestServerBuilder.Host}/{TestServerBuilder.Callback}?state={state}&nonce={nonce}&code=123"); |
| { | ||
| var nonce = ""; | ||
| var configuration = TestConfiguration.GetConfiguration(); | ||
| var domain = configuration["Auth0:Domain"]; |
92e2635 to
ec57fb6
Compare
622f400 to
e73f01f
Compare
…ng DomainResolver
…coped OpenIdConnectConfiguration management
6dba108 to
c51ef46
Compare
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.
By submitting a PR to this repository, you agree to the terms within the Auth0 Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.
Description
This PR adds first-class support for Auth0 multiple custom domains in the ASP.NET Core Authentication SDK. It enables dynamic domain (issuer) resolution per request so that a single application instance can authenticate users against different Auth0 custom domains.
Key aspects of the implementation:
Auth0CustomDomainsOptionswith aDomainResolverdelegate.Auth0CustomDomainStartupFilterto run early in the pipeline, invoke the configuredDomainResolver, and cache the resolved domain inHttpContext.ItemsunderAuth0Constants.ResolvedDomainKey.Auth0CustomDomainsOpenIdConnectConfigurationManagerto maintain separateOpenIdConnectConfigurationinstances per resolved domain, with independent metadata-address-based caching.Auth0CustomDomainsOpenIdConnectPostConfigureOptionsto plug the custom configuration manager intoOpenIdConnectOptions, disable static issuer validation, and clearAuthorityso it is resolved dynamically.Multiple custom domains are only activated when a
DomainResolveris configured.Testing
Unit test cases added for all the new code added.
This change adds test coverage for new/changed/fixed functionality
Checklist
main