Show / Hide Table of Contents

Class OpenIddictAuthorizationManager<TAuthorization>

Provides methods allowing to manage the authorizations stored in the store.

Inheritance
System.Object
OpenIddictAuthorizationManager<TAuthorization>
Namespace: OpenIddict.Core
Assembly: cs.temp.dll.dll
Syntax
public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthorizationManager where TAuthorization : class
Type Parameters
Name Description
TAuthorization

The type of the Authorization entity.

Remarks

Applications that do not want to depend on a specific entity type can use the non-generic instead, for which the actual entity type is resolved at runtime based on the default entity type registered in the core options.

Constructors

OpenIddictAuthorizationManager(IOpenIddictAuthorizationCache<TAuthorization>, ILogger<OpenIddictAuthorizationManager<TAuthorization>>, IOptionsMonitor<OpenIddictCoreOptions>, IOpenIddictAuthorizationStoreResolver)

Declaration
public OpenIddictAuthorizationManager(IOpenIddictAuthorizationCache<TAuthorization> cache, ILogger<OpenIddictAuthorizationManager<TAuthorization>> logger, IOptionsMonitor<OpenIddictCoreOptions> options, IOpenIddictAuthorizationStoreResolver resolver)
Parameters
Type Name Description
IOpenIddictAuthorizationCache<TAuthorization> cache
ILogger<OpenIddictAuthorizationManager<TAuthorization>> logger
IOptionsMonitor<OpenIddictCoreOptions> options
IOpenIddictAuthorizationStoreResolver resolver

Properties

Cache

Gets the cache associated with the current manager.

Declaration
protected IOpenIddictAuthorizationCache<TAuthorization> Cache { get; }
Property Value
Type Description
IOpenIddictAuthorizationCache<TAuthorization>

Logger

Gets the logger associated with the current manager.

Declaration
protected ILogger Logger { get; }
Property Value
Type Description
ILogger

Options

Gets the options associated with the current manager.

Declaration
protected IOptionsMonitor<OpenIddictCoreOptions> Options { get; }
Property Value
Type Description
IOptionsMonitor<OpenIddictCoreOptions>

Store

Gets the store associated with the current manager.

Declaration
protected IOpenIddictAuthorizationStore<TAuthorization> Store { get; }
Property Value
Type Description
IOpenIddictAuthorizationStore<TAuthorization>

Methods

CountAsync(CancellationToken)

Determines the number of authorizations that exist in the database.

Declaration
public virtual ValueTask<long> CountAsync(CancellationToken cancellationToken = null)
Parameters
Type Name Description
CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.Int64>

A that can be used to monitor the asynchronous operation, whose result returns the number of authorizations in the database.

CountAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>>, CancellationToken)

Determines the number of authorizations that match the specified query.

Declaration
public virtual ValueTask<long> CountAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = null)
Parameters
Type Name Description
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query

The query to execute.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.Int64>

A that can be used to monitor the asynchronous operation, whose result returns the number of authorizations that match the specified query.

Type Parameters
Name Description
TResult

The result type.

CreateAsync(TAuthorization, CancellationToken)

Creates a new authorization.

Declaration
public virtual ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The application to create.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask

A that can be used to monitor the asynchronous operation.

CreateAsync(ClaimsPrincipal, String, String, String, ImmutableArray<String>, CancellationToken)

Creates a new permanent authorization based on the specified parameters.

Declaration
public virtual ValueTask<TAuthorization> CreateAsync(ClaimsPrincipal principal, string subject, string client, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = null)
Parameters
Type Name Description
ClaimsPrincipal principal

The principal associated with the authorization.

System.String subject

The subject associated with the authorization.

System.String client

The client associated with the authorization.

System.String type

The authorization type.

ImmutableArray<System.String> scopes

The minimal scopes associated with the authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<TAuthorization>

A that can be used to monitor the asynchronous operation, whose result returns the authorization.

CreateAsync(OpenIddictAuthorizationDescriptor, CancellationToken)

Creates a new authorization based on the specified descriptor.

Declaration
public virtual ValueTask<TAuthorization> CreateAsync(OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = null)
Parameters
Type Name Description
OpenIddictAuthorizationDescriptor descriptor

The authorization descriptor.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<TAuthorization>

A that can be used to monitor the asynchronous operation, whose result returns the authorization.

DeleteAsync(TAuthorization, CancellationToken)

Removes an existing authorization.

Declaration
public virtual ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization to delete.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask

A that can be used to monitor the asynchronous operation.

FindAsync(String, String, CancellationToken)

Retrieves the authorizations corresponding to the specified subject and associated with the application identifier.

Declaration
public virtual IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String subject

The subject associated with the authorization.

System.String client

The client associated with the authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<TAuthorization>

The authorizations corresponding to the subject/client.

FindAsync(String, String, String, CancellationToken)

Retrieves the authorizations matching the specified parameters.

Declaration
public virtual IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, string status, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String subject

