Table of Contents

Class AppPrincipalTransform

Namespace
Arc4u.OAuth2
Assembly
Arc4u.OAuth2.AspNetCore.dll

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

applicationContext IApplicationContext

The scoped application context that receives the principal.

claimProfileFiller IClaimProfileFiller

The filler that builds the user profile from the claims.

claimAuthorizationFiller IClaimAuthorizationFiller

The filler that builds the authorization from the claims.

serviceProvider IServiceProvider

The service provider, used to resolve the claims filler and the cache key generator when extra claims are loaded.

options IOptions<ClaimsFillerOptions>

The claims filler options.

cacheHelper ICacheHelper

The helper giving access to the token cache.

activitySourceFactory IActivitySourceFactory

The factory of the activity source used for telemetry.

tokenCacheOptions IOptions<TokenCacheOptions>

The token cache options, giving the lifetime of the cached claims.

logger ILogger<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

principal ClaimsPrincipal

The principal to transform.

Returns

Task<ClaimsPrincipal>

The AppPrincipal built from the identity of principal.

Exceptions

ArgumentNullException

principal is null.

ArgumentException

The principal has no identity.