Show / Hide Table of Contents

Class OpenIddictExtensions

Provides extension methods to make OpenIddictRequest and OpenIddictResponse easier to work with.

Inheritance
System.Object
OpenIddictExtensions
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: OpenIddict.Abstractions
Assembly: cs.temp.dll.dll
Syntax
public static class OpenIddictExtensions

Methods

AddClaim(ClaimsIdentity, String, String)

Adds a claim to a given identity.

Declaration
public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value)
Parameters
Type Name Description
ClaimsIdentity identity

The identity.

System.String type

The type associated with the claim.

System.String value

The value associated with the claim.

Returns
Type Description
ClaimsIdentity

AddClaim(ClaimsIdentity, String, String, ImmutableArray<String>)

Adds a claim to a given identity and specify one or more destinations.

Declaration
public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, ImmutableArray<string> destinations)
Parameters
Type Name Description
ClaimsIdentity identity

The identity.

System.String type

The type associated with the claim.

System.String value

The value associated with the claim.

ImmutableArray<System.String> destinations

The destinations associated with the claim.

Returns
Type Description
ClaimsIdentity

AddClaim(ClaimsIdentity, String, String, String[])

Adds a claim to a given identity and specify one or more destinations.

Declaration
public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, params string[] destinations)
Parameters
Type Name Description
ClaimsIdentity identity

The identity.

System.String type

The type associated with the claim.

System.String value

The value associated with the claim.

System.String[] destinations

The destinations associated with the claim.

Returns
Type Description
ClaimsIdentity

Clone(ClaimsIdentity, Func<Claim, Boolean>)

Clones an identity by filtering its claims and the claims of its actor, recursively.

Declaration
public static ClaimsIdentity Clone(this ClaimsIdentity identity, Func<Claim, bool> filter)
Parameters
Type Name Description
ClaimsIdentity identity

The instance to filter.

Func<Claim, System.Boolean> filter

The delegate filtering the claims: return true to accept the claim, false to remove it.

Returns
Type Description
ClaimsIdentity

Clone(ClaimsPrincipal, Func<Claim, Boolean>)

Clones a principal by filtering its identities.

Declaration
public static ClaimsPrincipal Clone(this ClaimsPrincipal principal, Func<Claim, bool> filter)
Parameters
Type Name Description
ClaimsPrincipal principal

The instance to filter.

Func<Claim, System.Boolean> filter

The delegate filtering the claims: return true to accept the claim, false to remove it.

Returns
Type Description
ClaimsPrincipal

GetAccessTokenLifetime(ClaimsPrincipal)

Gets the access token lifetime associated with the claims principal.

