Table of Contents

Interface IOpenIddictAuthorizationManager

Namespace
OpenIddict.Abstractions
Assembly
OpenIddict.Abstractions.dll

Provides methods allowing to manage the authorizations stored in the store. Note: this interface is not meant to be implemented by custom managers, that should inherit from the generic OpenIddictAuthorizationManager class. It is primarily intended to be used by services that cannot easily depend on the generic authorization manager. The actual authorization entity type is automatically determined at runtime based on the OpenIddict core options.

public interface IOpenIddictAuthorizationManager

Methods

CountAsync(CancellationToken)

Determines the number of authorizations that exist in the database.

ValueTask<long> CountAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<long>

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

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

Determines the number of authorizations that match the specified query.

ValueTask<long> CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)

Parameters

query Func<IQueryable<object>, IQueryable<TResult>>

The query to execute.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<long>

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

Type Parameters

TResult

The result type.

CreateAsync(OpenIddictAuthorizationDescriptor, CancellationToken)

Creates a new authorization based on the specified descriptor.

ValueTask<object> CreateAsync(OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)

Parameters

descriptor OpenIddictAuthorizationDescriptor

The authorization descriptor.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<object>

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

CreateAsync(object, CancellationToken)

Creates a new authorization.

ValueTask CreateAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The application to create.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

CreateAsync(ClaimsIdentity, string, string, string, ImmutableArray<string>, CancellationToken)

Creates a new permanent authorization based on the specified parameters.

ValueTask<object> CreateAsync(ClaimsIdentity identity, string subject, string client, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = default)

Parameters

identity ClaimsIdentity

The identity associated with the authorization.

subject string

The subject associated with the authorization.

client string

The client associated with the authorization.

type string

The authorization type.

scopes ImmutableArray<string>

The minimal scopes associated with the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<object>

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

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

Creates a new permanent authorization based on the specified parameters.

ValueTask<object> CreateAsync(ClaimsPrincipal principal, string subject, string client, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = default)

Parameters

principal ClaimsPrincipal

The principal associated with the authorization.

subject string

The subject associated with the authorization.

client string

The client associated with the authorization.

type string

The authorization type.

scopes ImmutableArray<string>

The minimal scopes associated with the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<object>

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

DeleteAsync(object, CancellationToken)

Removes an existing authorization.

ValueTask DeleteAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization to delete.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

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

Retrieves the authorizations matching the specified parameters.

IAsyncEnumerable<object> FindAsync(string subject, string client, string status, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = default)

Parameters

subject string

The subject associated with the authorization.

client string

The client associated with the authorization.

status string

The authorization status.

type string

The authorization type.

scopes ImmutableArray<string>

The minimal scopes associated with the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<object>

The authorizations corresponding to the criteria.

FindAsync(string, string, string, string, CancellationToken)

Retrieves the authorizations matching the specified parameters.

IAsyncEnumerable<object> FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken = default)

Parameters

subject string

The subject associated with the authorization.

client string

The client associated with the authorization.

status string

The authorization status.

type string

The authorization type.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<object>

The authorizations corresponding to the criteria.

FindAsync(string, string, string, CancellationToken)

Retrieves the authorizations matching the specified parameters.

IAsyncEnumerable<object> FindAsync(string subject, string client, string status, CancellationToken cancellationToken = default)

Parameters

subject string

The subject associated with the authorization.

client string

The client associated with the authorization.

status string

The authorization status.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<object>

The authorizations corresponding to the criteria.

FindAsync(string, string, CancellationToken)

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

IAsyncEnumerable<object> FindAsync(string subject, string client, CancellationToken cancellationToken = default)

Parameters

subject string

The subject associated with the authorization.

client string

The client associated with the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<object>

The authorizations corresponding to the subject/client.

FindByApplicationIdAsync(string, CancellationToken)

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

IAsyncEnumerable<object> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken = default)

Parameters

identifier string

The application identifier associated with the authorizations.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<object>

The authorizations corresponding to the specified application.

FindByIdAsync(string, CancellationToken)

Retrieves an authorization using its unique identifier.

ValueTask<object?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default)

Parameters

identifier string

The unique identifier associated with the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<object>

A ValueTask 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.

IAsyncEnumerable<object> FindBySubjectAsync(string subject, CancellationToken cancellationToken = default)

Parameters

subject string

The subject associated with the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<object>

The authorizations corresponding to the specified subject.

GetApplicationIdAsync(object, CancellationToken)

Retrieves the optional application identifier associated with an authorization.

ValueTask<string?> GetApplicationIdAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

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

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

Executes the specified query and returns the first element.

ValueTask<TResult?> GetAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)

Parameters

query Func<IQueryable<object>, IQueryable<TResult>>

