Skip to content

Commit

Permalink
Change to not actually resolve the IProvideIdentityDetails service, a…
Browse files Browse the repository at this point in the history
…s it is possibly not fully wired and ready to start up.

Instead, use the IServiceProviderIsService interface to see if IProvideIdentityDetails has been registered as a type in the service provider (which AddIdentityProvider will do, if appropriate).
  • Loading branch information
Torgeir-Hansen committed Sep 29, 2023
1 parent a807851 commit 11245d6
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ public static IServiceCollection AddIdentityProvider(this IServiceCollection ser
/// <exception cref="MultipleIdentityDetailsProvidersFound">Thrown if multiple identity details providers are found.</exception>
public static IEndpointRouteBuilder MapIdentityProvider(this IEndpointRouteBuilder endpoints, IApplicationBuilder app)
{
var identityProvider = app.ApplicationServices.GetService<IProvideIdentityDetails>();
if (identityProvider is not null)
var serviceProviderIsService = app.ApplicationServices.GetService<IServiceProviderIsService>();
if (serviceProviderIsService!.IsService(typeof(IProvideIdentityDetails)))
{
endpoints.MapGet(".aksio/me", async (HttpRequest request, HttpResponse response) =>
await app.ApplicationServices.GetService<IdentityProviderEndpoint>()!.Handler(request, response));
endpoints.MapGet(
".aksio/me",
(HttpRequest request, HttpResponse response) =>
app.ApplicationServices.GetService<IdentityProviderEndpoint>()!.Handler(request, response));
}

return endpoints;
Expand Down

0 comments on commit 11245d6

Please sign in to comment.