The subject associated with the authorization.

System.String client

The client associated with the authorization.

System.String status

The authorization status.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<TAuthorization>

The authorizations corresponding to the criteria.

FindAsync(String, String, String, String, CancellationToken)

Retrieves the authorizations matching the specified parameters.

Declaration
public virtual IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String subject

The subject associated with the authorization.

System.String client

The client associated with the authorization.

System.String status

The authorization status.

System.String type

The authorization type.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<TAuthorization>

The authorizations corresponding to the criteria.

FindAsync(String, String, String, String, ImmutableArray<String>, CancellationToken)

Retrieves the authorizations matching the specified parameters.

Declaration
public virtual IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, string status, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String subject

The subject associated with the authorization.

System.String client

The client associated with the authorization.

System.String status

The authorization status.

System.String type

The authorization type.

ImmutableArray<System.String> scopes

The minimal scopes associated with the authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<TAuthorization>

The authorizations corresponding to the criteria.

FindByApplicationIdAsync(String, CancellationToken)

Retrieves the list of authorizations corresponding to the specified application identifier.

Declaration
public virtual IAsyncEnumerable<TAuthorization> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String identifier

The application identifier associated with the authorizations.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<TAuthorization>

The authorizations corresponding to the specified application.

FindByIdAsync(String, CancellationToken)

Retrieves an authorization using its unique identifier.

Declaration
public virtual ValueTask<TAuthorization> FindByIdAsync(string identifier, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String identifier

The unique identifier associated with the authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<TAuthorization>

A that can be used to monitor the asynchronous operation, whose result returns the authorization corresponding to the identifier.

FindBySubjectAsync(String, CancellationToken)

Retrieves all the authorizations corresponding to the specified subject.

Declaration
public virtual IAsyncEnumerable<TAuthorization> FindBySubjectAsync(string subject, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String subject

The subject associated with the authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<TAuthorization>

The authorizations corresponding to the specified subject.

GetApplicationIdAsync(TAuthorization, CancellationToken)

Retrieves the optional application identifier associated with an authorization.

Declaration
public virtual ValueTask<string> GetApplicationIdAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.String>

A that can be used to monitor the asynchronous operation, whose result returns the application identifier associated with the authorization.

GetAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>>, CancellationToken)

Executes the specified query and returns the first element.

Declaration
public virtual ValueTask<TResult> GetAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = null)
Parameters
Type Name Description
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query

The query to execute.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<TResult>

A that can be used to monitor the asynchronous operation, whose result returns the first element returned when executing the query.

Type Parameters
Name Description
TResult

The result type.

GetAsync<TState, TResult>(Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>>, TState, CancellationToken)

Executes the specified query and returns the first element.

Declaration
public virtual ValueTask<TResult> GetAsync<TState, TResult>(Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken = null)
Parameters
Type Name Description
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query

The query to execute.

TState state

The optional state.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<TResult>

A that can be used to monitor the asynchronous operation, whose result returns the first element returned when executing the query.

Type Parameters
Name Description
TState

The state type.

TResult

The result type.

GetCreationDateAsync(TAuthorization, CancellationToken)

Retrieves the creation date associated with an authorization.

Declaration
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.Nullable<DateTimeOffset>>

A that can be used to monitor the asynchronous operation, whose result returns the creation date associated with the specified authorization.

GetIdAsync(TAuthorization, CancellationToken)

Retrieves the unique identifier associated with an authorization.

Declaration
public virtual ValueTask<string> GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.String>

A that can be used to monitor the asynchronous operation, whose result returns the unique identifier associated with the authorization.

GetPropertiesAsync(TAuthorization, CancellationToken)

Retrieves the additional properties associated with an authorization.

Declaration
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<ImmutableDictionary<System.String, JsonElement>>

A that can be used to monitor the asynchronous operation, whose result returns all the additional properties associated with the authorization.

GetScopesAsync(TAuthorization, CancellationToken)

Retrieves the scopes associated with an authorization.

Declaration
public virtual ValueTask<ImmutableArray<string>> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<ImmutableArray<System.String>>

A that can be used to monitor the asynchronous operation, whose result returns the scopes associated with the specified authorization.

GetStatusAsync(TAuthorization, CancellationToken)

Retrieves the status associated with an authorization.

Declaration
public virtual ValueTask<string> GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.String>

A that can be used to monitor the asynchronous operation, whose result returns the status associated with the specified authorization.

GetSubjectAsync(TAuthorization, CancellationToken)

Retrieves the subject associated with an authorization.

Declaration
public virtual ValueTask<string> GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.String>

A that can be used to monitor the asynchronous operation, whose result returns the subject associated with the specified authorization.

GetTypeAsync(TAuthorization, CancellationToken)

Retrieves the type associated with an authorization.

Declaration
public virtual ValueTask<string> GetTypeAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.String>

A that can be used to monitor the asynchronous operation, whose result returns the type associated with the specified authorization.

