Table of Contents

Interface IOpenIddictAuthorizationStore<TAuthorization>

Namespace
OpenIddict.Abstractions
Assembly
OpenIddict.Abstractions.dll

Provides methods allowing to manage the authorizations stored in a database.

public interface IOpenIddictAuthorizationStore<TAuthorization> where TAuthorization : class

Type Parameters

TAuthorization

The type of the Authorization entity.

Methods

CountAsync(CancellationToken)

Determines the number of authorizations that exist in the database.

ValueTask<long> CountAsync(CancellationToken cancellationToken)

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<TAuthorization>, IQueryable<TResult>>, CancellationToken)

Determines the number of authorizations that match the specified query.

ValueTask<long> CountAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)

Parameters

query Func<IQueryable<TAuthorization>, 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(TAuthorization, CancellationToken)

Creates a new authorization.

ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

The authorization 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.

DeleteAsync(TAuthorization, CancellationToken)

Removes an existing authorization.

ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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<TAuthorization> FindAsync(string subject, string client, string status, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken)

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<TAuthorization>

The authorizations corresponding to the criteria.

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

Retrieves the authorizations matching the specified parameters.

IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken)

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<TAuthorization>

The authorizations corresponding to the criteria.

FindAsync(string, string, string, CancellationToken)

Retrieves the authorizations matching the specified parameters.

IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, string status, CancellationToken cancellationToken)

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<TAuthorization>

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<TAuthorization> FindAsync(string subject, string client, CancellationToken cancellationToken)

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<TAuthorization>

The authorizations corresponding to the subject/client.

FindByApplicationIdAsync(string, CancellationToken)

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

IAsyncEnumerable<TAuthorization> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken)

Parameters

identifier string

The application identifier associated with the authorizations.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TAuthorization>

The authorizations corresponding to the specified application.

FindByIdAsync(string, CancellationToken)

Retrieves an authorization using its unique identifier.

ValueTask<TAuthorization?> FindByIdAsync(string identifier, CancellationToken cancellationToken)

Parameters

identifier string

The unique identifier associated with the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<TAuthorization>

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<TAuthorization> FindBySubjectAsync(string subject, CancellationToken cancellationToken)

Parameters

subject string

The subject associated with the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TAuthorization>

The authorizations corresponding to the specified subject.

GetApplicationIdAsync(TAuthorization, CancellationToken)

Retrieves the optional application identifier associated with an authorization.

ValueTask<string?> GetApplicationIdAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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<TState, TResult>(Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>>, TState, CancellationToken)

Executes the specified query and returns the first element.

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

Parameters

query Func<IQueryable<TAuthorization>, 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(TAuthorization, CancellationToken)

Retrieves the creation date associated with an authorization.

ValueTask<DateTimeOffset?> GetCreationDateAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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

Retrieves the unique identifier associated with an authorization.

ValueTask<string?> GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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

Retrieves the additional properties associated with an authorization.

ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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

Retrieves the scopes associated with an authorization.

ValueTask<ImmutableArray<string>> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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

Retrieves the status associated with an authorization.

ValueTask<string?> GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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

Retrieves the subject associated with an authorization.

ValueTask<string?> GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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

Retrieves the type associated with an authorization.

ValueTask<string?> GetTypeAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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.

InstantiateAsync(CancellationToken)

Instantiates a new authorization.

ValueTask<TAuthorization> InstantiateAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<TAuthorization>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the instantiated authorization, that can be persisted in the database.

ListAsync(int?, int?, CancellationToken)

Executes the specified query and returns all the corresponding elements.

IAsyncEnumerable<TAuthorization> ListAsync(int? count, int? offset, CancellationToken cancellationToken)

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<TAuthorization>

All the elements returned when executing the specified query.

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

Executes the specified query and returns all the corresponding elements.

IAsyncEnumerable<TResult> ListAsync<TState, TResult>(Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)

Parameters

query Func<IQueryable<TAuthorization>, 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.

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)

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.

SetApplicationIdAsync(TAuthorization, string?, CancellationToken)

Sets the application identifier associated with an authorization.

ValueTask SetApplicationIdAsync(TAuthorization authorization, string? identifier, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

The authorization.

identifier string

The unique identifier associated with the client application.

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.

SetCreationDateAsync(TAuthorization, DateTimeOffset?, CancellationToken)

Sets the creation date associated with an authorization.

ValueTask SetCreationDateAsync(TAuthorization authorization, DateTimeOffset? date, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

The authorization.

date DateTimeOffset?

The expiration date.

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.

SetPropertiesAsync(TAuthorization, ImmutableDictionary<string, JsonElement>, CancellationToken)

Sets the additional properties associated with an authorization.

ValueTask SetPropertiesAsync(TAuthorization authorization, ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

The authorization.

properties ImmutableDictionary<string, JsonElement>

The additional properties associated with 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.

SetScopesAsync(TAuthorization, ImmutableArray<string>, CancellationToken)

Sets the scopes associated with an authorization.

ValueTask SetScopesAsync(TAuthorization authorization, ImmutableArray<string> scopes, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

The authorization.

scopes ImmutableArray<string>

The scopes associated with 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.

SetStatusAsync(TAuthorization, string?, CancellationToken)

Sets the status associated with an authorization.

ValueTask SetStatusAsync(TAuthorization authorization, string? status, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

The authorization.

status string

The status associated with 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.

SetSubjectAsync(TAuthorization, string?, CancellationToken)

Sets the subject associated with an authorization.

ValueTask SetSubjectAsync(TAuthorization authorization, string? subject, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

The authorization.

subject string

The subject associated with 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.

SetTypeAsync(TAuthorization, string?, CancellationToken)

Sets the type associated with an authorization.

ValueTask SetTypeAsync(TAuthorization authorization, string? type, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

The authorization.

type string

The type associated with 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(TAuthorization, CancellationToken)

Updates an existing authorization.

ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken)

Parameters

authorization TAuthorization

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.