Interface IOpenIddictAuthorizationManager
Provides methods allowing to manage the authorizations stored in the store. Note: this interface is not meant to be implemented by custom managers, that should inherit from the generic OpenIddictAuthorizationManager class. It is primarily intended to be used by services that cannot easily depend on the generic authorization manager. The actual authorization entity type is automatically determined at runtime based on the OpenIddict core options.
Namespace: OpenIddict.Abstractions
Assembly: cs.temp.dll.dll
Syntax
public interface IOpenIddictAuthorizationManager
Methods
CountAsync(CancellationToken)
Determines the number of authorizations that exist in the database.
Declaration
ValueTask<long> CountAsync(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Int64> | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation, whose result returns the number of authorizations in the database. |
CountAsync<TResult>(Func<IQueryable<Object>, IQueryable<TResult>>, CancellationToken)
Determines the number of authorizations that match the specified query.
Declaration
ValueTask<long> CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IQueryable<System.Object>, IQueryable<TResult>> | query | The query to execute. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Int64> | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation, whose result returns the number of authorizations that match the specified query. |
Type Parameters
Name | Description |
---|---|
TResult | The result type. |
CreateAsync(ClaimsPrincipal, String, String, String, ImmutableArray<String>, CancellationToken)
Creates a new permanent authorization based on the specified parameters.
Declaration
ValueTask<object> CreateAsync(ClaimsPrincipal principal, string subject, string client, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
ClaimsPrincipal | principal | The principal associated with the authorization. |
System.String | subject | The subject associated with the authorization. |
System.String | client | The client associated with the authorization. |
System.String | type | The authorization type. |
ImmutableArray<System.String> | scopes | The minimal scopes associated with the authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Object> | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation, whose result returns the authorization. |
CreateAsync(OpenIddictAuthorizationDescriptor, CancellationToken)
Creates a new authorization based on the specified descriptor.
Declaration
ValueTask<object> CreateAsync(OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
OpenIddictAuthorizationDescriptor | descriptor | The authorization descriptor. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Object> | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation, whose result returns the authorization. |
CreateAsync(Object, CancellationToken)
Creates a new authorization.
Declaration
ValueTask CreateAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The application to create. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation. |
DeleteAsync(Object, CancellationToken)
Removes an existing authorization.
Declaration
ValueTask DeleteAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization to delete. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation. |
FindAsync(String, String, CancellationToken)
Retrieves the authorizations corresponding to the specified subject and associated with the application identifier.
Declaration
IAsyncEnumerable<object> FindAsync(string subject, string client, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | subject | The subject associated with the authorization. |
System.String | client | The client associated with the authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<System.Object> | The authorizations corresponding to the subject/client. |
FindAsync(String, String, String, CancellationToken)
Retrieves the authorizations matching the specified parameters.
Declaration
IAsyncEnumerable<object> FindAsync(string subject, string client, string status, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | subject | The subject associated with the authorization. |
System.String | client | The client associated with the authorization. |
System.String | status | The authorization status. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<System.Object> | The authorizations corresponding to the criteria. |
FindAsync(String, String, String, String, CancellationToken)
Retrieves the authorizations matching the specified parameters.
Declaration
IAsyncEnumerable<object> FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | subject | The subject associated with the authorization. |
System.String | client | The client associated with the authorization. |
System.String | status | The authorization status. |
System.String | type | The authorization type. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<System.Object> | The authorizations corresponding to the criteria. |
FindAsync(String, String, String, String, ImmutableArray<String>, CancellationToken)
Retrieves the authorizations matching the specified parameters.
Declaration
IAsyncEnumerable<object> FindAsync(string subject, string client, string status, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | subject | The subject associated with the authorization. |
System.String | client | The client associated with the authorization. |
System.String | status | The authorization status. |
System.String | type | The authorization type. |
ImmutableArray<System.String> | scopes | The minimal scopes associated with the authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<System.Object> | The authorizations corresponding to the criteria. |
FindByApplicationIdAsync(String, CancellationToken)
Retrieves the list of authorizations corresponding to the specified application identifier.
Declaration
IAsyncEnumerable<object> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The application identifier associated with the authorizations. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<System.Object> | The authorizations corresponding to the specified application. |
FindByIdAsync(String, CancellationToken)
Retrieves an authorization using its unique identifier.
Declaration
ValueTask<object> FindByIdAsync(string identifier, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | identifier | The unique identifier associated with the authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Object> | A System.Threading.Tasks.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.
Declaration
IAsyncEnumerable<object> FindBySubjectAsync(string subject, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | subject | The subject associated with the authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<System.Object> | The authorizations corresponding to the specified subject. |
GetApplicationIdAsync(Object, CancellationToken)
Retrieves the optional application identifier associated with an authorization.
Declaration
ValueTask<string> GetApplicationIdAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.String> | A System.Threading.Tasks.ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the application identifier associated with the authorization. |
GetAsync<TResult>(Func<IQueryable<Object>, IQueryable<TResult>>, CancellationToken)
Executes the specified query and returns the first element.
Declaration
ValueTask<TResult> GetAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IQueryable<System.Object>, IQueryable<TResult>> | query | The query to execute. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<TResult> | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation, whose result returns the first element returned when executing the query. |
Type Parameters
Name | Description |
---|---|
TResult | The result type. |
GetAsync<TState, TResult>(Func<IQueryable<Object>, TState, IQueryable<TResult>>, TState, CancellationToken)
Executes the specified query and returns the first element.
Declaration
ValueTask<TResult> GetAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IQueryable<System.Object>, TState, IQueryable<TResult>> | query | The query to execute. |
TState | state | The optional state. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<TResult> | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation, whose result returns the first element returned when executing the query. |
Type Parameters
Name | Description |
---|---|
TState | The state type. |
TResult | The result type. |
GetCreationDateAsync(Object, CancellationToken)
Retrieves the creation date associated with an authorization.
Declaration
ValueTask<DateTimeOffset?> GetCreationDateAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Nullable<System.DateTimeOffset>> | A System.Threading.Tasks.ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the creation date associated with the specified authorization. |
GetIdAsync(Object, CancellationToken)
Retrieves the unique identifier associated with an authorization.
Declaration
ValueTask<string> GetIdAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.String> | A System.Threading.Tasks.ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the unique identifier associated with the authorization. |
GetPropertiesAsync(Object, CancellationToken)
Retrieves the additional properties associated with an authorization.
Declaration
ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<ImmutableDictionary<System.String, JsonElement>> | A System.Threading.Tasks.ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns all the additional properties associated with the authorization. |
GetScopesAsync(Object, CancellationToken)
Retrieves the scopes associated with an authorization.
Declaration
ValueTask<ImmutableArray<string>> GetScopesAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<ImmutableArray<System.String>> | A System.Threading.Tasks.ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the scopes associated with the specified authorization. |
GetStatusAsync(Object, CancellationToken)
Retrieves the status associated with an authorization.
Declaration
ValueTask<string> GetStatusAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.String> | A System.Threading.Tasks.ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the status associated with the specified authorization. |
GetSubjectAsync(Object, CancellationToken)
Retrieves the subject associated with an authorization.
Declaration
ValueTask<string> GetSubjectAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.String> | A System.Threading.Tasks.ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the subject associated with the specified authorization. |
GetTypeAsync(Object, CancellationToken)
Retrieves the type associated with an authorization.
Declaration
ValueTask<string> GetTypeAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.String> | A System.Threading.Tasks.ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the type associated with the specified authorization. |
HasScopesAsync(Object, ImmutableArray<String>, CancellationToken)
Determines whether the specified scopes are included in the authorization.
Declaration
ValueTask<bool> HasScopesAsync(object authorization, ImmutableArray<string> scopes, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
ImmutableArray<System.String> | scopes | The scopes. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Boolean> |
|
HasStatusAsync(Object, String, CancellationToken)
Determines whether a given authorization has the specified status.
Declaration
ValueTask<bool> HasStatusAsync(object authorization, string status, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
System.String | status | The expected status. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Boolean> |
|
HasTypeAsync(Object, String, CancellationToken)
Determines whether a given authorization has the specified type.
Declaration
ValueTask<bool> HasTypeAsync(object authorization, string type, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
System.String | type | The expected type. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Boolean> |
|
ListAsync(Nullable<Int32>, Nullable<Int32>, CancellationToken)
Executes the specified query and returns all the corresponding elements.
Declaration
IAsyncEnumerable<object> ListAsync(int? count = default(int? ), int? offset = default(int? ), CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Int32> | count | The number of results to return. |
System.Nullable<System.Int32> | offset | The number of results to skip. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<System.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.
Declaration
IAsyncEnumerable<TResult> ListAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IQueryable<System.Object>, IQueryable<TResult>> | query | The query to execute. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<TResult> | All the elements returned when executing the specified query. |
Type Parameters
Name | Description |
---|---|
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.
Declaration
IAsyncEnumerable<TResult> ListAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IQueryable<System.Object>, TState, IQueryable<TResult>> | query | The query to execute. |
TState | state | The optional state. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<TResult> | All the elements returned when executing the specified query. |
Type Parameters
Name | Description |
---|---|
TState | The state type. |
TResult | The result type. |
PopulateAsync(OpenIddictAuthorizationDescriptor, Object, CancellationToken)
Populates the specified descriptor using the properties exposed by the authorization.
Declaration
ValueTask PopulateAsync(OpenIddictAuthorizationDescriptor descriptor, object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
OpenIddictAuthorizationDescriptor | descriptor | The descriptor. |
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation. |
PopulateAsync(Object, OpenIddictAuthorizationDescriptor, CancellationToken)
Populates the authorization using the specified descriptor.
Declaration
ValueTask PopulateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
OpenIddictAuthorizationDescriptor | descriptor | The descriptor. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation. |
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.
Declaration
ValueTask PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.DateTimeOffset | threshold | The date before which authorizations are not pruned. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation. |
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.
TryRevokeAsync(Object, CancellationToken)
Tries to revoke an authorization.
Declaration
ValueTask<bool> TryRevokeAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization to revoke. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask<System.Boolean> |
|
UpdateAsync(Object, CancellationToken)
Updates an existing authorization.
Declaration
ValueTask UpdateAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization to update. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation. |
UpdateAsync(Object, OpenIddictAuthorizationDescriptor, CancellationToken)
Updates an existing authorization.
Declaration
ValueTask UpdateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization to update. |
OpenIddictAuthorizationDescriptor | descriptor | The descriptor used to update the authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Threading.Tasks.ValueTask | A System.Threading.Tasks.ValueTask that can be used to monitor the asynchronous operation. |
ValidateAsync(Object, CancellationToken)
Validates the authorization to ensure it's in a consistent state.
Declaration
IAsyncEnumerable<ValidationResult> ValidateAsync(object authorization, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | authorization | The authorization. |
CancellationToken | cancellationToken | The |
Returns
Type | Description |
---|---|
System.Collections.Generic.IAsyncEnumerable<ValidationResult> | The validation error encountered when validating the authorization. |