Interface IOpenIddictTokenManager
- Namespace
- OpenIddict.Abstractions
- Assembly
- OpenIddict.Abstractions.dll
Provides methods allowing to manage the tokens stored in the store. Note: this interface is not meant to be implemented by custom managers, that should inherit from the generic OpenIddictTokenManager class. It is primarily intended to be used by services that cannot easily depend on the generic token manager. The actual token entity type is automatically determined at runtime based on the OpenIddict core options.
public interface IOpenIddictTokenManager
Methods
CountAsync(CancellationToken)
Determines the number of tokens that exist in the database.
ValueTask<long> CountAsync(CancellationToken cancellationToken = default)
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 tokens in the database.
CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>>, CancellationToken)
Determines the number of tokens that match the specified query.
ValueTask<long> CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Parameters
queryFunc<IQueryable<object>, 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(OpenIddictTokenDescriptor, CancellationToken)
Creates a new token based on the specified descriptor.
ValueTask<object> CreateAsync(OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
Parameters
descriptorOpenIddictTokenDescriptorThe token descriptor.
cancellationTokenCancellationTokenThe 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 token.
CreateAsync(object, CancellationToken)
Creates a new token.
ValueTask CreateAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
DeleteAsync(object, CancellationToken)
Removes an existing token.
ValueTask DeleteAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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<object> FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken = default)
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<object>
The tokens corresponding to the criteria.
FindAsync(string, string, string, CancellationToken)
Retrieves the tokens matching the specified parameters.
IAsyncEnumerable<object> FindAsync(string subject, string client, string status, CancellationToken cancellationToken = default)
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<object>
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<object> FindAsync(string subject, string client, CancellationToken cancellationToken = default)
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<object>
The tokens corresponding to the subject/client.
FindByApplicationIdAsync(string, CancellationToken)
Retrieves the list of tokens corresponding to the specified application identifier.
IAsyncEnumerable<object> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken = default)
Parameters
identifierstringThe application identifier associated with the tokens.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<object>
The tokens corresponding to the specified application.
FindByAuthorizationIdAsync(string, CancellationToken)
Retrieves the list of tokens corresponding to the specified authorization identifier.
IAsyncEnumerable<object> FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken = default)
Parameters
identifierstringThe authorization identifier associated with the tokens.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<object>
The tokens corresponding to the specified authorization.
FindByIdAsync(string, CancellationToken)
Retrieves a token using its unique identifier.
ValueTask<object?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default)
Parameters
identifierstringThe unique identifier associated with the token.
cancellationTokenCancellationTokenThe 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 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<object?> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken = default)
Parameters
identifierstringThe reference identifier associated with the tokens.
cancellationTokenCancellationTokenThe 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 tokens corresponding to the specified reference identifier.
FindBySubjectAsync(string, CancellationToken)
Retrieves the list of tokens corresponding to the specified subject.
IAsyncEnumerable<object> FindBySubjectAsync(string subject, CancellationToken cancellationToken = default)
Parameters
subjectstringThe subject associated with the tokens.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<object>
The tokens corresponding to the specified subject.
GetApplicationIdAsync(object, CancellationToken)
Retrieves the optional application identifier associated with a token.
ValueTask<string?> GetApplicationIdAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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<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
queryFunc<IQueryable<object>, IQueryable<TResult>>The query to execute.
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
TResultThe 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
queryFunc<IQueryable<object>, 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(object, CancellationToken)
Retrieves the optional authorization identifier associated with a token.
ValueTask<string?> GetAuthorizationIdAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, CancellationToken)
Retrieves the creation date associated with a token.
ValueTask<DateTimeOffset?> GetCreationDateAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, CancellationToken)
Retrieves the expiration date associated with a token.
ValueTask<DateTimeOffset?> GetExpirationDateAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, CancellationToken)
Retrieves the unique identifier associated with a token.
ValueTask<string?> GetIdAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, CancellationToken)
Retrieves the payload associated with a token.
ValueTask<string?> GetPayloadAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, CancellationToken)
Retrieves the additional properties associated with a token.
ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, CancellationToken)
Retrieves the redemption date associated with a token.
ValueTask<DateTimeOffset?> GetRedemptionDateAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, 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(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, CancellationToken)
Retrieves the status associated with a token.
ValueTask<string?> GetStatusAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, CancellationToken)
Retrieves the subject associated with a token.
ValueTask<string?> GetSubjectAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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(object, CancellationToken)
Retrieves the token type associated with a token.
ValueTask<string?> GetTypeAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe 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.
HasStatusAsync(object, string, CancellationToken)
Determines whether a given token has the specified status.
ValueTask<bool> HasStatusAsync(object token, string status, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token.
statusstringThe expected status.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
HasTypeAsync(object, ImmutableArray<string>, CancellationToken)
Determines whether a given token has any of the specified types.
ValueTask<bool> HasTypeAsync(object token, ImmutableArray<string> types, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token.
typesImmutableArray<string>The expected types.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
HasTypeAsync(object, string, CancellationToken)
Determines whether a given token has the specified type.
ValueTask<bool> HasTypeAsync(object token, string type, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token.
typestringThe expected type.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
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
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<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
queryFunc<IQueryable<object>, IQueryable<TResult>>The query to execute.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<TResult>
All the elements returned when executing the specified query.
Type Parameters
TResultThe 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
queryFunc<IQueryable<object>, 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.
PopulateAsync(OpenIddictTokenDescriptor, object, CancellationToken)
Populates the specified descriptor using the properties exposed by the token.
ValueTask PopulateAsync(OpenIddictTokenDescriptor descriptor, object token, CancellationToken cancellationToken = default)
Parameters
descriptorOpenIddictTokenDescriptorThe descriptor.
tokenobjectThe token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
PopulateAsync(object, OpenIddictTokenDescriptor, CancellationToken)
Populates the token using the specified descriptor.
ValueTask PopulateAsync(object token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token.
descriptorOpenIddictTokenDescriptorThe descriptor.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
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 = default)
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 = default)
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.
TryRedeemAsync(object, CancellationToken)
Tries to redeem a token.
ValueTask<bool> TryRedeemAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token to redeem.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
TryRejectAsync(object, CancellationToken)
Tries to reject a token.
ValueTask<bool> TryRejectAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token to reject.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
TryRevokeAsync(object, CancellationToken)
Tries to revoke a token.
ValueTask<bool> TryRevokeAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token to revoke.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
UpdateAsync(object, OpenIddictTokenDescriptor, CancellationToken)
Updates an existing token.
ValueTask UpdateAsync(object token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token to update.
descriptorOpenIddictTokenDescriptorThe descriptor used to update the token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
UpdateAsync(object, CancellationToken)
Updates an existing token.
ValueTask UpdateAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token to update.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
ValidateAsync(object, CancellationToken)
Validates the token to ensure it's in a consistent state.
IAsyncEnumerable<ValidationResult> ValidateAsync(object token, CancellationToken cancellationToken = default)
Parameters
tokenobjectThe token.
cancellationTokenCancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<ValidationResult>
The validation error encountered when validating the token.