HasScopesAsync(TAuthorization, ImmutableArray<String>, CancellationToken)

Determines whether the specified scopes are included in the authorization.

Declaration
public virtual ValueTask<bool> HasScopesAsync(TAuthorization authorization, ImmutableArray<string> scopes, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

ImmutableArray<System.String> scopes

The scopes.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.Boolean>

true if the scopes are included in the authorization, false otherwise.

HasStatusAsync(TAuthorization, String, CancellationToken)

Determines whether a given authorization has the specified status.

Declaration
public virtual ValueTask<bool> HasStatusAsync(TAuthorization authorization, string status, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

System.String status

The expected status.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.Boolean>

true if the authorization has the specified status, false otherwise.

HasTypeAsync(TAuthorization, String, CancellationToken)

Determines whether a given authorization has the specified type.

Declaration
public virtual ValueTask<bool> HasTypeAsync(TAuthorization authorization, string type, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

System.String type

The expected type.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.Boolean>

true if the authorization has the specified type, false otherwise.

ListAsync(Nullable<Int32>, Nullable<Int32>, CancellationToken)

Executes the specified query and returns all the corresponding elements.

Declaration
public virtual IAsyncEnumerable<TAuthorization> ListAsync(int? count = default(int? ), int? offset = default(int? ), CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.Nullable<System.Int32> count

The number of results to return.

System.Nullable<System.Int32> offset

The number of results to skip.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<TAuthorization>

All the elements returned when executing the specified query.

ListAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>>, CancellationToken)

Executes the specified query and returns all the corresponding elements.

Declaration
public virtual IAsyncEnumerable<TResult> ListAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = null)
Parameters
Type Name Description
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query

The query to execute.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<TResult>

All the elements returned when executing the specified query.

Type Parameters
Name Description
TResult

The result type.

ListAsync<TState, TResult>(Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>>, TState, CancellationToken)

Executes the specified query and returns all the corresponding elements.

Declaration
public virtual IAsyncEnumerable<TResult> ListAsync<TState, TResult>(Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken = null)
Parameters
Type Name Description
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query

The query to execute.

TState state

The optional state.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<TResult>

All the elements returned when executing the specified query.

Type Parameters
Name Description
TState

The state type.

TResult

The result type.

PopulateAsync(TAuthorization, OpenIddictAuthorizationDescriptor, CancellationToken)

Populates the authorization using the specified descriptor.

Declaration
public virtual ValueTask PopulateAsync(TAuthorization authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

OpenIddictAuthorizationDescriptor descriptor

The descriptor.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask

A that can be used to monitor the asynchronous operation.

PopulateAsync(OpenIddictAuthorizationDescriptor, TAuthorization, CancellationToken)

Populates the specified descriptor using the properties exposed by the authorization.

Declaration
public virtual ValueTask PopulateAsync(OpenIddictAuthorizationDescriptor descriptor, TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
OpenIddictAuthorizationDescriptor descriptor

The descriptor.

TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask

A that can be used to monitor the asynchronous operation.

PruneAsync(DateTimeOffset, CancellationToken)

Removes the authorizations that are marked as invalid and the ad-hoc ones that have no token attached. Only authorizations created before the specified threshold are removed.

Declaration
public virtual ValueTask PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken = null)
Parameters
Type Name Description
DateTimeOffset threshold

The date before which authorizations are not pruned.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask

A that can be used to monitor the asynchronous operation.

Remarks

To ensure ad-hoc authorizations that no longer have any valid/non-expired token attached are correctly removed, the tokens should always be pruned first.

TryRevokeAsync(TAuthorization, CancellationToken)

Tries to revoke an authorization.

Declaration
public virtual ValueTask<bool> TryRevokeAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization to revoke.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask<System.Boolean>

true if the authorization was successfully revoked, false otherwise.

UpdateAsync(TAuthorization, CancellationToken)

Updates an existing authorization.

Declaration
public virtual ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization to update.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask

A that can be used to monitor the asynchronous operation.

UpdateAsync(TAuthorization, OpenIddictAuthorizationDescriptor, CancellationToken)

Updates an existing authorization.

Declaration
public virtual ValueTask UpdateAsync(TAuthorization authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization to update.

OpenIddictAuthorizationDescriptor descriptor

The descriptor used to update the authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
ValueTask

A that can be used to monitor the asynchronous operation.

ValidateAsync(TAuthorization, CancellationToken)

Validates the authorization to ensure it's in a consistent state.

Declaration
public virtual IAsyncEnumerable<ValidationResult> ValidateAsync(TAuthorization authorization, CancellationToken cancellationToken = null)
Parameters
Type Name Description
TAuthorization authorization

The authorization.

CancellationToken cancellationToken

The that can be used to abort the operation.

Returns
Type Description
IAsyncEnumerable<ValidationResult>

The validation error encountered when validating the authorization.

In This Article
Back to top Generated by DocFX