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
TToken
The type of the Token entity.
Methods
CountAsync(CancellationToken)
Determines the number of tokens that exist in the database.
ValueTask<long> CountAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenThe 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
query
Func<IQueryable<TToken>, IQueryable<TResult>>The query to execute.
cancellationToken
CancellationTokenThe 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
TResult
The result type.
CreateAsync(TToken, CancellationToken)
Creates a new token.
ValueTask CreateAsync(TToken token, CancellationToken cancellationToken)
Parameters
token
TTokenThe token to create.
cancellationToken
CancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
DeleteAsync(TToken, CancellationToken)
Removes a token.
ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken)
Parameters
token
TTokenThe token to delete.
cancellationToken
CancellationTokenThe 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
subject
stringThe subject associated with the token.
client
stringThe client associated with the token.
status
stringThe token status.
type
stringThe token type.
cancellationToken
CancellationTokenThe 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
subject
stringThe subject associated with the token.
client
stringThe client associated with the token.
status
stringThe token status.
cancellationToken
CancellationTokenThe 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
subject
stringThe subject associated with the token.
client
stringThe client associated with the token.
cancellationToken
CancellationTokenThe 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
identifier
stringThe application identifier associated with the tokens.
cancellationToken
CancellationTokenThe 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
identifier
stringThe authorization identifier associated with the tokens.
cancellationToken
CancellationTokenThe 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
identifier
stringThe unique identifier associated with the token.
cancellationToken
CancellationTokenThe 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
identifier
stringThe reference identifier associated with the tokens.
cancellationToken
CancellationTokenThe 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
subject
stringThe subject associated with the tokens.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
query
Func<IQueryable<TToken>, TState, IQueryable<TResult>>The query to execute.
state
TStateThe optional state.
cancellationToken
CancellationTokenThe 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.
GetAuthorizationIdAsync(TToken, CancellationToken)
Retrieves the optional authorization identifier associated with a token.
ValueTask<string?> GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken)
Parameters
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
cancellationToken
CancellationTokenThe 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
cancellationToken
CancellationTokenThe 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
count
int?The number of results to return.
offset
int?The number of results to skip.
cancellationToken
CancellationTokenThe 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
query
Func<IQueryable<TToken>, TState, IQueryable<TResult>>The query to execute.
state
TStateThe optional state.
cancellationToken
CancellationTokenThe 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 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
threshold
DateTimeOffsetThe date before which tokens are not pruned.
cancellationToken
CancellationTokenThe 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
identifier
stringThe authorization identifier associated with the tokens.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
identifier
stringThe unique identifier associated with the token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
identifier
stringThe unique identifier associated with the token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
date
DateTimeOffset?The creation date.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
date
DateTimeOffset?The expiration date.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
payload
stringThe payload associated with the token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
properties
ImmutableDictionary<string, JsonElement>The additional properties associated with the token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
date
DateTimeOffset?The redemption date.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
identifier
stringThe reference identifier associated with the token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
status
stringThe status associated with the authorization.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
subject
stringThe subject associated with the token.
cancellationToken
CancellationTokenThe 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
token
TTokenThe token.
type
stringThe token type associated with the token.
cancellationToken
CancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
UpdateAsync(TToken, CancellationToken)
Updates an existing token.
ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken)
Parameters
token
TTokenThe token to update.
cancellationToken
CancellationTokenThe CancellationToken that can be used to abort the operation.