Interface IOpenIddictTokenStore<TToken>
- Namespace
- OpenIddict.Abstractions
- Assembly
- OpenIddict.Abstractions.dll
Provides methods allowing to manage the tokens stored in a database.
public interface IOpenIddictTokenStore<TToken> where TToken : class
Type Parameters
TTokenThe type of the Token entity.
Methods
CountAsync(CancellationToken)
Determines the number of tokens that exist in the database.
ValueTask<long> CountAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe 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 applications in the database.
CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>>, CancellationToken)
Determines the number of tokens that match the specified query.
ValueTask<long> CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
Parameters
queryFunc<IQueryable<TToken>, IQueryable<TResult>>The query to execute.
cancellationTokenCancellationTokenThe 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 tokens that match the specified query.
Type Parameters
TResultThe result type.
CreateAsync(TToken, CancellationToken)
Creates a new token.
ValueTask CreateAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token to create.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
DeleteAsync(TToken, CancellationToken)
Removes a token.
ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token to delete.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
FindAsync(string, string, string, string, CancellationToken)
Retrieves the tokens matching the specified parameters.
IAsyncEnumerable<TToken> FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken)
Parameters
subjectstringThe subject associated with the token.
clientstringThe client associated with the token.
statusstringThe token status.
typestringThe token type.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<TToken>
The tokens corresponding to the criteria.
FindAsync(string, string, string, CancellationToken)
Retrieves the tokens matching the specified parameters.
IAsyncEnumerable<TToken> FindAsync(string subject, string client, string status, CancellationToken cancellationToken)
Parameters
subjectstringThe subject associated with the token.
clientstringThe client associated with the token.
statusstringThe token status.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<TToken>
The tokens corresponding to the criteria.
FindAsync(string, string, CancellationToken)
Retrieves the tokens corresponding to the specified subject and associated with the application identifier.
IAsyncEnumerable<TToken> FindAsync(string subject, string client, CancellationToken cancellationToken)
Parameters
subjectstringThe subject associated with the token.
clientstringThe client associated with the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<TToken>
The tokens corresponding to the subject/client.
FindByApplicationIdAsync(string, CancellationToken)
Retrieves the list of tokens corresponding to the specified application identifier.
IAsyncEnumerable<TToken> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken)
Parameters
identifierstringThe application identifier associated with the tokens.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<TToken>
The tokens corresponding to the specified application.
FindByAuthorizationIdAsync(string, CancellationToken)
Retrieves the list of tokens corresponding to the specified authorization identifier.
IAsyncEnumerable<TToken> FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken)
Parameters
identifierstringThe authorization identifier associated with the tokens.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<TToken>
The tokens corresponding to the specified authorization.
FindByIdAsync(string, CancellationToken)
Retrieves a token using its unique identifier.
ValueTask<TToken?> FindByIdAsync(string identifier, CancellationToken cancellationToken)
Parameters
identifierstringThe unique identifier associated with the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- ValueTask<TToken>
A ValueTask that can be used to monitor the asynchronous operation, whose result returns the token corresponding to the unique identifier.
FindByReferenceIdAsync(string, CancellationToken)
Retrieves the list of tokens corresponding to the specified reference identifier. Note: the reference identifier may be hashed or encrypted for security reasons.
ValueTask<TToken?> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken)
Parameters
identifierstringThe reference identifier associated with the tokens.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- ValueTask<TToken>
A ValueTask that can be used to monitor the asynchronous operation, whose result returns the tokens corresponding to the specified reference identifier.
FindBySubjectAsync(string, CancellationToken)
Retrieves the list of tokens corresponding to the specified subject.
IAsyncEnumerable<TToken> FindBySubjectAsync(string subject, CancellationToken cancellationToken)
Parameters
subjectstringThe subject associated with the tokens.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<TToken>
The tokens corresponding to the specified subject.
GetApplicationIdAsync(TToken, CancellationToken)
Retrieves the optional application identifier associated with a token.
ValueTask<string?> GetApplicationIdAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 token.
GetAsync<TState, TResult>(Func<IQueryable<TToken>, TState, IQueryable<TResult>>, TState, CancellationToken)
Executes the specified query and returns the first element.
ValueTask<TResult?> GetAsync<TState, TResult>(Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
Parameters
queryFunc<IQueryable<TToken>, TState, IQueryable<TResult>>The query to execute.
stateTStateThe optional state.
cancellationTokenCancellationTokenThe 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
TStateThe state type.
TResultThe result type.
GetAuthorizationIdAsync(TToken, CancellationToken)
Retrieves the optional authorization identifier associated with a token.
ValueTask<string?> GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 authorization identifier associated with the token.
GetCreationDateAsync(TToken, CancellationToken)
Retrieves the creation date associated with a token.
ValueTask<DateTimeOffset?> GetCreationDateAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 token.
GetExpirationDateAsync(TToken, CancellationToken)
Retrieves the expiration date associated with a token.
ValueTask<DateTimeOffset?> GetExpirationDateAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 expiration date associated with the specified token.
GetIdAsync(TToken, CancellationToken)
Retrieves the unique identifier associated with a token.
ValueTask<string?> GetIdAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 token.
GetPayloadAsync(TToken, CancellationToken)
Retrieves the payload associated with a token.
ValueTask<string?> GetPayloadAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 payload associated with the specified token.
GetPropertiesAsync(TToken, CancellationToken)
Retrieves the additional properties associated with a token.
ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 token.
GetRedemptionDateAsync(TToken, CancellationToken)
Retrieves the redemption date associated with a token.
ValueTask<DateTimeOffset?> GetRedemptionDateAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 redemption date associated with the specified token.
GetReferenceIdAsync(TToken, CancellationToken)
Retrieves the reference identifier associated with a token. Note: depending on the manager used to create the token, the reference identifier may be hashed for security reasons.
ValueTask<string?> GetReferenceIdAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 reference identifier associated with the specified token.
GetStatusAsync(TToken, CancellationToken)
Retrieves the status associated with a token.
ValueTask<string?> GetStatusAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 token.
GetSubjectAsync(TToken, CancellationToken)
Retrieves the subject associated with a token.
ValueTask<string?> GetSubjectAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 token.
GetTypeAsync(TToken, CancellationToken)
Retrieves the token type associated with a token.
ValueTask<string?> GetTypeAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
cancellationTokenCancellationTokenThe 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 token type associated with the specified token.
InstantiateAsync(CancellationToken)
Instantiates a new token.
ValueTask<TToken> InstantiateAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- ValueTask<TToken>
A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the instantiated token, that can be persisted in the database.
ListAsync(int?, int?, CancellationToken)
Executes the specified query and returns all the corresponding elements.
IAsyncEnumerable<TToken> ListAsync(int? count, int? offset, CancellationToken cancellationToken)
Parameters
countint?The number of results to return.
offsetint?The number of results to skip.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<TToken>
All the elements returned when executing the specified query.
ListAsync<TState, TResult>(Func<IQueryable<TToken>, TState, IQueryable<TResult>>, TState, CancellationToken)
Executes the specified query and returns all the corresponding elements.
IAsyncEnumerable<TResult> ListAsync<TState, TResult>(Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
Parameters
queryFunc<IQueryable<TToken>, TState, IQueryable<TResult>>The query to execute.
stateTStateThe optional state.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<TResult>
All the elements returned when executing the specified query.
Type Parameters
TStateThe state type.
TResultThe result type.
PruneAsync(DateTimeOffset, CancellationToken)
Removes the tokens that are marked as invalid or whose attached authorization is no longer valid.
Only tokens created before the specified threshold are removed.
ValueTask<long> PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken)
Parameters
thresholdDateTimeOffsetThe date before which tokens are not pruned.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
RevokeByAuthorizationIdAsync(string, CancellationToken)
Revokes all the tokens associated with the specified authorization identifier.
ValueTask<long> RevokeByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken)
Parameters
identifierstringThe authorization identifier associated with the tokens.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- ValueTask<long>
The number of tokens associated with the specified authorization that were marked as revoked.
SetApplicationIdAsync(TToken, string?, CancellationToken)
Sets the application identifier associated with a token.
ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
identifierstringThe unique identifier associated with the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetAuthorizationIdAsync(TToken, string?, CancellationToken)
Sets the authorization identifier associated with a token.
ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
identifierstringThe unique identifier associated with the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetCreationDateAsync(TToken, DateTimeOffset?, CancellationToken)
Sets the creation date associated with a token.
ValueTask SetCreationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
dateDateTimeOffset?The creation date.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetExpirationDateAsync(TToken, DateTimeOffset?, CancellationToken)
Sets the expiration date associated with a token.
ValueTask SetExpirationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
dateDateTimeOffset?The expiration date.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetPayloadAsync(TToken, string?, CancellationToken)
Sets the payload associated with a token.
ValueTask SetPayloadAsync(TToken token, string? payload, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
payloadstringThe payload associated with the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetPropertiesAsync(TToken, ImmutableDictionary<string, JsonElement>, CancellationToken)
Sets the additional properties associated with a token.
ValueTask SetPropertiesAsync(TToken token, ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
propertiesImmutableDictionary<string, JsonElement>The additional properties associated with the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetRedemptionDateAsync(TToken, DateTimeOffset?, CancellationToken)
Sets the redemption date associated with a token.
ValueTask SetRedemptionDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
dateDateTimeOffset?The redemption date.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetReferenceIdAsync(TToken, string?, CancellationToken)
Sets the reference identifier associated with a token. Note: depending on the manager used to create the token, the reference identifier may be hashed for security reasons.
ValueTask SetReferenceIdAsync(TToken token, string? identifier, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
identifierstringThe reference identifier associated with the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetStatusAsync(TToken, string?, CancellationToken)
Sets the status associated with a token.
ValueTask SetStatusAsync(TToken token, string? status, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
statusstringThe status associated with the authorization.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetSubjectAsync(TToken, string?, CancellationToken)
Sets the subject associated with a token.
ValueTask SetSubjectAsync(TToken token, string? subject, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
subjectstringThe subject associated with the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
SetTypeAsync(TToken, string?, CancellationToken)
Sets the token type associated with a token.
ValueTask SetTypeAsync(TToken token, string? type, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token.
typestringThe token type associated with the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
UpdateAsync(TToken, CancellationToken)
Updates an existing token.
ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken)
Parameters
tokenTTokenThe token to update.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.