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
#67)

* Change to not actually resolve the IProvideIdentityDetails service, as 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 authored Oct 2, 2023
1 parent a807851 commit 722c6e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void Establish()
return Task.FromResult(details_result);
});
}

protected virtual ClientPrincipal CreateClientPrincipal()
{
return new()
Expand Down

0 comments on commit 722c6e5

Please sign in to comment.