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
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 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
query
Func<IQueryable<object>, 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(OpenIddictTokenDescriptor, CancellationToken)
Creates a new token based on the specified descriptor.
ValueTask<object> CreateAsync(OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
Parameters
descriptor
OpenIddictTokenDescriptorThe token descriptor.
cancellationToken
CancellationTokenThe 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
token
objectThe token.
cancellationToken
CancellationTokenThe 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
token
objectThe 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<object> FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken = default)
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<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
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<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
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<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
identifier
stringThe application identifier associated with the tokens.
cancellationToken
CancellationTokenThe 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
identifier
stringThe authorization identifier associated with the tokens.
cancellationToken
CancellationTokenThe 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
identifier
stringThe unique identifier associated with the token.
cancellationToken
CancellationTokenThe 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
identifier
stringThe reference identifier associated with the tokens.
cancellationToken
CancellationTokenThe 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
subject
stringThe subject associated with the tokens.
cancellationToken
CancellationTokenThe 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
token
objectThe 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<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
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
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
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(object, CancellationToken)
Retrieves the optional authorization identifier associated with a token.
ValueTask<string?> GetAuthorizationIdAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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(object, CancellationToken)
Retrieves the creation date associated with a token.
ValueTask<DateTimeOffset?> GetCreationDateAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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(object, CancellationToken)
Retrieves the expiration date associated with a token.
ValueTask<DateTimeOffset?> GetExpirationDateAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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(object, CancellationToken)
Retrieves the unique identifier associated with a token.
ValueTask<string?> GetIdAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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(object, CancellationToken)
Retrieves the payload associated with a token.
ValueTask<string?> GetPayloadAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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(object, CancellationToken)
Retrieves the additional properties associated with a token.
ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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(object, CancellationToken)
Retrieves the redemption date associated with a token.
ValueTask<DateTimeOffset?> GetRedemptionDateAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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(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
token
objectThe 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(object, CancellationToken)
Retrieves the status associated with a token.
ValueTask<string?> GetStatusAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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(object, CancellationToken)
Retrieves the subject associated with a token.
ValueTask<string?> GetSubjectAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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(object, CancellationToken)
Retrieves the token type associated with a token.
ValueTask<string?> GetTypeAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe 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.
HasStatusAsync(object, string, CancellationToken)
Determines whether a given token has the specified status.
ValueTask<bool> HasStatusAsync(object token, string status, CancellationToken cancellationToken = default)
Parameters
token
objectThe token.
status
stringThe expected status.
cancellationToken
CancellationTokenThe 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
token
objectThe token.
types
ImmutableArray<string>The expected types.
cancellationToken
CancellationTokenThe 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
token
objectThe token.
type
stringThe expected type.
cancellationToken
CancellationTokenThe 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
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<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
CancellationTokenThe 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
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.
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
descriptor
OpenIddictTokenDescriptorThe descriptor.
token
objectThe token.
cancellationToken
CancellationTokenThe 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
token
objectThe token.
descriptor
OpenIddictTokenDescriptorThe descriptor.
cancellationToken
CancellationTokenThe 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
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 = default)
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.
TryRedeemAsync(object, CancellationToken)
Tries to redeem a token.
ValueTask<bool> TryRedeemAsync(object token, CancellationToken cancellationToken = default)
Parameters
token
objectThe token to redeem.
cancellationToken
CancellationTokenThe 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
token
objectThe token to reject.
cancellationToken
CancellationTokenThe 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
token
objectThe token to revoke.
cancellationToken
CancellationTokenThe 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
token
objectThe token to update.
descriptor
OpenIddictTokenDescriptorThe descriptor used to update the token.
cancellationToken
CancellationTokenThe 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
token
objectThe token to update.
cancellationToken
CancellationTokenThe 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
token
objectThe token.
cancellationToken
CancellationTokenThe CancellationToken that can be used to abort the operation.
Returns
- IAsyncEnumerable<ValidationResult>
The validation error encountered when validating the token.