|
|
|
@ -11,12 +11,12 @@ using System.ComponentModel; |
|
|
|
using System.Data; |
|
|
|
using System.Data.Entity; |
|
|
|
using System.Data.Entity.Infrastructure; |
|
|
|
using System.Diagnostics.CodeAnalysis; |
|
|
|
using System.Linq; |
|
|
|
using System.Text.Encodings.Web; |
|
|
|
using System.Text.Json; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using JetBrains.Annotations; |
|
|
|
using Microsoft.Extensions.Caching.Memory; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using OpenIddict.Abstractions; |
|
|
|
@ -36,9 +36,9 @@ namespace OpenIddict.EntityFramework |
|
|
|
where TContext : DbContext |
|
|
|
{ |
|
|
|
public OpenIddictEntityFrameworkTokenStore( |
|
|
|
[NotNull] IMemoryCache cache, |
|
|
|
[NotNull] TContext context, |
|
|
|
[NotNull] IOptionsMonitor<OpenIddictEntityFrameworkOptions> options) |
|
|
|
IMemoryCache cache, |
|
|
|
TContext context, |
|
|
|
IOptionsMonitor<OpenIddictEntityFrameworkOptions> options) |
|
|
|
: base(cache, context, options) |
|
|
|
{ |
|
|
|
} |
|
|
|
@ -60,9 +60,9 @@ namespace OpenIddict.EntityFramework |
|
|
|
where TKey : IEquatable<TKey> |
|
|
|
{ |
|
|
|
public OpenIddictEntityFrameworkTokenStore( |
|
|
|
[NotNull] IMemoryCache cache, |
|
|
|
[NotNull] TContext context, |
|
|
|
[NotNull] IOptionsMonitor<OpenIddictEntityFrameworkOptions> options) |
|
|
|
IMemoryCache cache, |
|
|
|
TContext context, |
|
|
|
IOptionsMonitor<OpenIddictEntityFrameworkOptions> options) |
|
|
|
{ |
|
|
|
Cache = cache; |
|
|
|
Context = context; |
|
|
|
@ -99,28 +99,12 @@ namespace OpenIddict.EntityFramework |
|
|
|
/// </summary>
|
|
|
|
private DbSet<TToken> Tokens => Context.Set<TToken>(); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Determines the number of tokens that exist in the database.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the number of applications in the database.
|
|
|
|
/// </returns>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask<long> CountAsync(CancellationToken cancellationToken) |
|
|
|
=> await Tokens.LongCountAsync(cancellationToken); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Determines the number of tokens that match the specified query.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TResult">The result type.</typeparam>
|
|
|
|
/// <param name="query">The query to execute.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the number of tokens that match the specified query.
|
|
|
|
/// </returns>
|
|
|
|
public virtual async ValueTask<long> CountAsync<TResult>([NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask<long> CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (query == null) |
|
|
|
{ |
|
|
|
@ -130,13 +114,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return await query(Tokens).LongCountAsync(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a new token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token to create.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual async ValueTask CreateAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask CreateAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -148,13 +127,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
await Context.SaveChangesAsync(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Removes a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token to delete.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual async ValueTask DeleteAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -177,16 +151,9 @@ namespace OpenIddict.EntityFramework |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the tokens corresponding to the specified
|
|
|
|
/// subject and associated with the application identifier.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="subject">The subject associated with the token.</param>
|
|
|
|
/// <param name="client">The client associated with the token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>The tokens corresponding to the subject/client.</returns>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindAsync([NotNull] string subject, |
|
|
|
[NotNull] string client, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindAsync(string subject, |
|
|
|
string client, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(subject)) |
|
|
|
{ |
|
|
|
@ -202,22 +169,15 @@ namespace OpenIddict.EntityFramework |
|
|
|
|
|
|
|
return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) |
|
|
|
where token.Application != null && |
|
|
|
token.Application.Id.Equals(key) && |
|
|
|
token.Application.Id!.Equals(key) && |
|
|
|
token.Subject == subject |
|
|
|
select token).AsAsyncEnumerable(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the tokens matching the specified parameters.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="subject">The subject associated with the token.</param>
|
|
|
|
/// <param name="client">The client associated with the token.</param>
|
|
|
|
/// <param name="status">The token status.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>The tokens corresponding to the criteria.</returns>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindAsync( |
|
|
|
[NotNull] string subject, [NotNull] string client, |
|
|
|
[NotNull] string status, CancellationToken cancellationToken) |
|
|
|
string subject, string client, |
|
|
|
string status, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(subject)) |
|
|
|
{ |
|
|
|
@ -238,24 +198,16 @@ namespace OpenIddict.EntityFramework |
|
|
|
|
|
|
|
return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) |
|
|
|
where token.Application != null && |
|
|
|
token.Application.Id.Equals(key) && |
|
|
|
token.Application.Id!.Equals(key) && |
|
|
|
token.Subject == subject && |
|
|
|
token.Status == status |
|
|
|
select token).AsAsyncEnumerable(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the tokens matching the specified parameters.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="subject">The subject associated with the token.</param>
|
|
|
|
/// <param name="client">The client associated with the token.</param>
|
|
|
|
/// <param name="status">The token status.</param>
|
|
|
|
/// <param name="type">The token type.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>The tokens corresponding to the criteria.</returns>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindAsync( |
|
|
|
[NotNull] string subject, [NotNull] string client, |
|
|
|
[NotNull] string status, [NotNull] string type, CancellationToken cancellationToken) |
|
|
|
string subject, string client, |
|
|
|
string status, string type, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(subject)) |
|
|
|
{ |
|
|
|
@ -281,20 +233,15 @@ namespace OpenIddict.EntityFramework |
|
|
|
|
|
|
|
return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) |
|
|
|
where token.Application != null && |
|
|
|
token.Application.Id.Equals(key) && |
|
|
|
token.Application.Id!.Equals(key) && |
|
|
|
token.Subject == subject && |
|
|
|
token.Status == status && |
|
|
|
token.Type == type |
|
|
|
select token).AsAsyncEnumerable(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the list of tokens corresponding to the specified application identifier.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="identifier">The application identifier associated with the tokens.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>The tokens corresponding to the specified application.</returns>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(identifier)) |
|
|
|
{ |
|
|
|
@ -305,17 +252,12 @@ namespace OpenIddict.EntityFramework |
|
|
|
|
|
|
|
return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) |
|
|
|
where token.Application != null && |
|
|
|
token.Application.Id.Equals(key) |
|
|
|
token.Application.Id!.Equals(key) |
|
|
|
select token).AsAsyncEnumerable(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the list of tokens corresponding to the specified authorization identifier.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="identifier">The authorization identifier associated with the tokens.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>Tokens corresponding to the specified authorization.</returns>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindByAuthorizationIdAsync([NotNull] string identifier, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(identifier)) |
|
|
|
{ |
|
|
|
@ -326,20 +268,12 @@ namespace OpenIddict.EntityFramework |
|
|
|
|
|
|
|
return (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) |
|
|
|
where token.Authorization != null && |
|
|
|
token.Authorization.Id.Equals(key) |
|
|
|
token.Authorization.Id!.Equals(key) |
|
|
|
select token).AsAsyncEnumerable(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves a token using its unique identifier.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="identifier">The unique identifier associated with the token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the token corresponding to the unique identifier.
|
|
|
|
/// </returns>
|
|
|
|
public virtual async ValueTask<TToken> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask<TToken?> FindByIdAsync(string identifier, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(identifier)) |
|
|
|
{ |
|
|
|
@ -349,21 +283,12 @@ namespace OpenIddict.EntityFramework |
|
|
|
var key = ConvertIdentifierFromString(identifier); |
|
|
|
|
|
|
|
return await (from token in Tokens.Include(token => token.Application).Include(token => token.Authorization) |
|
|
|
where token.Id.Equals(key) |
|
|
|
where token.Id!.Equals(key) |
|
|
|
select token).FirstOrDefaultAsync(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the list of tokens corresponding to the specified reference identifier.
|
|
|
|
/// Note: the reference identifier may be hashed or encrypted for security reasons.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="identifier">The reference identifier associated with the tokens.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the tokens corresponding to the specified reference identifier.
|
|
|
|
/// </returns>
|
|
|
|
public virtual async ValueTask<TToken> FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask<TToken?> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(identifier)) |
|
|
|
{ |
|
|
|
@ -375,13 +300,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
select token).FirstOrDefaultAsync(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the list of tokens corresponding to the specified subject.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="subject">The subject associated with the tokens.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>The tokens corresponding to the specified subject.</returns>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual IAsyncEnumerable<TToken> FindBySubjectAsync(string subject, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(subject)) |
|
|
|
{ |
|
|
|
@ -393,16 +313,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
select token).AsAsyncEnumerable(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the optional application identifier associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the application identifier associated with the token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual async ValueTask<string> GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask<string?> GetApplicationIdAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -429,21 +341,10 @@ namespace OpenIddict.EntityFramework |
|
|
|
return ConvertIdentifierToString(token.Application.Id); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Executes the specified query and returns the first element.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TState">The state type.</typeparam>
|
|
|
|
/// <typeparam name="TResult">The result type.</typeparam>
|
|
|
|
/// <param name="query">The query to execute.</param>
|
|
|
|
/// <param name="state">The optional state.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the first element returned when executing the query.
|
|
|
|
/// </returns>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask<TResult> GetAsync<TState, TResult>( |
|
|
|
[NotNull] Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, |
|
|
|
[CanBeNull] TState state, CancellationToken cancellationToken) |
|
|
|
Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, |
|
|
|
TState state, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (query == null) |
|
|
|
{ |
|
|
|
@ -455,16 +356,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
.Include(token => token.Authorization), state).FirstOrDefaultAsync(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the optional authorization identifier associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the authorization identifier associated with the token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual async ValueTask<string> GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask<string?> GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -491,16 +384,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return ConvertIdentifierToString(token.Authorization.Id); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the creation date associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the creation date associated with the specified token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -510,16 +395,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return new ValueTask<DateTimeOffset?>(token.CreationDate); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the expiration date associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the expiration date associated with the specified token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual ValueTask<DateTimeOffset?> GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<DateTimeOffset?> GetExpirationDateAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -529,54 +406,30 @@ namespace OpenIddict.EntityFramework |
|
|
|
return new ValueTask<DateTimeOffset?>(token.ExpirationDate); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the unique identifier associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the unique identifier associated with the token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual ValueTask<string> GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<string?> GetIdAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(token)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<string>(ConvertIdentifierToString(token.Id)); |
|
|
|
return new ValueTask<string?>(ConvertIdentifierToString(token.Id)); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the payload associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the payload associated with the specified token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual ValueTask<string> GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<string?> GetPayloadAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(token)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<string>(token.Payload); |
|
|
|
return new ValueTask<string?>(token.Payload); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the additional properties associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns all the additional properties associated with the token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -602,92 +455,51 @@ namespace OpenIddict.EntityFramework |
|
|
|
return new ValueTask<ImmutableDictionary<string, JsonElement>>(properties); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 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.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the reference identifier associated with the specified token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual ValueTask<string> GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<string?> GetReferenceIdAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(token)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<string>(token.ReferenceId); |
|
|
|
return new ValueTask<string?>(token.ReferenceId); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the status associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the status associated with the specified token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual ValueTask<string> GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<string?> GetStatusAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(token)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<string>(token.Status); |
|
|
|
return new ValueTask<string?>(token.Status); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the subject associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the subject associated with the specified token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual ValueTask<string> GetSubjectAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<string?> GetSubjectAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(token)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<string>(token.Subject); |
|
|
|
return new ValueTask<string?>(token.Subject); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the token type associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the token type associated with the specified token.
|
|
|
|
/// </returns>
|
|
|
|
public virtual ValueTask<string> GetTypeAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<string?> GetTypeAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
throw new ArgumentNullException(nameof(token)); |
|
|
|
} |
|
|
|
|
|
|
|
return new ValueTask<string>(token.Type); |
|
|
|
return new ValueTask<string?>(token.Type); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Instantiates a new token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>
|
|
|
|
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
|
|
|
|
/// whose result returns the instantiated token, that can be persisted in the database.
|
|
|
|
/// </returns>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask<TToken> InstantiateAsync(CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
try |
|
|
|
@ -702,19 +514,12 @@ namespace OpenIddict.EntityFramework |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Executes the specified query and returns all the corresponding elements.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="count">The number of results to return.</param>
|
|
|
|
/// <param name="offset">The number of results to skip.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>All the elements returned when executing the specified query.</returns>
|
|
|
|
public virtual IAsyncEnumerable<TToken> ListAsync( |
|
|
|
[CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual IAsyncEnumerable<TToken> ListAsync(int? count, int? offset, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
var query = Tokens.Include(token => token.Application) |
|
|
|
.Include(token => token.Authorization) |
|
|
|
.OrderBy(token => token.Id) |
|
|
|
.OrderBy(token => token.Id!) |
|
|
|
.AsQueryable(); |
|
|
|
|
|
|
|
if (offset.HasValue) |
|
|
|
@ -730,18 +535,10 @@ namespace OpenIddict.EntityFramework |
|
|
|
return query.AsAsyncEnumerable(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Executes the specified query and returns all the corresponding elements.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TState">The state type.</typeparam>
|
|
|
|
/// <typeparam name="TResult">The result type.</typeparam>
|
|
|
|
/// <param name="query">The query to execute.</param>
|
|
|
|
/// <param name="state">The optional state.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>All the elements returned when executing the specified query.</returns>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual IAsyncEnumerable<TResult> ListAsync<TState, TResult>( |
|
|
|
[NotNull] Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, |
|
|
|
[CanBeNull] TState state, CancellationToken cancellationToken) |
|
|
|
Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, |
|
|
|
TState state, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (query == null) |
|
|
|
{ |
|
|
|
@ -753,20 +550,16 @@ namespace OpenIddict.EntityFramework |
|
|
|
.Include(token => token.Authorization), state).AsAsyncEnumerable(cancellationToken); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Removes the tokens that are marked as expired or invalid.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask PruneAsync(CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
// Note: Entity Framework 6.x doesn't support set-based deletes, which prevents removing
|
|
|
|
// entities in a single command without having to retrieve and materialize them first.
|
|
|
|
// To work around this limitation, entities are manually listed and deleted using a batch logic.
|
|
|
|
|
|
|
|
List<Exception> exceptions = null; |
|
|
|
List<Exception>? exceptions = null; |
|
|
|
|
|
|
|
DbContextTransaction CreateTransaction() |
|
|
|
DbContextTransaction? CreateTransaction() |
|
|
|
{ |
|
|
|
// Note: relational providers like Sqlite are known to lack proper support
|
|
|
|
// for repeatable read transactions. To ensure this method can be safely used
|
|
|
|
@ -830,15 +623,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the application identifier associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="identifier">The unique identifier associated with the client application.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual async ValueTask SetApplicationIdAsync([NotNull] TToken token, |
|
|
|
[CanBeNull] string identifier, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -874,15 +660,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the authorization identifier associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="identifier">The unique identifier associated with the authorization.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual async ValueTask SetAuthorizationIdAsync([NotNull] TToken token, |
|
|
|
[CanBeNull] string identifier, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -918,15 +697,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the creation date associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="date">The creation date.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual ValueTask SetCreationDateAsync([NotNull] TToken token, |
|
|
|
[CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask SetCreationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -938,15 +710,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the expiration date associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="date">The expiration date.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual ValueTask SetExpirationDateAsync([NotNull] TToken token, |
|
|
|
[CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask SetExpirationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -958,14 +723,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the payload associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="payload">The payload associated with the token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual ValueTask SetPayloadAsync([NotNull] TToken token, [CanBeNull] string payload, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask SetPayloadAsync(TToken token, string? payload, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -977,15 +736,9 @@ namespace OpenIddict.EntityFramework |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the additional properties associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="properties">The additional properties associated with the token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual ValueTask SetPropertiesAsync([NotNull] TToken token, |
|
|
|
[CanBeNull] ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask SetPropertiesAsync(TToken token, |
|
|
|
ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -1008,16 +761,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 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.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="identifier">The reference identifier associated with the token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual ValueTask SetReferenceIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask SetReferenceIdAsync(TToken token, string? identifier, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -1029,14 +774,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the status associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="status">The status associated with the authorization.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual ValueTask SetStatusAsync([NotNull] TToken token, [CanBeNull] string status, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask SetStatusAsync(TToken token, string? status, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -1048,14 +787,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the subject associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="subject">The subject associated with the token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual ValueTask SetSubjectAsync([NotNull] TToken token, [CanBeNull] string subject, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask SetSubjectAsync(TToken token, string? subject, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -1067,14 +800,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Sets the token type associated with a token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token.</param>
|
|
|
|
/// <param name="type">The token type associated with the token.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual ValueTask SetTypeAsync([NotNull] TToken token, [CanBeNull] string type, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual ValueTask SetTypeAsync(TToken token, string? type, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -1086,13 +813,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
return default; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Updates an existing token.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="token">The token to update.</param>
|
|
|
|
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
|
|
|
|
/// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
|
|
|
|
public virtual async ValueTask UpdateAsync([NotNull] TToken token, CancellationToken cancellationToken) |
|
|
|
/// <inheritdoc/>
|
|
|
|
public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken) |
|
|
|
{ |
|
|
|
if (token == null) |
|
|
|
{ |
|
|
|
@ -1126,7 +848,8 @@ namespace OpenIddict.EntityFramework |
|
|
|
/// </summary>
|
|
|
|
/// <param name="identifier">The identifier to convert.</param>
|
|
|
|
/// <returns>An instance of <typeparamref name="TKey"/> representing the provided identifier.</returns>
|
|
|
|
public virtual TKey ConvertIdentifierFromString([CanBeNull] string identifier) |
|
|
|
[return: MaybeNull] |
|
|
|
public virtual TKey ConvertIdentifierFromString(string? identifier) |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(identifier)) |
|
|
|
{ |
|
|
|
@ -1141,7 +864,7 @@ namespace OpenIddict.EntityFramework |
|
|
|
/// </summary>
|
|
|
|
/// <param name="identifier">The identifier to convert.</param>
|
|
|
|
/// <returns>A <see cref="string"/> representation of the provided identifier.</returns>
|
|
|
|
public virtual string ConvertIdentifierToString([CanBeNull] TKey identifier) |
|
|
|
public virtual string? ConvertIdentifierToString([AllowNull] TKey identifier) |
|
|
|
{ |
|
|
|
if (Equals(identifier, default(TKey))) |
|
|
|
{ |
|
|
|
|