The query to execute.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<TResult>

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

Type Parameters

TResult

The result type.

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

Executes the specified query and returns the first element.

ValueTask<TResult?> GetAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken = default)

Parameters

query Func<IQueryable<object>, TState, IQueryable<TResult>>

The query to execute.

state TState

The optional state.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<TResult>

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

Type Parameters

TState

The state type.

TResult

The result type.

GetCreationDateAsync(object, CancellationToken)

Retrieves the creation date associated with an authorization.

ValueTask<DateTimeOffset?> GetCreationDateAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<DateTimeOffset?>

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

GetIdAsync(object, CancellationToken)

Retrieves the unique identifier associated with an authorization.

ValueTask<string?> GetIdAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

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

GetPropertiesAsync(object, CancellationToken)

Retrieves the additional properties associated with an authorization.

ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<ImmutableDictionary<string, JsonElement>>

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

GetScopesAsync(object, CancellationToken)

Retrieves the scopes associated with an authorization.

ValueTask<ImmutableArray<string>> GetScopesAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<ImmutableArray<string>>

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

GetStatusAsync(object, CancellationToken)

Retrieves the status associated with an authorization.

ValueTask<string?> GetStatusAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

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

GetSubjectAsync(object, CancellationToken)

Retrieves the subject associated with an authorization.

ValueTask<string?> GetSubjectAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

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

GetTypeAsync(object, CancellationToken)

Retrieves the type associated with an authorization.

ValueTask<string?> GetTypeAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

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

HasScopesAsync(object, ImmutableArray<string>, CancellationToken)

Determines whether the specified scopes are included in the authorization.

ValueTask<bool> HasScopesAsync(object authorization, ImmutableArray<string> scopes, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

scopes ImmutableArray<string>

The scopes.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<bool>

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

HasStatusAsync(object, string, CancellationToken)

Determines whether a given authorization has the specified status.

ValueTask<bool> HasStatusAsync(object authorization, string status, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

status string

The expected status.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<bool>

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

HasTypeAsync(object, string, CancellationToken)

Determines whether a given authorization has the specified type.

ValueTask<bool> HasTypeAsync(object authorization, string type, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

type string

The expected type.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<bool>

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

ListAsync(int?, int?, CancellationToken)

Executes the specified query and returns all the corresponding elements.

IAsyncEnumerable<object> ListAsync(int? count = null, int? offset = null, CancellationToken cancellationToken = default)

Parameters

count int?

The number of results to return.

offset int?

The number of results to skip.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<object>

All the elements returned when executing the specified query.

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

Executes the specified query and returns all the corresponding elements.

IAsyncEnumerable<TResult> ListAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)

Parameters

query Func<IQueryable<object>, IQueryable<TResult>>

The query to execute.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TResult>

All the elements returned when executing the specified query.

Type Parameters

TResult

The result type.

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

Executes the specified query and returns all the corresponding elements.

IAsyncEnumerable<TResult> ListAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken = default)

Parameters

query Func<IQueryable<object>, TState, IQueryable<TResult>>

The query to execute.

state TState

The optional state.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TResult>

All the elements returned when executing the specified query.

Type Parameters

TState

The state type.

TResult

The result type.

PopulateAsync(OpenIddictAuthorizationDescriptor, object, CancellationToken)

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

ValueTask PopulateAsync(OpenIddictAuthorizationDescriptor descriptor, object authorization, CancellationToken cancellationToken = default)

Parameters

descriptor OpenIddictAuthorizationDescriptor

The descriptor.

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

PopulateAsync(object, OpenIddictAuthorizationDescriptor, CancellationToken)

Populates the authorization using the specified descriptor.

ValueTask PopulateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

descriptor OpenIddictAuthorizationDescriptor

The descriptor.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask 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.

ValueTask<long> PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken = default)

Parameters

threshold DateTimeOffset

The date before which authorizations are not pruned.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<long>

The number of authorizations that were removed.

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(object, CancellationToken)

Tries to revoke an authorization.

ValueTask<bool> TryRevokeAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization to revoke.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<bool>

true if the authorization was successfully revoked, false otherwise.

UpdateAsync(object, OpenIddictAuthorizationDescriptor, CancellationToken)

Updates an existing authorization.

ValueTask UpdateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization to update.

descriptor OpenIddictAuthorizationDescriptor

The descriptor used to update the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

UpdateAsync(object, CancellationToken)

Updates an existing authorization.

ValueTask UpdateAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization to update.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

ValidateAsync(object, CancellationToken)

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

IAsyncEnumerable<ValidationResult> ValidateAsync(object authorization, CancellationToken cancellationToken = default)

Parameters

authorization object

The authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<ValidationResult>

The validation error encountered when validating the authorization.