Skip to content

Commit

Permalink
feat: allow for better endpoint validation
Browse files Browse the repository at this point in the history
  • Loading branch information
9p4 committed Feb 20, 2024
1 parent 5149cef commit d51e506
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion SSO-Auth/Api/SSOController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public SSOController(ILogger<SSOController> logger, ISessionManager sessionManag
RedirectUri = GetRequestBase(config.SchemeOverride) + $"/sso/OID/{(Request.Path.Value.Contains("/start/", StringComparison.InvariantCultureIgnoreCase) ? "redirect" : "r")}/" + provider,
Scope = string.Join(" ", scopes.Prepend("openid profile")),
};
var oidEndpointUri = new Uri(config.OidEndpoint?.Trim());
options.Policy.Discovery.AdditionalEndpointBaseAddresses.Add(oidEndpointUri.GetLeftPart(UriPartial.Authority));
options.Policy.Discovery.ValidateEndpoints = !config.DoNotValidateEndpoints; // For Google and other providers with different endpoints
options.Policy.Discovery.RequireHttps = !config.DisableHttps;
options.Policy.Discovery.ValidateIssuerName = !config.DoNotValidateIssuerName;
Expand Down Expand Up @@ -305,7 +307,9 @@ public async Task<ActionResult> OidChallenge(string provider, [FromQuery] bool i
RedirectUri = redirectUri,
Scope = string.Join(" ", config.OidScopes.Prepend("openid profile")),
};
options.Policy.Discovery.ValidateEndpoints = false; // For Google and other providers with different endpoints
var oidEndpointUri = new Uri(config.OidEndpoint?.Trim());
options.Policy.Discovery.AdditionalEndpointBaseAddresses.Add(oidEndpointUri.GetLeftPart(UriPartial.Authority));
options.Policy.Discovery.ValidateEndpoints = !config.DoNotValidateEndpoints; // For Google and other providers with different endpoints
var oidcClient = new OidcClient(options);
var state = await oidcClient.PrepareLoginAsync().ConfigureAwait(false);
StateManager.Add(state.State, new TimedAuthorizeState(state, DateTime.Now));
Expand Down

0 comments on commit d51e506

Please sign in to comment.