Class AppPrincipalTransform
Transform a ClaimsPrincipal to a AppPrincipal. This needs to be injected with a scoped lifetime, because it relies on an IApplicationContext, which is also scoped.
[Export(typeof(IClaimsTransformation))]
[Scoped]
public class AppPrincipalTransform : IClaimsTransformation
- Inheritance
-
AppPrincipalTransform
- Implements
- Inherited Members
Constructors
AppPrincipalTransform(IApplicationContext, IClaimProfileFiller, IClaimAuthorizationFiller, IServiceProvider, IOptions<ClaimsFillerOptions>, ICacheHelper, IActivitySourceFactory, IOptions<TokenCacheOptions>, ILogger<AppPrincipalTransform>)
Initializes a new instance of the AppPrincipalTransform class.
public AppPrincipalTransform(IApplicationContext applicationContext, IClaimProfileFiller claimProfileFiller, IClaimAuthorizationFiller claimAuthorizationFiller, IServiceProvider serviceProvider, IOptions<ClaimsFillerOptions> options, ICacheHelper cacheHelper, IActivitySourceFactory activitySourceFactory, IOptions<TokenCacheOptions> tokenCacheOptions, ILogger<AppPrincipalTransform> logger)
Parameters
applicationContextIApplicationContextThe scoped application context that receives the principal.
claimProfileFillerIClaimProfileFillerThe filler that builds the user profile from the claims.
claimAuthorizationFillerIClaimAuthorizationFillerThe filler that builds the authorization from the claims.
serviceProviderIServiceProviderThe service provider, used to resolve the claims filler and the cache key generator when extra claims are loaded.
optionsIOptions<ClaimsFillerOptions>The claims filler options.
cacheHelperICacheHelperThe helper giving access to the token cache.
activitySourceFactoryIActivitySourceFactoryThe factory of the activity source used for telemetry.
tokenCacheOptionsIOptions<TokenCacheOptions>The token cache options, giving the lifetime of the cached claims.
loggerILogger<AppPrincipalTransform>The logger.
Methods
TransformAsync(ClaimsPrincipal)
Builds an AppPrincipal from the principal and stores it in the IApplicationContext. When LoadClaimsFromClaimsFillerProvider is enabled, the extra claims are first loaded from the cache or from the registered IClaimsFiller and added to the identity, except those listed in ClaimsToExclude.
public Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
Parameters
principalClaimsPrincipalThe principal to transform.
Returns
- Task<ClaimsPrincipal>
The AppPrincipal built from the identity of
principal.
Exceptions
- ArgumentNullException
principalis null.- ArgumentException
The principal has no identity.