Declaration
public static TimeSpan? GetAccessTokenLifetime(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.Nullable<TimeSpan>

The access token lifetime or null if the claim cannot be found.

GetAcrValues(OpenIddictRequest)

Extracts the authentication context class values from an OpenIddictRequest.

Declaration
public static ImmutableArray<string> GetAcrValues(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
ImmutableArray<System.String>

GetAudiences(ClaimsPrincipal)

Gets the audiences list stored in the claims principal.

Declaration
public static ImmutableArray<string> GetAudiences(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
ImmutableArray<System.String>

The audiences list or an empty set if the claims cannot be found.

GetAuthorizationCodeLifetime(ClaimsPrincipal)

Gets the authorization code lifetime associated with the claims principal.

Declaration
public static TimeSpan? GetAuthorizationCodeLifetime(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.Nullable<TimeSpan>

The authorization code lifetime or null if the claim cannot be found.

GetAuthorizationId(ClaimsPrincipal)

Gets the internal authorization identifier associated with the claims principal.

Declaration
public static string GetAuthorizationId(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.String

The unique identifier or null if the claim cannot be found.

GetClaim(ClaimsIdentity, String)

Gets the claim value corresponding to the given type.

Declaration
public static string GetClaim(this ClaimsIdentity identity, string type)
Parameters
Type Name Description
ClaimsIdentity identity

The identity.

System.String type

The type associated with the claim.

Returns
Type Description
System.String

The claim value.

GetClaim(ClaimsPrincipal, String)

Gets the claim value corresponding to the given type.

Declaration
public static string GetClaim(this ClaimsPrincipal principal, string type)
Parameters
Type Name Description
ClaimsPrincipal principal

The principal.

System.String type

The type associated with the claim.

Returns
Type Description
System.String

The claim value.

GetClaims(ClaimsIdentity, String)

Gets the claim values corresponding to the given type.

Declaration
public static ImmutableArray<string> GetClaims(this ClaimsIdentity identity, string type)
Parameters
Type Name Description
ClaimsIdentity identity

The identity.

System.String type

The type associated with the claims.

Returns
Type Description
ImmutableArray<System.String>

The claim values.

GetClaims(ClaimsPrincipal, String)

Gets the claim values corresponding to the given type.

Declaration
public static ImmutableArray<string> GetClaims(this ClaimsPrincipal principal, string type)
Parameters
Type Name Description
ClaimsPrincipal principal

The principal.

System.String type

The type associated with the claims.

Returns
Type Description
ImmutableArray<System.String>

The claim values.

GetCreationDate(ClaimsPrincipal)

Gets the creation date stored in the claims principal.

Declaration
public static DateTimeOffset? GetCreationDate(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.Nullable<DateTimeOffset>

The creation date or null if the claim cannot be found.

GetDestinations(Claim)

Gets the destinations associated with a claim.

Declaration
public static ImmutableArray<string> GetDestinations(this Claim claim)
Parameters
Type Name Description
Claim claim

The instance.

Returns
Type Description
ImmutableArray<System.String>

The destinations associated with the claim.

GetDestinations(ClaimsPrincipal)

Gets the destinations associated with all the claims of the given principal.

Declaration
public static ImmutableDictionary<string, string[]> GetDestinations(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The principal.

Returns
Type Description
ImmutableDictionary<System.String, System.String[]>

The destinations, returned as a flattened dictionary.

GetDeviceCodeLifetime(ClaimsPrincipal)

Gets the device code lifetime associated with the claims principal.

Declaration
public static TimeSpan? GetDeviceCodeLifetime(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.Nullable<TimeSpan>

The device code lifetime or null if the claim cannot be found.

GetExpirationDate(ClaimsPrincipal)

Gets the expiration date stored in the claims principal.

Declaration
public static DateTimeOffset? GetExpirationDate(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.Nullable<DateTimeOffset>

The expiration date or null if the claim cannot be found.

GetIdentityTokenLifetime(ClaimsPrincipal)

Gets the identity token lifetime associated with the claims principal.

Declaration
public static TimeSpan? GetIdentityTokenLifetime(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.Nullable<TimeSpan>

The identity token lifetime or null if the claim cannot be found.

GetPresenters(ClaimsPrincipal)

Gets the presenters list stored in the claims principal.

Declaration
public static ImmutableArray<string> GetPresenters(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
ImmutableArray<System.String>

The presenters list or an empty set if the claims cannot be found.

GetPrompts(OpenIddictRequest)

Extracts the prompt values from an OpenIddictRequest.

Declaration
public static ImmutableArray<string> GetPrompts(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
ImmutableArray<System.String>

GetRefreshTokenLifetime(ClaimsPrincipal)

Gets the refresh token lifetime associated with the claims principal.

Declaration
public static TimeSpan? GetRefreshTokenLifetime(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.Nullable<TimeSpan>

The refresh token lifetime or null if the claim cannot be found.

GetResources(ClaimsPrincipal)

Gets the resources list stored in the claims principal.

Declaration
public static ImmutableArray<string> GetResources(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
ImmutableArray<System.String>

The resources list or an empty set if the claims cannot be found.

GetResponseTypes(OpenIddictRequest)

Extracts the response types from an OpenIddictRequest.

Declaration
public static ImmutableArray<string> GetResponseTypes(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
ImmutableArray<System.String>

GetScopes(ClaimsPrincipal)

Gets the scopes list stored in the claims principal.

Declaration
public static ImmutableArray<string> GetScopes(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
ImmutableArray<System.String>

The scopes list or an empty set if the claim cannot be found.

GetScopes(OpenIddictRequest)

Extracts the scopes from an OpenIddictRequest.

Declaration
public static ImmutableArray<string> GetScopes(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
ImmutableArray<System.String>

GetTokenId(ClaimsPrincipal)

Gets the internal token identifier associated with the claims principal.

Declaration
public static string GetTokenId(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.String

The unique identifier or null if the claim cannot be found.

GetTokenType(ClaimsPrincipal)

Gets the token type associated with the claims principal.

Declaration
public static string GetTokenType(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.String

The token type or null if the claim cannot be found.

GetUserCodeLifetime(ClaimsPrincipal)

Gets the user code lifetime associated with the claims principal.

Declaration
public static TimeSpan? GetUserCodeLifetime(this ClaimsPrincipal principal)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

Returns
Type Description
System.Nullable<TimeSpan>

The user code lifetime or null if the claim cannot be found.

HasAcrValue(OpenIddictRequest, String)

Determines whether the requested authentication context class values contain the specified item.

Declaration
public static bool HasAcrValue(this OpenIddictRequest request, string value)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

System.String value

The component to look for in the parameter.

Returns
Type Description
System.Boolean

HasAudience(ClaimsPrincipal, String)

Determines whether the claims principal contains the given audience.

Declaration
public static bool HasAudience(this ClaimsPrincipal principal, string audience)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String audience

The audience.

Returns
Type Description
System.Boolean

true if the principal contains the given audience.

HasClaim(ClaimsIdentity, String)

Determines whether the claims identity contains at least one claim of the specified type.

Declaration
public static bool HasClaim(this ClaimsIdentity identity, string type)
Parameters
Type Name Description
ClaimsIdentity identity

The claims identity.

System.String type

The claim type.

Returns
Type Description
System.Boolean

true if the identity contains at least one claim of the specified type.

HasClaim(ClaimsPrincipal, String)

Determines whether the claims principal contains at least one claim of the specified type.

Declaration
public static bool HasClaim(this ClaimsPrincipal principal, string type)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String type

The claim type.

Returns
Type Description
System.Boolean

true if the principal contains at least one claim of the specified type.

HasDestination(Claim, String)

Determines whether the given claim contains the required destination.

Declaration
public static bool HasDestination(this Claim claim, string destination)
Parameters
Type Name Description
Claim claim

The instance.

System.String destination

The required destination.

Returns
Type Description
System.Boolean

HasPresenter(ClaimsPrincipal, String)

Determines whether the claims principal contains the given presenter.

Declaration
public static bool HasPresenter(this ClaimsPrincipal principal, string presenter)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String presenter

The presenter.

Returns
Type Description
System.Boolean

true if the principal contains the given presenter.

HasPrompt(OpenIddictRequest, String)

Determines whether the requested prompt contains the specified value.

Declaration
public static bool HasPrompt(this OpenIddictRequest request, string prompt)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

System.String prompt

The component to look for in the parameter.

Returns
Type Description
System.Boolean

HasResource(ClaimsPrincipal, String)

Determines whether the claims principal contains the given resource.

Declaration
public static bool HasResource(this ClaimsPrincipal principal, string resource)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String resource

The resource.

Returns
Type Description
System.Boolean

true if the principal contains the given resource.

HasResponseType(OpenIddictRequest, String)

Determines whether the requested response type contains the specified value.

Declaration
public static bool HasResponseType(this OpenIddictRequest request, string type)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

System.String type

The component to look for in the parameter.

Returns
Type Description
System.Boolean

HasScope(ClaimsPrincipal, String)

Determines whether the claims principal contains the given scope.

Declaration
public static bool HasScope(this ClaimsPrincipal principal, string scope)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String scope

The scope.

Returns
Type Description
System.Boolean

true if the principal contains the given scope.

HasScope(OpenIddictRequest, String)

Determines whether the requested scope contains the specified value.

Declaration
public static bool HasScope(this OpenIddictRequest request, string scope)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

System.String scope

The component to look for in the parameter.

Returns
Type Description
System.Boolean

HasTokenType(ClaimsPrincipal, String)

Determines whether the token type associated with the claims principal matches the specified type.

Declaration
public static bool HasTokenType(this ClaimsPrincipal principal, string type)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String type

The token type.

Returns
Type Description
System.Boolean

true if the token type matches the specified type.

IsAuthorizationCodeFlow(OpenIddictRequest)

Determines whether the "response_type" parameter corresponds to the authorization code flow. See http://tools.ietf.org/html/rfc6749#section-4.1.1 for more information.

Declaration
public static bool IsAuthorizationCodeFlow(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request is a code flow request, false otherwise.

IsAuthorizationCodeGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the authorization code grant. See http://tools.ietf.org/html/rfc6749#section-4.1.3 for more information.

Declaration
public static bool IsAuthorizationCodeGrantType(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request is a code grant request, false otherwise.

IsClientCredentialsGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the client credentials grant. See http://tools.ietf.org/html/rfc6749#section-4.4.2 for more information.

Declaration
public static bool IsClientCredentialsGrantType(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request is a client credentials grant request, false otherwise.

IsDeviceCodeGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the device code grant. See https://tools.ietf.org/html/rfc8628 for more information.

Declaration
public static bool IsDeviceCodeGrantType(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request is a device code grant request, false otherwise.

IsFormPostResponseMode(OpenIddictRequest)

Determines whether the "response_mode" parameter corresponds to the form post response mode. See http://openid.net/specs/oauth-v2-form-post-response-mode-1_0.html for more information.

Declaration
public static bool IsFormPostResponseMode(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request specified the form post response mode or if it's the default value for the requested flow, false otherwise.

IsFragmentResponseMode(OpenIddictRequest)

Determines whether the "response_mode" parameter corresponds to the fragment response mode. See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html for more information.

Declaration
public static bool IsFragmentResponseMode(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request specified the fragment response mode or if it's the default value for the requested flow, false otherwise.

IsHybridFlow(OpenIddictRequest)

Determines whether the "response_type" parameter corresponds to the hybrid flow. See http://tools.ietf.org/html/rfc6749#section-4.2.1 and http://openid.net/specs/openid-connect-core-1_0.html for more information.

Declaration
public static bool IsHybridFlow(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request is an hybrid flow request, false otherwise.

IsImplicitFlow(OpenIddictRequest)

Determines whether the "response_type" parameter corresponds to the implicit flow. See http://tools.ietf.org/html/rfc6749#section-4.2.1 and http://openid.net/specs/openid-connect-core-1_0.html for more information

Declaration
public static bool IsImplicitFlow(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request is an implicit flow request, false otherwise.

IsNoneFlow(OpenIddictRequest)

Determines whether the "response_type" parameter corresponds to the "none" response type. See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#none for more information.

Declaration
public static bool IsNoneFlow(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request is a response_type=none request, false otherwise.

IsPasswordGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the password grant. See http://tools.ietf.org/html/rfc6749#section-4.3.2 for more information.

Declaration
public static bool IsPasswordGrantType(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request is a password grant request, false otherwise.

IsQueryResponseMode(OpenIddictRequest)

Determines whether the "response_mode" parameter corresponds to the query response mode. See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html for more information.

Declaration
public static bool IsQueryResponseMode(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request specified the query response mode or if it's the default value for the requested flow, false otherwise.

IsRefreshTokenGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the refresh token grant. See http://tools.ietf.org/html/rfc6749#section-6 for more information.

Declaration
public static bool IsRefreshTokenGrantType(this OpenIddictRequest request)
Parameters
Type Name Description
OpenIddictRequest request

The OpenIddictRequest instance.

Returns
Type Description
System.Boolean

true if the request is a refresh token grant request, false otherwise.

RemoveClaims(ClaimsIdentity, String)

Removes all the claims corresponding to the given type.

Declaration
public static ClaimsIdentity RemoveClaims(this ClaimsIdentity identity, string type)
Parameters
Type Name Description
ClaimsIdentity identity

The identity.

System.String type

The type associated with the claims.

Returns
Type Description
ClaimsIdentity

The claims identity.

RemoveClaims(ClaimsPrincipal, String)

Removes all the claims corresponding to the given type.

Declaration
public static ClaimsPrincipal RemoveClaims(this ClaimsPrincipal principal, string type)
Parameters
Type Name Description
ClaimsPrincipal principal

The principal.

System.String type

The type associated with the claims.

Returns
Type Description
ClaimsPrincipal

The claims identity.

SetAccessTokenLifetime(ClaimsPrincipal, Nullable<TimeSpan>)

Sets the access token lifetime associated with the claims principal.

Declaration
public static ClaimsPrincipal SetAccessTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<TimeSpan> lifetime

The access token lifetime to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetAudiences(ClaimsPrincipal, ImmutableArray<String>)

Sets the audiences list in the claims principal. Note: this method automatically excludes duplicate audiences.

Declaration
public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, ImmutableArray<string> audiences)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

ImmutableArray<System.String> audiences

The audiences to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetAudiences(ClaimsPrincipal, Nullable<IEnumerable<String>>)

Sets the audiences list in the claims principal. Note: this method automatically excludes duplicate audiences.

Declaration
public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, IEnumerable<string>? audiences)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<IEnumerable<System.String>> audiences

The audiences to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetAudiences(ClaimsPrincipal, String[])

Sets the audiences list in the claims principal. Note: this method automatically excludes duplicate audiences.

Declaration
public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, params string[] audiences)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String[] audiences

The audiences to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetAuthorizationCodeLifetime(ClaimsPrincipal, Nullable<TimeSpan>)

Sets the authorization code lifetime associated with the claims principal.

Declaration
public static ClaimsPrincipal SetAuthorizationCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<TimeSpan> lifetime

The authorization code lifetime to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetAuthorizationId(ClaimsPrincipal, String)

Sets the internal authorization identifier associated with the claims principal.

Declaration
public static ClaimsPrincipal SetAuthorizationId(this ClaimsPrincipal principal, string identifier)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String identifier

The unique identifier to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetClaim(ClaimsPrincipal, String, String)

Sets the claim value corresponding to the given type.

Declaration
public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, string value)
Parameters
Type Name Description
ClaimsPrincipal principal

The principal.

System.String type

The type associated with the claims.

System.String value

The claim value.

Returns
Type Description
ClaimsPrincipal

The claims identity.

SetClaims(ClaimsIdentity, String, ImmutableArray<String>)

Sets the claim values corresponding to the given type.

Declaration
public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, ImmutableArray<string> values)
Parameters
Type Name Description
ClaimsIdentity identity

The identity.

System.String type

The type associated with the claims.

ImmutableArray<System.String> values

The claim values.

Returns
Type Description
ClaimsIdentity

The claims identity.

SetClaims(ClaimsIdentity, String, String)

Sets the claim value corresponding to the given type.

Declaration
public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, string value)
Parameters
Type Name Description
ClaimsIdentity identity

The identity.

System.String type

The type associated with the claims.

System.String value

The claim value.

Returns
Type Description
ClaimsIdentity

The claims identity.

SetClaims(ClaimsPrincipal, String, ImmutableArray<String>)

Sets the claim values corresponding to the given type.

Declaration
public static ClaimsPrincipal SetClaims(this ClaimsPrincipal principal, string type, ImmutableArray<string> values)
Parameters
Type Name Description
ClaimsPrincipal principal

The principal.

System.String type

The type associated with the claims.

ImmutableArray<System.String> values

The claim values.

Returns
Type Description
ClaimsPrincipal

The claims identity.

SetCreationDate(ClaimsPrincipal, Nullable<DateTimeOffset>)

Sets the creation date in the claims principal.

Declaration
public static ClaimsPrincipal SetCreationDate(this ClaimsPrincipal principal, DateTimeOffset? date)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<DateTimeOffset> date

The creation date

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetDestinations(Claim, ImmutableArray<String>)

Adds specific destinations to a claim.

Declaration
public static Claim SetDestinations(this Claim claim, ImmutableArray<string> destinations)
Parameters
Type Name Description
Claim claim

The instance.

ImmutableArray<System.String> destinations

The destinations.

Returns
Type Description
Claim

SetDestinations(Claim, Nullable<IEnumerable<String>>)

Adds specific destinations to a claim.

Declaration
public static Claim SetDestinations(this Claim claim, IEnumerable<string>? destinations)
Parameters
Type Name Description
Claim claim

The instance.

System.Nullable<IEnumerable<System.String>> destinations

The destinations.

Returns
Type Description
Claim

SetDestinations(Claim, String[])

Adds specific destinations to a claim.

Declaration
public static Claim SetDestinations(this Claim claim, params string[] destinations)
Parameters
Type Name Description
Claim claim

The instance.

System.String[] destinations

The destinations.

Returns
Type Description
Claim

SetDestinations(ClaimsPrincipal, ImmutableDictionary<String, String[]>)

Sets the destinations associated with all the claims of the given principal.

Declaration
public static ClaimsPrincipal SetDestinations(this ClaimsPrincipal principal, ImmutableDictionary<string, string[]> destinations)
Parameters
Type Name Description
ClaimsPrincipal principal

The principal.

ImmutableDictionary<System.String, System.String[]> destinations

The destinations, as a flattened dictionary.

Returns
Type Description
ClaimsPrincipal

The principal.

SetDeviceCodeLifetime(ClaimsPrincipal, Nullable<TimeSpan>)

Sets the device code lifetime associated with the claims principal.

Declaration
public static ClaimsPrincipal SetDeviceCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<TimeSpan> lifetime

The device code lifetime to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetExpirationDate(ClaimsPrincipal, Nullable<DateTimeOffset>)

Sets the expiration date in the claims principal.

Declaration
public static ClaimsPrincipal SetExpirationDate(this ClaimsPrincipal principal, DateTimeOffset? date)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<DateTimeOffset> date

The expiration date

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetIdentityTokenLifetime(ClaimsPrincipal, Nullable<TimeSpan>)

Sets the identity token lifetime associated with the claims principal.

Declaration
public static ClaimsPrincipal SetIdentityTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<TimeSpan> lifetime

The identity token lifetime to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetPresenters(ClaimsPrincipal, ImmutableArray<String>)

Sets the presenters list in the claims principal. Note: this method automatically excludes duplicate presenters.

Declaration
public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, ImmutableArray<string> presenters)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

ImmutableArray<System.String> presenters

The presenters to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetPresenters(ClaimsPrincipal, Nullable<IEnumerable<String>>)

Sets the presenters list in the claims principal. Note: this method automatically excludes duplicate presenters.

Declaration
public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, IEnumerable<string>? presenters)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<IEnumerable<System.String>> presenters

The presenters to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetPresenters(ClaimsPrincipal, String[])

Sets the presenters list in the claims principal. Note: this method automatically excludes duplicate presenters.

Declaration
public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, params string[] presenters)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String[] presenters

The presenters to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetRefreshTokenLifetime(ClaimsPrincipal, Nullable<TimeSpan>)

Sets the refresh token lifetime associated with the claims principal.

Declaration
public static ClaimsPrincipal SetRefreshTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<TimeSpan> lifetime

The refresh token lifetime to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetResources(ClaimsPrincipal, ImmutableArray<String>)

Sets the resources list in the claims principal. Note: this method automatically excludes duplicate resources.

Declaration
public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, ImmutableArray<string> resources)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

ImmutableArray<System.String> resources

The resources to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetResources(ClaimsPrincipal, Nullable<IEnumerable<String>>)

Sets the resources list in the claims principal. Note: this method automatically excludes duplicate resources.

Declaration
public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, IEnumerable<string>? resources)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<IEnumerable<System.String>> resources

The resources to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetResources(ClaimsPrincipal, String[])

Sets the resources list in the claims principal. Note: this method automatically excludes duplicate resources.

Declaration
public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, params string[] resources)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String[] resources

The resources to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetScopes(ClaimsPrincipal, ImmutableArray<String>)

Sets the scopes list in the claims principal. Note: this method automatically excludes duplicate scopes.

Declaration
public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, ImmutableArray<string> scopes)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

ImmutableArray<System.String> scopes

The scopes to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetScopes(ClaimsPrincipal, Nullable<IEnumerable<String>>)

Sets the scopes list in the claims principal. Note: this method automatically excludes duplicate scopes.

Declaration
public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, IEnumerable<string>? scopes)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<IEnumerable<System.String>> scopes

The scopes to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetScopes(ClaimsPrincipal, String[])

Sets the scopes list in the claims principal. Note: this method automatically excludes duplicate scopes.

Declaration
public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, params string[] scopes)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String[] scopes

The scopes to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetTokenId(ClaimsPrincipal, String)

Sets the internal token identifier associated with the claims principal.

Declaration
public static ClaimsPrincipal SetTokenId(this ClaimsPrincipal principal, string identifier)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String identifier

The unique identifier to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetTokenType(ClaimsPrincipal, String)

Sets the token type associated with the claims principal.

Declaration
public static ClaimsPrincipal SetTokenType(this ClaimsPrincipal principal, string type)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.String type

The token type to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

SetUserCodeLifetime(ClaimsPrincipal, Nullable<TimeSpan>)

Sets the user code lifetime associated with the claims principal.

Declaration
public static ClaimsPrincipal SetUserCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
Parameters
Type Name Description
ClaimsPrincipal principal

The claims principal.

System.Nullable<TimeSpan> lifetime

The user code lifetime to store.

Returns
Type Description
ClaimsPrincipal

The claims principal.

In This Article
Back to top Generated by DocFX