Given that we're mainly using Auth0 currently, and that we'd likely need to use Auth0's Auth & Management APIs in any project that uses Auth0 I've reworked the Infrastructure.Identity architecture.
We will now have a dedicated folder/namespace in there for each identity provider we add. Only Auth0 for now.
Added Auth0 API clients with optional ServiceCollectionExtensions methods for adding them to DI
Added a ManagementApiClientFactory, used internally when adding the ManagementApiClient to DI
The ManagementApiClient is added as a Transient service using a factory method. Each time the service is injected a new instance of the client will be created, but the token we fetch for use with those instances will be cached for its lifetime and refreshed automatically. There's a built-in 30-minute grace and, since the services are transient no one instance should exist for longer than that.
Each identity provider we add will manage its own IOptions configuration.
Given that we're mainly using Auth0 currently, and that we'd likely need to use Auth0's Auth & Management APIs in any project that uses Auth0 I've reworked the
Infrastructure.Identity
architecture.ServiceCollectionExtensions
methods for adding them to DIManagementApiClientFactory
, used internally when adding theManagementApiClient
to DI TheManagementApiClient
is added as a Transient service using a factory method. Each time the service is injected a new instance of the client will be created, but the token we fetch for use with those instances will be cached for its lifetime and refreshed automatically. There's a built-in 30-minute grace and, since the services are transient no one instance should exist for longer than that.IOptions
configuration.