Browse Source

Add nullable annotations to OpenIddict.Core

pull/1038/head
Kévin Chalet 6 years ago
parent
commit
7a6e123734
  1. 96
      src/OpenIddict.Core/Caches/OpenIddictApplicationCache.cs
  2. 130
      src/OpenIddict.Core/Caches/OpenIddictAuthorizationCache.cs
  3. 94
      src/OpenIddict.Core/Caches/OpenIddictScopeCache.cs
  4. 145
      src/OpenIddict.Core/Caches/OpenIddictTokenCache.cs
  5. 185
      src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
  6. 154
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  7. 134
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  8. 183
      src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
  9. 1
      src/OpenIddict.Core/OpenIddict.Core.csproj
  10. 45
      src/OpenIddict.Core/OpenIddictCoreBuilder.cs
  11. 7
      src/OpenIddict.Core/OpenIddictCoreExtensions.cs
  12. 8
      src/OpenIddict.Core/OpenIddictCoreOptions.cs
  13. 3
      src/OpenIddict.Core/Resolvers/OpenIddictApplicationStoreResolver.cs
  14. 3
      src/OpenIddict.Core/Resolvers/OpenIddictAuthorizationStoreResolver.cs
  15. 3
      src/OpenIddict.Core/Resolvers/OpenIddictScopeStoreResolver.cs
  16. 3
      src/OpenIddict.Core/Resolvers/OpenIddictTokenStoreResolver.cs

96
src/OpenIddict.Core/Caches/OpenIddictApplicationCache.cs

@ -11,7 +11,6 @@ using System.Collections.Immutable;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
@ -31,8 +30,8 @@ namespace OpenIddict.Core
private readonly IOpenIddictApplicationStore<TApplication> _store;
public OpenIddictApplicationCache(
[NotNull] IOptionsMonitor<OpenIddictCoreOptions> options,
[NotNull] IOpenIddictApplicationStoreResolver resolver)
IOptionsMonitor<OpenIddictCoreOptions> options,
IOpenIddictApplicationStoreResolver resolver)
{
_cache = new MemoryCache(new MemoryCacheOptions
{
@ -43,13 +42,8 @@ namespace OpenIddict.Core
_store = resolver.Get<TApplication>();
}
/// <summary>
/// Add the specified application to the cache.
/// </summary>
/// <param name="application">The application to add to the cache.</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 async ValueTask AddAsync([NotNull] TApplication application, CancellationToken cancellationToken)
/// <inheritdoc/>
public async ValueTask AddAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
@ -99,9 +93,7 @@ namespace OpenIddict.Core
}, application, cancellationToken);
}
/// <summary>
/// Disposes the resources held by this instance.
/// </summary>
/// <inheritdoc/>
public void Dispose()
{
foreach (var signal in _signals)
@ -112,16 +104,8 @@ namespace OpenIddict.Core
_cache.Dispose();
}
/// <summary>
/// Retrieves an application using its client identifier.
/// </summary>
/// <param name="identifier">The client identifier associated with the application.</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 client application corresponding to the identifier.
/// </returns>
public ValueTask<TApplication> FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
public ValueTask<TApplication?> FindByClientIdAsync(string identifier, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(identifier))
{
@ -134,14 +118,14 @@ namespace OpenIddict.Core
Identifier = identifier
};
if (_cache.TryGetValue(parameters, out TApplication application))
if (_cache.TryGetValue(parameters, out TApplication? application))
{
return new ValueTask<TApplication>(application);
return new ValueTask<TApplication?>(application);
}
return new ValueTask<TApplication>(ExecuteAsync());
return new ValueTask<TApplication?>(ExecuteAsync());
async Task<TApplication> ExecuteAsync()
async Task<TApplication?> ExecuteAsync()
{
if ((application = await _store.FindByClientIdAsync(identifier, cancellationToken)) != null)
{
@ -154,16 +138,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves an application using its unique identifier.
/// </summary>
/// <param name="identifier">The unique identifier associated with the application.</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 client application corresponding to the identifier.
/// </returns>
public ValueTask<TApplication> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
public ValueTask<TApplication?> FindByIdAsync(string identifier, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(identifier))
{
@ -176,14 +152,14 @@ namespace OpenIddict.Core
Identifier = identifier
};
if (_cache.TryGetValue(parameters, out TApplication application))
if (_cache.TryGetValue(parameters, out TApplication? application))
{
return new ValueTask<TApplication>(application);
return new ValueTask<TApplication?>(application);
}
return new ValueTask<TApplication>(ExecuteAsync());
return new ValueTask<TApplication?>(ExecuteAsync());
async Task<TApplication> ExecuteAsync()
async Task<TApplication?> ExecuteAsync()
{
if ((application = await _store.FindByIdAsync(identifier, cancellationToken)) != null)
{
@ -196,14 +172,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves all the applications associated with the specified post_logout_redirect_uri.
/// </summary>
/// <param name="address">The post_logout_redirect_uri associated with the applications.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The client applications corresponding to the specified post_logout_redirect_uri.</returns>
public IAsyncEnumerable<TApplication> FindByPostLogoutRedirectUriAsync(
[NotNull] string address, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TApplication> FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(address))
{
@ -243,14 +213,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves all the applications associated with the specified redirect_uri.
/// </summary>
/// <param name="address">The redirect_uri associated with the applications.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The client applications corresponding to the specified redirect_uri.</returns>
public IAsyncEnumerable<TApplication> FindByRedirectUriAsync(
[NotNull] string address, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TApplication> FindByRedirectUriAsync(string address, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(address))
{
@ -290,13 +254,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Removes the specified application from the cache.
/// </summary>
/// <param name="application">The application to remove from the cache.</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 async ValueTask RemoveAsync([NotNull] TApplication application, CancellationToken cancellationToken)
/// <inheritdoc/>
public async ValueTask RemoveAsync(TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{
@ -309,7 +268,7 @@ namespace OpenIddict.Core
throw new InvalidOperationException(SR.GetResourceString(SR.ID1195));
}
if (_signals.TryRemove(identifier, out CancellationTokenSource signal))
if (_signals.TryRemove(identifier, out CancellationTokenSource? signal))
{
signal.Cancel();
signal.Dispose();
@ -323,8 +282,7 @@ namespace OpenIddict.Core
/// <param name="application">The application to store in the cache entry, if applicable.</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>
protected virtual async ValueTask CreateEntryAsync(
[NotNull] object key, [CanBeNull] TApplication application, CancellationToken cancellationToken)
protected virtual async ValueTask CreateEntryAsync(object key, TApplication? application, CancellationToken cancellationToken)
{
if (key == null)
{
@ -356,7 +314,7 @@ namespace OpenIddict.Core
/// <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>
protected virtual async ValueTask CreateEntryAsync(
[NotNull] object key, [CanBeNull] ImmutableArray<TApplication> applications, CancellationToken cancellationToken)
object key, ImmutableArray<TApplication> applications, CancellationToken cancellationToken)
{
if (key == null)
{
@ -391,7 +349,7 @@ namespace OpenIddict.Core
/// whose result returns an expiration signal for the specified application.
/// </returns>
protected virtual async ValueTask<IChangeToken> CreateExpirationSignalAsync(
[NotNull] TApplication application, CancellationToken cancellationToken)
TApplication application, CancellationToken cancellationToken)
{
if (application == null)
{

130
src/OpenIddict.Core/Caches/OpenIddictAuthorizationCache.cs

@ -11,7 +11,6 @@ using System.Collections.Immutable;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
@ -31,8 +30,8 @@ namespace OpenIddict.Core
private readonly IOpenIddictAuthorizationStore<TAuthorization> _store;
public OpenIddictAuthorizationCache(
[NotNull] IOptionsMonitor<OpenIddictCoreOptions> options,
[NotNull] IOpenIddictAuthorizationStoreResolver resolver)
IOptionsMonitor<OpenIddictCoreOptions> options,
IOpenIddictAuthorizationStoreResolver resolver)
{
_cache = new MemoryCache(new MemoryCacheOptions
{
@ -43,14 +42,7 @@ namespace OpenIddict.Core
_store = resolver.Get<TAuthorization>();
}
/// <summary>
/// Add the specified authorization to the cache.
/// </summary>
/// <param name="authorization">The authorization to add to the cache.</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>
/// <inheritdoc/>
public async ValueTask AddAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
@ -107,9 +99,7 @@ namespace OpenIddict.Core
}, authorization, cancellationToken);
}
/// <summary>
/// Disposes the resources held by this instance.
/// </summary>
/// <inheritdoc/>
public void Dispose()
{
foreach (var signal in _signals)
@ -120,16 +110,8 @@ namespace OpenIddict.Core
_cache.Dispose();
}
/// <summary>
/// Retrieves the authorizations corresponding to the specified
/// subject and associated with the application identifier.
/// </summary>
/// <param name="subject">The subject associated with the authorization.</param>
/// <param name="client">The client associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the subject/client.</returns>
public IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(subject))
{
@ -175,17 +157,10 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves the authorizations matching the specified parameters.
/// </summary>
/// <param name="subject">The subject associated with the authorization.</param>
/// <param name="client">The client associated with the authorization.</param>
/// <param name="status">The authorization status.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the criteria.</returns>
/// <inheritdoc/>
public IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client,
[NotNull] string status, CancellationToken cancellationToken)
string subject, string client,
string status, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(subject))
{
@ -237,18 +212,10 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves the authorizations matching the specified parameters.
/// </summary>
/// <param name="subject">The subject associated with the authorization.</param>
/// <param name="client">The client associated with the authorization.</param>
/// <param name="status">The authorization status.</param>
/// <param name="type">The authorization type.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the criteria.</returns>
/// <inheritdoc/>
public IAsyncEnumerable<TAuthorization> 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))
{
@ -306,19 +273,10 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves the authorizations matching the specified parameters.
/// </summary>
/// <param name="subject">The subject associated with the authorization.</param>
/// <param name="client">The client associated with the authorization.</param>
/// <param name="status">The authorization status.</param>
/// <param name="type">The authorization type.</param>
/// <param name="scopes">The minimal scopes associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the criteria.</returns>
/// <inheritdoc/>
public IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client,
[NotNull] string status, [NotNull] string type,
string subject, string client,
string status, string type,
ImmutableArray<string> scopes, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(subject))
@ -356,14 +314,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves the list of authorizations corresponding to the specified application identifier.
/// </summary>
/// <param name="identifier">The application identifier associated with the authorizations.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the specified application.</returns>
public IAsyncEnumerable<TAuthorization> FindByApplicationIdAsync(
[NotNull] string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TAuthorization> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(identifier))
{
@ -403,16 +355,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves an authorization using its unique identifier.
/// </summary>
/// <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{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the identifier.
/// </returns>
public ValueTask<TAuthorization> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
public ValueTask<TAuthorization?> FindByIdAsync(string identifier, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(identifier))
{
@ -425,14 +369,14 @@ namespace OpenIddict.Core
Identifier = identifier
};
if (_cache.TryGetValue(parameters, out TAuthorization authorization))
if (_cache.TryGetValue(parameters, out TAuthorization? authorization))
{
return new ValueTask<TAuthorization>(authorization);
return new ValueTask<TAuthorization?>(authorization);
}
return new ValueTask<TAuthorization>(ExecuteAsync());
return new ValueTask<TAuthorization?>(ExecuteAsync());
async Task<TAuthorization> ExecuteAsync()
async Task<TAuthorization?> ExecuteAsync()
{
if ((authorization = await _store.FindByIdAsync(identifier, cancellationToken)) != null)
{
@ -445,14 +389,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves all the authorizations corresponding to the specified subject.
/// </summary>
/// <param name="subject">The subject associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the specified subject.</returns>
public IAsyncEnumerable<TAuthorization> FindBySubjectAsync(
[NotNull] string subject, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TAuthorization> FindBySubjectAsync(string subject, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(subject))
{
@ -492,13 +430,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Removes the specified authorization from the cache.
/// </summary>
/// <param name="authorization">The authorization to remove from the cache.</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 async ValueTask RemoveAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
/// <inheritdoc/>
public async ValueTask RemoveAsync(TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
{
@ -511,7 +444,7 @@ namespace OpenIddict.Core
throw new InvalidOperationException(SR.GetResourceString(SR.ID1195));
}
if (_signals.TryRemove(identifier, out CancellationTokenSource signal))
if (_signals.TryRemove(identifier, out CancellationTokenSource? signal))
{
signal.Cancel();
signal.Dispose();
@ -525,8 +458,7 @@ namespace OpenIddict.Core
/// <param name="authorization">The authorization to store in the cache entry, if applicable.</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>
protected virtual async ValueTask CreateEntryAsync(
[NotNull] object key, [CanBeNull] TAuthorization authorization, CancellationToken cancellationToken)
protected virtual async ValueTask CreateEntryAsync(object key, TAuthorization? authorization, CancellationToken cancellationToken)
{
if (key == null)
{
@ -558,7 +490,7 @@ namespace OpenIddict.Core
/// <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>
protected virtual async ValueTask CreateEntryAsync(
[NotNull] object key, [CanBeNull] ImmutableArray<TAuthorization> authorizations, CancellationToken cancellationToken)
object key, ImmutableArray<TAuthorization> authorizations, CancellationToken cancellationToken)
{
if (key == null)
{
@ -593,7 +525,7 @@ namespace OpenIddict.Core
/// whose result returns an expiration signal for the specified authorization.
/// </returns>
protected virtual async ValueTask<IChangeToken> CreateExpirationSignalAsync(
[NotNull] TAuthorization authorization, CancellationToken cancellationToken)
TAuthorization authorization, CancellationToken cancellationToken)
{
if (authorization == null)
{

94
src/OpenIddict.Core/Caches/OpenIddictScopeCache.cs

@ -12,7 +12,6 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
@ -32,8 +31,8 @@ namespace OpenIddict.Core
private readonly IOpenIddictScopeStore<TScope> _store;
public OpenIddictScopeCache(
[NotNull] IOptionsMonitor<OpenIddictCoreOptions> options,
[NotNull] IOpenIddictScopeStoreResolver resolver)
IOptionsMonitor<OpenIddictCoreOptions> options,
IOpenIddictScopeStoreResolver resolver)
{
_cache = new MemoryCache(new MemoryCacheOptions
{
@ -44,13 +43,8 @@ namespace OpenIddict.Core
_store = resolver.Get<TScope>();
}
/// <summary>
/// Add the specified scope to the cache.
/// </summary>
/// <param name="scope">The scope to add to the cache.</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 async ValueTask AddAsync([NotNull] TScope scope, CancellationToken cancellationToken)
/// <inheritdoc/>
public async ValueTask AddAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
{
@ -91,9 +85,7 @@ namespace OpenIddict.Core
}, scope, cancellationToken);
}
/// <summary>
/// Disposes the resources held by this instance.
/// </summary>
/// <inheritdoc/>
public void Dispose()
{
foreach (var signal in _signals)
@ -104,16 +96,8 @@ namespace OpenIddict.Core
_cache.Dispose();
}
/// <summary>
/// Retrieves a scope using its unique identifier.
/// </summary>
/// <param name="identifier">The unique identifier associated with the scope.</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 scope corresponding to the identifier.
/// </returns>
public ValueTask<TScope> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
public ValueTask<TScope?> FindByIdAsync(string identifier, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(identifier))
{
@ -126,12 +110,14 @@ namespace OpenIddict.Core
Identifier = identifier
};
if (_cache.TryGetValue(parameters, out TScope scope))
if (_cache.TryGetValue(parameters, out TScope? scope))
{
return new ValueTask<TScope>(scope);
return new ValueTask<TScope?>(scope);
}
async Task<TScope> ExecuteAsync()
return new ValueTask<TScope?>(ExecuteAsync());
async Task<TScope?> ExecuteAsync()
{
if ((scope = await _store.FindByIdAsync(identifier, cancellationToken)) != null)
{
@ -142,20 +128,10 @@ namespace OpenIddict.Core
return scope;
}
return new ValueTask<TScope>(ExecuteAsync());
}
/// <summary>
/// Retrieves a scope using its name.
/// </summary>
/// <param name="name">The name associated with the scope.</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 scope corresponding to the specified name.
/// </returns>
public ValueTask<TScope> FindByNameAsync([NotNull] string name, CancellationToken cancellationToken)
/// <inheritdoc/>
public ValueTask<TScope?> FindByNameAsync(string name, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(name))
{
@ -168,12 +144,12 @@ namespace OpenIddict.Core
Name = name
};
if (_cache.TryGetValue(parameters, out TScope scope))
if (_cache.TryGetValue(parameters, out TScope? scope))
{
return new ValueTask<TScope>(scope);
return new ValueTask<TScope?>(scope);
}
async Task<TScope> ExecuteAsync()
async Task<TScope?> ExecuteAsync()
{
if ((scope = await _store.FindByNameAsync(name, cancellationToken)) != null)
{
@ -185,15 +161,10 @@ namespace OpenIddict.Core
return scope;
}
return new ValueTask<TScope>(ExecuteAsync());
return new ValueTask<TScope?>(ExecuteAsync());
}
/// <summary>
/// Retrieves a list of scopes using their name.
/// </summary>
/// <param name="names">The names associated with the scopes.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The scopes corresponding to the specified names.</returns>
/// <inheritdoc/>
public IAsyncEnumerable<TScope> FindByNamesAsync(ImmutableArray<string> names, CancellationToken cancellationToken)
{
if (names.Any(name => string.IsNullOrEmpty(name)))
@ -216,13 +187,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Retrieves all the scopes that contain the specified resource.
/// </summary>
/// <param name="resource">The resource associated with the scopes.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The scopes associated with the specified resource.</returns>
public IAsyncEnumerable<TScope> FindByResourceAsync([NotNull] string resource, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TScope> FindByResourceAsync(string resource, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(resource))
{
@ -262,13 +228,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Removes the specified scope from the cache.
/// </summary>
/// <param name="scope">The scope to remove from the cache.</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 async ValueTask RemoveAsync([NotNull] TScope scope, CancellationToken cancellationToken)
/// <inheritdoc/>
public async ValueTask RemoveAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
{
@ -281,7 +242,7 @@ namespace OpenIddict.Core
throw new InvalidOperationException(SR.GetResourceString(SR.ID1195));
}
if (_signals.TryRemove(identifier, out CancellationTokenSource signal))
if (_signals.TryRemove(identifier, out CancellationTokenSource? signal))
{
signal.Cancel();
signal.Dispose();
@ -295,8 +256,7 @@ namespace OpenIddict.Core
/// <param name="scope">The scope to store in the cache entry, if applicable.</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>
protected virtual async ValueTask CreateEntryAsync(
[NotNull] object key, [CanBeNull] TScope scope, CancellationToken cancellationToken)
protected virtual async ValueTask CreateEntryAsync(object key, TScope? scope, CancellationToken cancellationToken)
{
if (key == null)
{
@ -328,7 +288,7 @@ namespace OpenIddict.Core
/// <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>
protected virtual async ValueTask CreateEntryAsync(
[NotNull] object key, [CanBeNull] ImmutableArray<TScope> scopes, CancellationToken cancellationToken)
object key, ImmutableArray<TScope> scopes, CancellationToken cancellationToken)
{
if (key == null)
{
@ -362,7 +322,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns an expiration signal for the specified scope.
/// </returns>
protected virtual async ValueTask<IChangeToken> CreateExpirationSignalAsync([NotNull] TScope scope, CancellationToken cancellationToken)
protected virtual async ValueTask<IChangeToken> CreateExpirationSignalAsync(TScope scope, CancellationToken cancellationToken)
{
if (scope == null)
{

145
src/OpenIddict.Core/Caches/OpenIddictTokenCache.cs

@ -11,7 +11,6 @@ using System.Collections.Immutable;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
@ -31,8 +30,8 @@ namespace OpenIddict.Core
private readonly IOpenIddictTokenStore<TToken> _store;
public OpenIddictTokenCache(
[NotNull] IOptionsMonitor<OpenIddictCoreOptions> options,
[NotNull] IOpenIddictTokenStoreResolver resolver)
IOptionsMonitor<OpenIddictCoreOptions> options,
IOpenIddictTokenStoreResolver resolver)
{
_cache = new MemoryCache(new MemoryCacheOptions
{
@ -43,13 +42,8 @@ namespace OpenIddict.Core
_store = resolver.Get<TToken>();
}
/// <summary>
/// Add the specified token to the cache.
/// </summary>
/// <param name="token">The token to add to the cache.</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 async ValueTask AddAsync([NotNull] TToken token, CancellationToken cancellationToken)
/// <inheritdoc/>
public async ValueTask AddAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
{
@ -123,9 +117,7 @@ namespace OpenIddict.Core
}, token, cancellationToken);
}
/// <summary>
/// Disposes the resources held by this instance.
/// </summary>
/// <inheritdoc/>
public void Dispose()
{
foreach (var signal in _signals)
@ -136,16 +128,8 @@ namespace OpenIddict.Core
_cache.Dispose();
}
/// <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 IAsyncEnumerable<TToken> FindAsync([NotNull] string subject,
[NotNull] string client, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TToken> FindAsync(string subject, string client, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(subject))
{
@ -191,17 +175,10 @@ namespace OpenIddict.Core
}
}
/// <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 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))
{
@ -253,18 +230,10 @@ namespace OpenIddict.Core
}
}
/// <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 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))
{
@ -322,14 +291,8 @@ namespace OpenIddict.Core
}
}
/// <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 IAsyncEnumerable<TToken> FindByApplicationIdAsync(
[NotNull] string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TToken> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(identifier))
{
@ -369,14 +332,8 @@ namespace OpenIddict.Core
}
}
/// <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>The tokens corresponding to the specified authorization.</returns>
public IAsyncEnumerable<TToken> FindByAuthorizationIdAsync(
[NotNull] string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TToken> FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(identifier))
{
@ -416,16 +373,8 @@ namespace OpenIddict.Core
}
}
/// <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{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the token corresponding to the unique identifier.
/// </returns>
public ValueTask<TToken> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
public ValueTask<TToken?> FindByIdAsync(string identifier, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(identifier))
{
@ -438,14 +387,14 @@ namespace OpenIddict.Core
Identifier = identifier
};
if (_cache.TryGetValue(parameters, out TToken token))
if (_cache.TryGetValue(parameters, out TToken? token))
{
return new ValueTask<TToken>(token);
return new ValueTask<TToken?>(token);
}
return new ValueTask<TToken>(ExecuteAsync());
return new ValueTask<TToken?>(ExecuteAsync());
async Task<TToken> ExecuteAsync()
async Task<TToken?> ExecuteAsync()
{
if ((token = await _store.FindByIdAsync(identifier, cancellationToken)) != null)
{
@ -458,17 +407,8 @@ namespace OpenIddict.Core
}
}
/// <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{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified reference identifier.
/// </returns>
public ValueTask<TToken> FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
public ValueTask<TToken?> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(identifier))
{
@ -481,14 +421,14 @@ namespace OpenIddict.Core
Identifier = identifier
};
if (_cache.TryGetValue(parameters, out TToken token))
if (_cache.TryGetValue(parameters, out TToken? token))
{
return new ValueTask<TToken>(token);
return new ValueTask<TToken?>(token);
}
return new ValueTask<TToken>(ExecuteAsync());
return new ValueTask<TToken?>(ExecuteAsync());
async Task<TToken> ExecuteAsync()
async Task<TToken?> ExecuteAsync()
{
if ((token = await _store.FindByReferenceIdAsync(identifier, cancellationToken)) != null)
{
@ -501,13 +441,8 @@ namespace OpenIddict.Core
}
}
/// <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 IAsyncEnumerable<TToken> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken)
/// <inheritdoc/>
public IAsyncEnumerable<TToken> FindBySubjectAsync(string subject, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(subject))
{
@ -547,13 +482,8 @@ namespace OpenIddict.Core
}
}
/// <summary>
/// Removes the specified token from the cache.
/// </summary>
/// <param name="token">The token to remove from the cache.</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 async ValueTask RemoveAsync([NotNull] TToken token, CancellationToken cancellationToken)
/// <inheritdoc/>
public async ValueTask RemoveAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
{
@ -566,7 +496,7 @@ namespace OpenIddict.Core
throw new InvalidOperationException(SR.GetResourceString(SR.ID1204));
}
if (_signals.TryRemove(identifier, out CancellationTokenSource signal))
if (_signals.TryRemove(identifier, out CancellationTokenSource? signal))
{
signal.Cancel();
signal.Dispose();
@ -580,8 +510,7 @@ namespace OpenIddict.Core
/// <param name="token">The token to store in the cache entry, if applicable.</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>
protected virtual async ValueTask CreateEntryAsync(
[NotNull] object key, [CanBeNull] TToken token, CancellationToken cancellationToken)
protected virtual async ValueTask CreateEntryAsync(object key, TToken? token, CancellationToken cancellationToken)
{
if (key == null)
{
@ -613,7 +542,7 @@ namespace OpenIddict.Core
/// <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>
protected virtual async ValueTask CreateEntryAsync(
[NotNull] object key, [CanBeNull] ImmutableArray<TToken> tokens, CancellationToken cancellationToken)
object key, ImmutableArray<TToken> tokens, CancellationToken cancellationToken)
{
if (key == null)
{
@ -647,7 +576,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns an expiration signal for the specified token.
/// </returns>
protected virtual async ValueTask<IChangeToken> CreateExpirationSignalAsync([NotNull] TToken token, CancellationToken cancellationToken)
protected virtual async ValueTask<IChangeToken> CreateExpirationSignalAsync(TToken token, CancellationToken cancellationToken)
{
if (token == null)
{

185
src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs

@ -16,7 +16,6 @@ using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -50,11 +49,11 @@ namespace OpenIddict.Core
public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplicationManager where TApplication : class
{
public OpenIddictApplicationManager(
[NotNull] IOpenIddictApplicationCache<TApplication> cache,
[NotNull] IStringLocalizer<OpenIddictResources> localizer,
[NotNull] ILogger<OpenIddictApplicationManager<TApplication>> logger,
[NotNull] IOptionsMonitor<OpenIddictCoreOptions> options,
[NotNull] IOpenIddictApplicationStoreResolver resolver)
IOpenIddictApplicationCache<TApplication> cache,
IStringLocalizer<OpenIddictResources> localizer,
ILogger<OpenIddictApplicationManager<TApplication>> logger,
IOptionsMonitor<OpenIddictCoreOptions> options,
IOpenIddictApplicationStoreResolver resolver)
{
Cache = cache;
Localizer = localizer;
@ -110,7 +109,7 @@ namespace OpenIddict.Core
/// whose result returns the number of applications that match the specified query.
/// </returns>
public virtual ValueTask<long> CountAsync<TResult>(
[NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -128,7 +127,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual ValueTask CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
public virtual ValueTask CreateAsync(TApplication application, CancellationToken cancellationToken = default)
=> CreateAsync(application, secret: null, cancellationToken);
/// <summary>
@ -142,9 +141,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask CreateAsync(
[NotNull] TApplication application,
[CanBeNull] string secret, CancellationToken cancellationToken = default)
public virtual async ValueTask CreateAsync(TApplication application, string? secret, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -219,7 +216,7 @@ namespace OpenIddict.Core
/// whose result returns the unique identifier associated with the application.
/// </returns>
public virtual async ValueTask<TApplication> CreateAsync(
[NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default)
OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -256,7 +253,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask DeleteAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
public virtual async ValueTask DeleteAsync(TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -280,8 +277,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier.
/// </returns>
public virtual async ValueTask<TApplication> FindByClientIdAsync(
[NotNull] string identifier, CancellationToken cancellationToken = default)
public virtual async ValueTask<TApplication?> FindByClientIdAsync(
string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -318,7 +315,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier.
/// </returns>
public virtual async ValueTask<TApplication> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
public virtual async ValueTask<TApplication?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -353,7 +350,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The client applications corresponding to the specified post_logout_redirect_uri.</returns>
public virtual IAsyncEnumerable<TApplication> FindByPostLogoutRedirectUriAsync(
[NotNull] string address, CancellationToken cancellationToken = default)
string address, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(address))
{
@ -395,7 +392,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The client applications corresponding to the specified redirect_uri.</returns>
public virtual IAsyncEnumerable<TApplication> FindByRedirectUriAsync(
[NotNull] string address, CancellationToken cancellationToken = default)
string address, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(address))
{
@ -441,7 +438,7 @@ namespace OpenIddict.Core
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual ValueTask<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -464,8 +461,8 @@ namespace OpenIddict.Core
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default)
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -484,8 +481,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client identifier associated with the application.
/// </returns>
public virtual ValueTask<string> GetClientIdAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetClientIdAsync(
TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -504,8 +501,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client type of the application (by default, "public").
/// </returns>
public virtual ValueTask<string> GetClientTypeAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetClientTypeAsync(
TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -524,8 +521,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the consent type of the application (by default, "explicit").
/// </returns>
public virtual async ValueTask<string> GetConsentTypeAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
public virtual async ValueTask<string?> GetConsentTypeAsync(
TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -550,8 +547,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the application.
/// </returns>
public virtual ValueTask<string> GetDisplayNameAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetDisplayNameAsync(
TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -571,7 +568,7 @@ namespace OpenIddict.Core
/// whose result returns all the localized display names associated with the application.
/// </returns>
public virtual async ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -596,7 +593,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application.
/// </returns>
public virtual ValueTask<string> GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetIdAsync(TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -617,8 +614,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the matching localized display name associated with the application.
/// </returns>
public virtual ValueTask<string> GetLocalizedDisplayNameAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetLocalizedDisplayNameAsync(
TApplication application, CancellationToken cancellationToken = default)
=> GetLocalizedDisplayNameAsync(application, CultureInfo.CurrentUICulture, cancellationToken);
/// <summary>
@ -633,8 +630,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the matching localized display name associated with the application.
/// </returns>
public virtual async ValueTask<string> GetLocalizedDisplayNameAsync(
[NotNull] TApplication application, [NotNull] CultureInfo culture, CancellationToken cancellationToken = default)
public virtual async ValueTask<string?> GetLocalizedDisplayNameAsync(
TApplication application, CultureInfo culture, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -677,7 +674,7 @@ namespace OpenIddict.Core
/// whose result returns all the permissions associated with the application.
/// </returns>
public virtual ValueTask<ImmutableArray<string>> GetPermissionsAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -697,7 +694,7 @@ namespace OpenIddict.Core
/// whose result returns all the post_logout_redirect_uri associated with the application.
/// </returns>
public virtual ValueTask<ImmutableArray<string>> GetPostLogoutRedirectUrisAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -717,7 +714,7 @@ namespace OpenIddict.Core
/// whose result returns all the redirect_uri associated with the application.
/// </returns>
public virtual ValueTask<ImmutableArray<string>> GetRedirectUrisAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -737,7 +734,7 @@ namespace OpenIddict.Core
/// whose result returns all the requirements associated with the application.
/// </returns>
public virtual ValueTask<ImmutableArray<string>> GetRequirementsAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -755,7 +752,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the application has the specified client type, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> HasClientTypeAsync(
[NotNull] TApplication application, [NotNull] string type, CancellationToken cancellationToken = default)
TApplication application, string type, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -778,7 +775,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the application has the specified consent type, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> HasConsentTypeAsync(
[NotNull] TApplication application, [NotNull] string type, CancellationToken cancellationToken = default)
TApplication application, string type, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -801,7 +798,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the application has been granted the specified permission, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> HasPermissionAsync(
[NotNull] TApplication application, [NotNull] string permission, CancellationToken cancellationToken = default)
TApplication application, string permission, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -824,7 +821,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the requirement has been enforced for the specified application, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> HasRequirementAsync(
[NotNull] TApplication application, [NotNull] string requirement, CancellationToken cancellationToken = default)
TApplication application, string requirement, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -847,7 +844,7 @@ namespace OpenIddict.Core
/// <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<TApplication> ListAsync(
[CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default)
int? count = null, int? offset = null, CancellationToken cancellationToken = default)
=> Store.ListAsync(count, offset, cancellationToken);
/// <summary>
@ -858,7 +855,7 @@ namespace OpenIddict.Core
/// <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<TResult> ListAsync<TResult>(
[NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -878,8 +875,8 @@ namespace OpenIddict.Core
/// <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<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default)
Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -898,8 +895,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask PopulateAsync([NotNull] TApplication application,
[NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default)
public virtual async ValueTask PopulateAsync(TApplication application,
OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -935,8 +932,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask PopulateAsync(
[NotNull] OpenIddictApplicationDescriptor descriptor,
[NotNull] TApplication application, CancellationToken cancellationToken = default)
OpenIddictApplicationDescriptor descriptor,
TApplication application, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -974,7 +971,7 @@ namespace OpenIddict.Core
}
// Ensure the address is a valid absolute URL.
if (!Uri.TryCreate(address, UriKind.Absolute, out Uri uri) || !uri.IsWellFormedOriginalString())
if (!Uri.TryCreate(address, UriKind.Absolute, out Uri? uri) || !uri.IsWellFormedOriginalString())
{
throw new ArgumentException(SR.GetResourceString(SR.ID1213));
}
@ -992,7 +989,7 @@ namespace OpenIddict.Core
}
// Ensure the address is a valid absolute URL.
if (!Uri.TryCreate(address, UriKind.Absolute, out Uri uri) || !uri.IsWellFormedOriginalString())
if (!Uri.TryCreate(address, UriKind.Absolute, out Uri? uri) || !uri.IsWellFormedOriginalString())
{
throw new ArgumentException(SR.GetResourceString(SR.ID1213));
}
@ -1009,7 +1006,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask UpdateAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
public virtual async ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -1064,8 +1061,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask UpdateAsync([NotNull] TApplication application,
[CanBeNull] string secret, CancellationToken cancellationToken = default)
public virtual async ValueTask UpdateAsync(TApplication application, string? secret, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -1095,8 +1091,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask UpdateAsync([NotNull] TApplication application,
[NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default)
public virtual async ValueTask UpdateAsync(TApplication application,
OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -1131,7 +1127,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The validation error encountered when validating the application.</returns>
public virtual async IAsyncEnumerable<ValidationResult> ValidateAsync(
[NotNull] TApplication application, [EnumeratorCancellation] CancellationToken cancellationToken = default)
TApplication application, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -1205,7 +1201,7 @@ namespace OpenIddict.Core
}
// Ensure the address is a valid absolute URL.
if (!Uri.TryCreate(address, UriKind.Absolute, out Uri uri) || !uri.IsWellFormedOriginalString())
if (!Uri.TryCreate(address, UriKind.Absolute, out Uri? uri) || !uri.IsWellFormedOriginalString())
{
yield return new ValidationResult(Localizer[SR.ID3120]);
@ -1234,7 +1230,7 @@ namespace OpenIddict.Core
/// whose result returns a boolean indicating whether the client secret was valid.
/// </returns>
public virtual async ValueTask<bool> ValidateClientSecretAsync(
[NotNull] TApplication application, [NotNull] string secret, CancellationToken cancellationToken = default)
TApplication application, string secret, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -1281,7 +1277,7 @@ namespace OpenIddict.Core
/// whose result returns a boolean indicating whether the redirect_uri was valid.
/// </returns>
public virtual async ValueTask<bool> ValidateRedirectUriAsync(
[NotNull] TApplication application, [NotNull] string address, CancellationToken cancellationToken = default)
TApplication application, string address, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -1317,7 +1313,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual ValueTask<string> ObfuscateClientSecretAsync([NotNull] string secret, CancellationToken cancellationToken = default)
protected virtual ValueTask<string> ObfuscateClientSecretAsync(string secret, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(secret))
{
@ -1397,7 +1393,7 @@ namespace OpenIddict.Core
/// whose result returns a boolean indicating whether the specified value was valid.
/// </returns>
protected virtual ValueTask<bool> ValidateClientSecretAsync(
[NotNull] string secret, [NotNull] string comparand, CancellationToken cancellationToken = default)
string secret, string comparand, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(secret))
{
@ -1506,120 +1502,159 @@ namespace OpenIddict.Core
#endif
}
/// <inheritdoc/>
ValueTask<long> IOpenIddictApplicationManager.CountAsync(CancellationToken cancellationToken)
=> CountAsync(cancellationToken);
/// <inheritdoc/>
ValueTask<long> IOpenIddictApplicationManager.CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> CountAsync(query, cancellationToken);
/// <inheritdoc/>
async ValueTask<object> IOpenIddictApplicationManager.CreateAsync(OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken)
=> await CreateAsync(descriptor, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictApplicationManager.CreateAsync(object application, CancellationToken cancellationToken)
=> CreateAsync((TApplication) application, cancellationToken);
ValueTask IOpenIddictApplicationManager.CreateAsync(object application, string secret, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask IOpenIddictApplicationManager.CreateAsync(object application, string? secret, CancellationToken cancellationToken)
=> CreateAsync((TApplication) application, secret, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictApplicationManager.DeleteAsync(object application, CancellationToken cancellationToken)
=> DeleteAsync((TApplication) application, cancellationToken);
async ValueTask<object> IOpenIddictApplicationManager.FindByClientIdAsync(string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
async ValueTask<object?> IOpenIddictApplicationManager.FindByClientIdAsync(string identifier, CancellationToken cancellationToken)
=> await FindByClientIdAsync(identifier, cancellationToken);
async ValueTask<object> IOpenIddictApplicationManager.FindByIdAsync(string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
async ValueTask<object?> IOpenIddictApplicationManager.FindByIdAsync(string identifier, CancellationToken cancellationToken)
=> await FindByIdAsync(identifier, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictApplicationManager.FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken)
=> FindByPostLogoutRedirectUriAsync(address, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictApplicationManager.FindByRedirectUriAsync(string address, CancellationToken cancellationToken)
=> FindByRedirectUriAsync(address, cancellationToken);
/// <inheritdoc/>
ValueTask<TResult> IOpenIddictApplicationManager.GetAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> GetAsync(query, cancellationToken);
/// <inheritdoc/>
ValueTask<TResult> IOpenIddictApplicationManager.GetAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> GetAsync(query, state, cancellationToken);
ValueTask<string> IOpenIddictApplicationManager.GetClientIdAsync(object application, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictApplicationManager.GetClientIdAsync(object application, CancellationToken cancellationToken)
=> GetClientIdAsync((TApplication) application, cancellationToken);
ValueTask<string> IOpenIddictApplicationManager.GetClientTypeAsync(object application, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictApplicationManager.GetClientTypeAsync(object application, CancellationToken cancellationToken)
=> GetClientTypeAsync((TApplication) application, cancellationToken);
ValueTask<string> IOpenIddictApplicationManager.GetConsentTypeAsync(object application, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictApplicationManager.GetConsentTypeAsync(object application, CancellationToken cancellationToken)
=> GetConsentTypeAsync((TApplication) application, cancellationToken);
ValueTask<string> IOpenIddictApplicationManager.GetDisplayNameAsync(object application, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictApplicationManager.GetDisplayNameAsync(object application, CancellationToken cancellationToken)
=> GetDisplayNameAsync((TApplication) application, cancellationToken);
/// <inheritdoc/>
ValueTask<ImmutableDictionary<CultureInfo, string>> IOpenIddictApplicationManager.GetDisplayNamesAsync(object application, CancellationToken cancellationToken)
=> GetDisplayNamesAsync((TApplication) application, cancellationToken);
ValueTask<string> IOpenIddictApplicationManager.GetIdAsync(object application, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictApplicationManager.GetIdAsync(object application, CancellationToken cancellationToken)
=> GetIdAsync((TApplication) application, cancellationToken);
ValueTask<string> IOpenIddictApplicationManager.GetLocalizedDisplayNameAsync(object application, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictApplicationManager.GetLocalizedDisplayNameAsync(object application, CancellationToken cancellationToken)
=> GetLocalizedDisplayNameAsync((TApplication) application, cancellationToken);
ValueTask<string> IOpenIddictApplicationManager.GetLocalizedDisplayNameAsync(object application, CultureInfo culture, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictApplicationManager.GetLocalizedDisplayNameAsync(object application, CultureInfo culture, CancellationToken cancellationToken)
=> GetLocalizedDisplayNameAsync((TApplication) application, culture, cancellationToken);
/// <inheritdoc/>
ValueTask<ImmutableArray<string>> IOpenIddictApplicationManager.GetPermissionsAsync(object application, CancellationToken cancellationToken)
=> GetPermissionsAsync((TApplication) application, cancellationToken);
/// <inheritdoc/>
ValueTask<ImmutableArray<string>> IOpenIddictApplicationManager.GetPostLogoutRedirectUrisAsync(object application, CancellationToken cancellationToken)
=> GetPostLogoutRedirectUrisAsync((TApplication) application, cancellationToken);
/// <inheritdoc/>
ValueTask<ImmutableArray<string>> IOpenIddictApplicationManager.GetRedirectUrisAsync(object application, CancellationToken cancellationToken)
=> GetRedirectUrisAsync((TApplication) application, cancellationToken);
/// <inheritdoc/>
ValueTask<ImmutableArray<string>> IOpenIddictApplicationManager.GetRequirementsAsync(object application, CancellationToken cancellationToken)
=> GetRequirementsAsync((TApplication) application, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictApplicationManager.HasClientTypeAsync(object application, string type, CancellationToken cancellationToken)
=> HasClientTypeAsync((TApplication) application, type, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictApplicationManager.HasConsentTypeAsync(object application, string type, CancellationToken cancellationToken)
=> HasConsentTypeAsync((TApplication) application, type, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictApplicationManager.HasPermissionAsync(object application, string permission, CancellationToken cancellationToken)
=> HasPermissionAsync((TApplication) application, permission, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictApplicationManager.HasRequirementAsync(object application, string requirement, CancellationToken cancellationToken)
=> HasRequirementAsync((TApplication) application, requirement, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictApplicationManager.ListAsync(int? count, int? offset, CancellationToken cancellationToken)
=> ListAsync(count, offset, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<TResult> IOpenIddictApplicationManager.ListAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> ListAsync(query, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<TResult> IOpenIddictApplicationManager.ListAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> ListAsync(query, state, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictApplicationManager.PopulateAsync(OpenIddictApplicationDescriptor descriptor, object application, CancellationToken cancellationToken)
=> PopulateAsync(descriptor, (TApplication) application, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictApplicationManager.PopulateAsync(object application, OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken)
=> PopulateAsync((TApplication) application, descriptor, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictApplicationManager.UpdateAsync(object application, CancellationToken cancellationToken)
=> UpdateAsync((TApplication) application, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictApplicationManager.UpdateAsync(object application, OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken)
=> UpdateAsync((TApplication) application, descriptor, cancellationToken);
ValueTask IOpenIddictApplicationManager.UpdateAsync(object application, string secret, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask IOpenIddictApplicationManager.UpdateAsync(object application, string? secret, CancellationToken cancellationToken)
=> UpdateAsync((TApplication) application, secret, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<ValidationResult> IOpenIddictApplicationManager.ValidateAsync(object application, CancellationToken cancellationToken)
=> ValidateAsync((TApplication) application, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictApplicationManager.ValidateClientSecretAsync(object application, string secret, CancellationToken cancellationToken)
=> ValidateClientSecretAsync((TApplication) application, secret, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictApplicationManager.ValidateRedirectUriAsync(object application, string address, CancellationToken cancellationToken)
=> ValidateRedirectUriAsync((TApplication) application, address, cancellationToken);
}

154
src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs

@ -14,7 +14,6 @@ using System.Security.Claims;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -37,11 +36,11 @@ namespace OpenIddict.Core
public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthorizationManager where TAuthorization : class
{
public OpenIddictAuthorizationManager(
[NotNull] IOpenIddictAuthorizationCache<TAuthorization> cache,
[NotNull] IStringLocalizer<OpenIddictResources> localizer,
[NotNull] ILogger<OpenIddictAuthorizationManager<TAuthorization>> logger,
[NotNull] IOptionsMonitor<OpenIddictCoreOptions> options,
[NotNull] IOpenIddictAuthorizationStoreResolver resolver)
IOpenIddictAuthorizationCache<TAuthorization> cache,
IStringLocalizer<OpenIddictResources> localizer,
ILogger<OpenIddictAuthorizationManager<TAuthorization>> logger,
IOptionsMonitor<OpenIddictCoreOptions> options,
IOpenIddictAuthorizationStoreResolver resolver)
{
Cache = cache;
Localizer = localizer;
@ -97,7 +96,7 @@ namespace OpenIddict.Core
/// whose result returns the number of authorizations that match the specified query.
/// </returns>
public virtual ValueTask<long> CountAsync<TResult>(
[NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -115,7 +114,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
public virtual async ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -173,7 +172,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the authorization.
/// </returns>
public virtual async ValueTask<TAuthorization> CreateAsync(
[NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)
OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -205,8 +204,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the authorization.
/// </returns>
public virtual ValueTask<TAuthorization> CreateAsync(
[NotNull] ClaimsPrincipal principal, [NotNull] string subject, [NotNull] string client,
[NotNull] string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = default)
ClaimsPrincipal principal, string subject, string client,
string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = default)
{
if (principal == null)
{
@ -250,7 +249,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
public virtual async ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -274,7 +273,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the subject/client.</returns>
public virtual IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken = default)
string subject, string client, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -326,8 +325,8 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the criteria.</returns>
public virtual IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client,
[NotNull] string status, CancellationToken cancellationToken = default)
string subject, string client,
string status, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -381,8 +380,8 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the criteria.</returns>
public virtual IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client,
[NotNull] string status, [NotNull] string type, CancellationToken cancellationToken = default)
string subject, string client,
string status, string type, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -442,8 +441,8 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the criteria.</returns>
public virtual IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client,
[NotNull] string status, [NotNull] string type,
string subject, string client,
string status, string type,
ImmutableArray<string> scopes, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
@ -507,7 +506,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the specified application.</returns>
public virtual IAsyncEnumerable<TAuthorization> FindByApplicationIdAsync(
[NotNull] string identifier, CancellationToken cancellationToken = default)
string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -550,7 +549,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the identifier.
/// </returns>
public virtual async ValueTask<TAuthorization> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
public virtual async ValueTask<TAuthorization?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -585,7 +584,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The authorizations corresponding to the specified subject.</returns>
public virtual IAsyncEnumerable<TAuthorization> FindBySubjectAsync(
[NotNull] string subject, CancellationToken cancellationToken = default)
string subject, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -628,8 +627,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the authorization.
/// </returns>
public virtual ValueTask<string> GetApplicationIdAsync(
[NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetApplicationIdAsync(
TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -650,7 +649,7 @@ namespace OpenIddict.Core
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual ValueTask<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -673,8 +672,8 @@ namespace OpenIddict.Core
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default)
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -693,7 +692,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the authorization.
/// </returns>
public virtual ValueTask<string> GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -713,7 +712,7 @@ namespace OpenIddict.Core
/// whose result returns the scopes associated with the specified authorization.
/// </returns>
public virtual ValueTask<ImmutableArray<string>> GetScopesAsync(
[NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -732,8 +731,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified authorization.
/// </returns>
public virtual ValueTask<string> GetStatusAsync(
[NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetStatusAsync(
TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -752,8 +751,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the subject associated with the specified authorization.
/// </returns>
public virtual ValueTask<string> GetSubjectAsync(
[NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetSubjectAsync(
TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -772,8 +771,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the type associated with the specified authorization.
/// </returns>
public virtual ValueTask<string> GetTypeAsync(
[NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetTypeAsync(
TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -790,7 +789,7 @@ namespace OpenIddict.Core
/// <param name="scopes">The scopes.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the scopes are included in the authorization, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> HasScopesAsync([NotNull] TAuthorization authorization,
public virtual async ValueTask<bool> HasScopesAsync(TAuthorization authorization,
ImmutableArray<string> scopes, CancellationToken cancellationToken = default)
{
if (authorization == null)
@ -809,8 +808,8 @@ namespace OpenIddict.Core
/// <param name="status">The expected status.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the authorization has the specified status, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> HasStatusAsync([NotNull] TAuthorization authorization,
[NotNull] string status, CancellationToken cancellationToken = default)
public virtual async ValueTask<bool> HasStatusAsync(TAuthorization authorization,
string status, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -833,7 +832,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the authorization has the specified type, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> HasTypeAsync(
[NotNull] TAuthorization authorization, [NotNull] string type, CancellationToken cancellationToken = default)
TAuthorization authorization, string type, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -856,7 +855,7 @@ namespace OpenIddict.Core
/// <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<TAuthorization> ListAsync(
[CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default)
int? count = null, int? offset = null, CancellationToken cancellationToken = default)
=> Store.ListAsync(count, offset, cancellationToken);
/// <summary>
@ -867,7 +866,7 @@ namespace OpenIddict.Core
/// <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<TResult> ListAsync<TResult>(
[NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -887,8 +886,8 @@ namespace OpenIddict.Core
/// <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<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default)
Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -907,8 +906,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask PopulateAsync([NotNull] TAuthorization authorization,
[NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)
public virtual async ValueTask PopulateAsync(TAuthorization authorization,
OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -937,8 +936,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask PopulateAsync(
[NotNull] OpenIddictAuthorizationDescriptor descriptor,
[NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
OpenIddictAuthorizationDescriptor descriptor,
TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -978,7 +977,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask SetApplicationIdAsync(
[NotNull] TAuthorization authorization, [CanBeNull] string identifier, CancellationToken cancellationToken = default)
TAuthorization authorization, string? identifier, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -995,7 +994,7 @@ namespace OpenIddict.Core
/// <param name="authorization">The authorization to revoke.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the authorization was successfully revoked, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> TryRevokeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
public virtual async ValueTask<bool> TryRevokeAsync(TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -1042,7 +1041,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask UpdateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
public virtual async ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -1095,8 +1094,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask UpdateAsync([NotNull] TAuthorization authorization,
[NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)
public virtual async ValueTask UpdateAsync(TAuthorization authorization,
OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -1119,7 +1118,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The validation error encountered when validating the authorization.</returns>
public virtual async IAsyncEnumerable<ValidationResult> ValidateAsync(
[NotNull] TAuthorization authorization, [EnumeratorCancellation] CancellationToken cancellationToken = default)
TAuthorization authorization, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -1162,108 +1161,143 @@ namespace OpenIddict.Core
}
}
/// <inheritdoc/>
ValueTask<long> IOpenIddictAuthorizationManager.CountAsync(CancellationToken cancellationToken)
=> CountAsync(cancellationToken);
/// <inheritdoc/>
ValueTask<long> IOpenIddictAuthorizationManager.CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> CountAsync(query, cancellationToken);
/// <inheritdoc/>
async ValueTask<object> IOpenIddictAuthorizationManager.CreateAsync(ClaimsPrincipal principal, string subject, string client, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken)
=> await CreateAsync(principal, subject, client, type, scopes, cancellationToken);
/// <inheritdoc/>
async ValueTask<object> IOpenIddictAuthorizationManager.CreateAsync(OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken)
=> await CreateAsync(descriptor, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictAuthorizationManager.CreateAsync(object authorization, CancellationToken cancellationToken)
=> CreateAsync((TAuthorization) authorization, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictAuthorizationManager.DeleteAsync(object authorization, CancellationToken cancellationToken)
=> DeleteAsync((TAuthorization) authorization, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictAuthorizationManager.FindAsync(string subject, string client, CancellationToken cancellationToken)
=> FindAsync(subject, client, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictAuthorizationManager.FindAsync(string subject, string client, string status, CancellationToken cancellationToken)
=> FindAsync(subject, client, status, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictAuthorizationManager.FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken)
=> FindAsync(subject, client, status, type, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictAuthorizationManager.FindAsync(string subject, string client, string status, string type, ImmutableArray<string> scopes, CancellationToken cancellationToken)
=> FindAsync(subject, client, status, type, scopes, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictAuthorizationManager.FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken)
=> FindByApplicationIdAsync(identifier, cancellationToken);
async ValueTask<object> IOpenIddictAuthorizationManager.FindByIdAsync(string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
async ValueTask<object?> IOpenIddictAuthorizationManager.FindByIdAsync(string identifier, CancellationToken cancellationToken)
=> await FindByIdAsync(identifier, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictAuthorizationManager.FindBySubjectAsync(string subject, CancellationToken cancellationToken)
=> FindBySubjectAsync(subject, cancellationToken);
ValueTask<string> IOpenIddictAuthorizationManager.GetApplicationIdAsync(object authorization, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictAuthorizationManager.GetApplicationIdAsync(object authorization, CancellationToken cancellationToken)
=> GetApplicationIdAsync((TAuthorization) authorization, cancellationToken);
/// <inheritdoc/>
ValueTask<TResult> IOpenIddictAuthorizationManager.GetAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> GetAsync(query, cancellationToken);
/// <inheritdoc/>
ValueTask<TResult> IOpenIddictAuthorizationManager.GetAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> GetAsync(query, state, cancellationToken);
ValueTask<string> IOpenIddictAuthorizationManager.GetIdAsync(object authorization, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictAuthorizationManager.GetIdAsync(object authorization, CancellationToken cancellationToken)
=> GetIdAsync((TAuthorization) authorization, cancellationToken);
/// <inheritdoc/>
ValueTask<ImmutableArray<string>> IOpenIddictAuthorizationManager.GetScopesAsync(object authorization, CancellationToken cancellationToken)
=> GetScopesAsync((TAuthorization) authorization, cancellationToken);
ValueTask<string> IOpenIddictAuthorizationManager.GetStatusAsync(object authorization, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictAuthorizationManager.GetStatusAsync(object authorization, CancellationToken cancellationToken)
=> GetStatusAsync((TAuthorization) authorization, cancellationToken);
ValueTask<string> IOpenIddictAuthorizationManager.GetSubjectAsync(object authorization, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictAuthorizationManager.GetSubjectAsync(object authorization, CancellationToken cancellationToken)
=> GetSubjectAsync((TAuthorization) authorization, cancellationToken);
ValueTask<string> IOpenIddictAuthorizationManager.GetTypeAsync(object authorization, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictAuthorizationManager.GetTypeAsync(object authorization, CancellationToken cancellationToken)
=> GetTypeAsync((TAuthorization) authorization, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictAuthorizationManager.HasScopesAsync(object authorization, ImmutableArray<string> scopes, CancellationToken cancellationToken)
=> HasScopesAsync((TAuthorization) authorization, scopes, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictAuthorizationManager.HasStatusAsync(object authorization, string status, CancellationToken cancellationToken)
=> HasStatusAsync((TAuthorization) authorization, status, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictAuthorizationManager.HasTypeAsync(object authorization, string type, CancellationToken cancellationToken)
=> HasTypeAsync((TAuthorization) authorization, type, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictAuthorizationManager.ListAsync(int? count, int? offset, CancellationToken cancellationToken)
=> ListAsync(count, offset, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<TResult> IOpenIddictAuthorizationManager.ListAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> ListAsync(query, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<TResult> IOpenIddictAuthorizationManager.ListAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> ListAsync(query, state, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictAuthorizationManager.PopulateAsync(OpenIddictAuthorizationDescriptor descriptor, object authorization, CancellationToken cancellationToken)
=> PopulateAsync(descriptor, (TAuthorization) authorization, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictAuthorizationManager.PopulateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken)
=> PopulateAsync((TAuthorization) authorization, descriptor, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictAuthorizationManager.PruneAsync(CancellationToken cancellationToken)
=> PruneAsync(cancellationToken);
ValueTask IOpenIddictAuthorizationManager.SetApplicationIdAsync(object authorization, string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask IOpenIddictAuthorizationManager.SetApplicationIdAsync(object authorization, string? identifier, CancellationToken cancellationToken)
=> SetApplicationIdAsync((TAuthorization) authorization, identifier, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictAuthorizationManager.TryRevokeAsync(object authorization, CancellationToken cancellationToken)
=> TryRevokeAsync((TAuthorization) authorization, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictAuthorizationManager.UpdateAsync(object authorization, CancellationToken cancellationToken)
=> UpdateAsync((TAuthorization) authorization, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictAuthorizationManager.UpdateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken)
=> UpdateAsync((TAuthorization) authorization, descriptor, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<ValidationResult> IOpenIddictAuthorizationManager.ValidateAsync(object authorization, CancellationToken cancellationToken)
=> ValidateAsync((TAuthorization) authorization, cancellationToken);
}

134
src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs

@ -14,7 +14,6 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -36,11 +35,11 @@ namespace OpenIddict.Core
public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TScope : class
{
public OpenIddictScopeManager(
[NotNull] IOpenIddictScopeCache<TScope> cache,
[NotNull] IStringLocalizer<OpenIddictResources> localizer,
[NotNull] ILogger<OpenIddictScopeManager<TScope>> logger,
[NotNull] IOptionsMonitor<OpenIddictCoreOptions> options,
[NotNull] IOpenIddictScopeStoreResolver resolver)
IOpenIddictScopeCache<TScope> cache,
IStringLocalizer<OpenIddictResources> localizer,
ILogger<OpenIddictScopeManager<TScope>> logger,
IOptionsMonitor<OpenIddictCoreOptions> options,
IOpenIddictScopeStoreResolver resolver)
{
Cache = cache;
Localizer = localizer;
@ -96,7 +95,7 @@ namespace OpenIddict.Core
/// whose result returns the number of scopes that match the specified query.
/// </returns>
public virtual ValueTask<long> CountAsync<TResult>(
[NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -114,7 +113,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
public virtual async ValueTask CreateAsync(TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -166,7 +165,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the scope.
/// </returns>
public virtual async ValueTask<TScope> CreateAsync(
[NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default)
OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -193,7 +192,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask DeleteAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
public virtual async ValueTask DeleteAsync(TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -217,7 +216,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scope corresponding to the identifier.
/// </returns>
public virtual async ValueTask<TScope> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
public virtual async ValueTask<TScope?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -254,7 +253,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scope corresponding to the specified name.
/// </returns>
public virtual async ValueTask<TScope> FindByNameAsync([NotNull] string name, CancellationToken cancellationToken = default)
public virtual async ValueTask<TScope?> FindByNameAsync(string name, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(name))
{
@ -331,7 +330,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The scopes associated with the specified resource.</returns>
public virtual IAsyncEnumerable<TScope> FindByResourceAsync(
[NotNull] string resource, CancellationToken cancellationToken = default)
string resource, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(resource))
{
@ -377,7 +376,7 @@ namespace OpenIddict.Core
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual ValueTask<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -400,8 +399,8 @@ namespace OpenIddict.Core
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default)
Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -420,7 +419,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the description associated with the specified scope.
/// </returns>
public virtual ValueTask<string> GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetDescriptionAsync(TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -440,7 +439,7 @@ namespace OpenIddict.Core
/// whose result returns all the localized descriptions associated with the scope.
/// </returns>
public virtual async ValueTask<ImmutableDictionary<CultureInfo, string>> GetDescriptionsAsync(
[NotNull] TScope scope, CancellationToken cancellationToken = default)
TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -465,7 +464,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope.
/// </returns>
public virtual ValueTask<string> GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -485,7 +484,7 @@ namespace OpenIddict.Core
/// whose result returns all the localized display names associated with the scope.
/// </returns>
public virtual async ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(
[NotNull] TScope scope, CancellationToken cancellationToken = default)
TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -510,7 +509,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the scope.
/// </returns>
public virtual ValueTask<string> GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetIdAsync(TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -531,7 +530,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the matching display name associated with the scope.
/// </returns>
public virtual ValueTask<string> GetLocalizedDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetLocalizedDisplayNameAsync(TScope scope, CancellationToken cancellationToken = default)
=> GetLocalizedDisplayNameAsync(scope, CultureInfo.CurrentUICulture, cancellationToken);
/// <summary>
@ -546,8 +545,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the matching display name associated with the scope.
/// </returns>
public virtual async ValueTask<string> GetLocalizedDisplayNameAsync(
[NotNull] TScope scope, [NotNull] CultureInfo culture, CancellationToken cancellationToken = default)
public virtual async ValueTask<string?> GetLocalizedDisplayNameAsync(
TScope scope, CultureInfo culture, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -591,7 +590,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the matching localized description associated with the scope.
/// </returns>
public virtual ValueTask<string> GetLocalizedDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetLocalizedDescriptionAsync(TScope scope, CancellationToken cancellationToken = default)
=> GetLocalizedDescriptionAsync(scope, CultureInfo.CurrentUICulture, cancellationToken);
/// <summary>
@ -606,8 +605,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the matching localized description associated with the scope.
/// </returns>
public virtual async ValueTask<string> GetLocalizedDescriptionAsync(
[NotNull] TScope scope, [NotNull] CultureInfo culture, CancellationToken cancellationToken = default)
public virtual async ValueTask<string?> GetLocalizedDescriptionAsync(
TScope scope, CultureInfo culture, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -649,7 +648,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the name associated with the specified scope.
/// </returns>
public virtual ValueTask<string> GetNameAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetNameAsync(TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -669,7 +668,7 @@ namespace OpenIddict.Core
/// whose result returns all the resources associated with the scope.
/// </returns>
public virtual ValueTask<ImmutableArray<string>> GetResourcesAsync(
[NotNull] TScope scope, CancellationToken cancellationToken = default)
TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -687,7 +686,7 @@ namespace OpenIddict.Core
/// <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<TScope> ListAsync(
[CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default)
int? count = null, int? offset = null, CancellationToken cancellationToken = default)
=> Store.ListAsync(count, offset, cancellationToken);
/// <summary>
@ -698,7 +697,7 @@ namespace OpenIddict.Core
/// <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<TResult> ListAsync<TResult>(
[NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -718,8 +717,8 @@ namespace OpenIddict.Core
/// <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<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default)
Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -760,8 +759,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask PopulateAsync([NotNull] TScope scope,
[NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default)
public virtual async ValueTask PopulateAsync(TScope scope,
OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -791,8 +790,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask PopulateAsync(
[NotNull] OpenIddictScopeDescriptor descriptor,
[NotNull] TScope scope, CancellationToken cancellationToken = default)
OpenIddictScopeDescriptor descriptor,
TScope scope, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -831,7 +830,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask UpdateAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
public virtual async ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -884,8 +883,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask UpdateAsync([NotNull] TScope scope,
[NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default)
public virtual async ValueTask UpdateAsync(TScope scope,
OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -908,7 +907,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The validation error encountered when validating the scope.</returns>
public virtual async IAsyncEnumerable<ValidationResult> ValidateAsync(
[NotNull] TScope scope, [EnumeratorCancellation] CancellationToken cancellationToken = default)
TScope scope, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -923,7 +922,7 @@ namespace OpenIddict.Core
yield return new ValidationResult(Localizer[SR.ID3044]);
}
else if (name.Contains(Separators.Space[0]))
else if (name!.Contains(Separators.Space[0]))
{
yield return new ValidationResult(Localizer[SR.ID3045]);
}
@ -944,96 +943,127 @@ namespace OpenIddict.Core
}
}
/// <inheritdoc/>
ValueTask<long> IOpenIddictScopeManager.CountAsync(CancellationToken cancellationToken)
=> CountAsync(cancellationToken);
/// <inheritdoc/>
ValueTask<long> IOpenIddictScopeManager.CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> CountAsync(query, cancellationToken);
/// <inheritdoc/>
async ValueTask<object> IOpenIddictScopeManager.CreateAsync(OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken)
=> await CreateAsync(descriptor, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictScopeManager.CreateAsync(object scope, CancellationToken cancellationToken)
=> CreateAsync((TScope) scope, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictScopeManager.DeleteAsync(object scope, CancellationToken cancellationToken)
=> DeleteAsync((TScope) scope, cancellationToken);
async ValueTask<object> IOpenIddictScopeManager.FindByIdAsync(string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
async ValueTask<object?> IOpenIddictScopeManager.FindByIdAsync(string identifier, CancellationToken cancellationToken)
=> await FindByIdAsync(identifier, cancellationToken);
async ValueTask<object> IOpenIddictScopeManager.FindByNameAsync(string name, CancellationToken cancellationToken)
/// <inheritdoc/>
async ValueTask<object?> IOpenIddictScopeManager.FindByNameAsync(string name, CancellationToken cancellationToken)
=> await FindByNameAsync(name, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictScopeManager.FindByNamesAsync(ImmutableArray<string> names, CancellationToken cancellationToken)
=> FindByNamesAsync(names, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictScopeManager.FindByResourceAsync(string resource, CancellationToken cancellationToken)
=> FindByResourceAsync(resource, cancellationToken);
/// <inheritdoc/>
ValueTask<TResult> IOpenIddictScopeManager.GetAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> GetAsync(query, cancellationToken);
/// <inheritdoc/>
ValueTask<TResult> IOpenIddictScopeManager.GetAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> GetAsync(query, state, cancellationToken);
ValueTask<string> IOpenIddictScopeManager.GetDescriptionAsync(object scope, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictScopeManager.GetDescriptionAsync(object scope, CancellationToken cancellationToken)
=> GetDescriptionAsync((TScope) scope, cancellationToken);
/// <inheritdoc/>
ValueTask<ImmutableDictionary<CultureInfo, string>> IOpenIddictScopeManager.GetDescriptionsAsync(object scope, CancellationToken cancellationToken)
=> GetDescriptionsAsync((TScope) scope, cancellationToken);
ValueTask<string> IOpenIddictScopeManager.GetDisplayNameAsync(object scope, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictScopeManager.GetDisplayNameAsync(object scope, CancellationToken cancellationToken)
=> GetDisplayNameAsync((TScope) scope, cancellationToken);
/// <inheritdoc/>
ValueTask<ImmutableDictionary<CultureInfo, string>> IOpenIddictScopeManager.GetDisplayNamesAsync(object scope, CancellationToken cancellationToken)
=> GetDisplayNamesAsync((TScope) scope, cancellationToken);
ValueTask<string> IOpenIddictScopeManager.GetIdAsync(object scope, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictScopeManager.GetIdAsync(object scope, CancellationToken cancellationToken)
=> GetIdAsync((TScope) scope, cancellationToken);
ValueTask<string> IOpenIddictScopeManager.GetLocalizedDescriptionAsync(object scope, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictScopeManager.GetLocalizedDescriptionAsync(object scope, CancellationToken cancellationToken)
=> GetLocalizedDescriptionAsync((TScope) scope, cancellationToken);
ValueTask<string> IOpenIddictScopeManager.GetLocalizedDescriptionAsync(object scope, CultureInfo culture, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictScopeManager.GetLocalizedDescriptionAsync(object scope, CultureInfo culture, CancellationToken cancellationToken)
=> GetLocalizedDescriptionAsync((TScope) scope, culture, cancellationToken);
ValueTask<string> IOpenIddictScopeManager.GetLocalizedDisplayNameAsync(object scope, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictScopeManager.GetLocalizedDisplayNameAsync(object scope, CancellationToken cancellationToken)
=> GetLocalizedDisplayNameAsync((TScope) scope, cancellationToken);
ValueTask<string> IOpenIddictScopeManager.GetLocalizedDisplayNameAsync(object scope, CultureInfo culture, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictScopeManager.GetLocalizedDisplayNameAsync(object scope, CultureInfo culture, CancellationToken cancellationToken)
=> GetLocalizedDisplayNameAsync((TScope) scope, culture, cancellationToken);
ValueTask<string> IOpenIddictScopeManager.GetNameAsync(object scope, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictScopeManager.GetNameAsync(object scope, CancellationToken cancellationToken)
=> GetNameAsync((TScope) scope, cancellationToken);
/// <inheritdoc/>
ValueTask<ImmutableArray<string>> IOpenIddictScopeManager.GetResourcesAsync(object scope, CancellationToken cancellationToken)
=> GetResourcesAsync((TScope) scope, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictScopeManager.ListAsync(int? count, int? offset, CancellationToken cancellationToken)
=> ListAsync(count, offset, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<TResult> IOpenIddictScopeManager.ListAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> ListAsync(query, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<TResult> IOpenIddictScopeManager.ListAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> ListAsync(query, state, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<string> IOpenIddictScopeManager.ListResourcesAsync(ImmutableArray<string> scopes, CancellationToken cancellationToken)
=> ListResourcesAsync(scopes, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictScopeManager.PopulateAsync(OpenIddictScopeDescriptor descriptor, object scope, CancellationToken cancellationToken)
=> PopulateAsync(descriptor, (TScope) scope, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictScopeManager.PopulateAsync(object scope, OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken)
=> PopulateAsync((TScope) scope, descriptor, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictScopeManager.UpdateAsync(object scope, CancellationToken cancellationToken)
=> UpdateAsync((TScope) scope, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictScopeManager.UpdateAsync(object scope, OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken)
=> UpdateAsync((TScope) scope, descriptor, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<ValidationResult> IOpenIddictScopeManager.ValidateAsync(object scope, CancellationToken cancellationToken)
=> ValidateAsync((TScope) scope, cancellationToken);
}

183
src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs

@ -14,7 +14,6 @@ using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@ -37,11 +36,11 @@ namespace OpenIddict.Core
public class OpenIddictTokenManager<TToken> : IOpenIddictTokenManager where TToken : class
{
public OpenIddictTokenManager(
[NotNull] IOpenIddictTokenCache<TToken> cache,
[NotNull] IStringLocalizer<OpenIddictResources> localizer,
[NotNull] ILogger<OpenIddictTokenManager<TToken>> logger,
[NotNull] IOptionsMonitor<OpenIddictCoreOptions> options,
[NotNull] IOpenIddictTokenStoreResolver resolver)
IOpenIddictTokenCache<TToken> cache,
IStringLocalizer<OpenIddictResources> localizer,
ILogger<OpenIddictTokenManager<TToken>> logger,
IOptionsMonitor<OpenIddictCoreOptions> options,
IOpenIddictTokenStoreResolver resolver)
{
Cache = cache;
Localizer = localizer;
@ -97,7 +96,7 @@ namespace OpenIddict.Core
/// whose result returns the number of tokens that match the specified query.
/// </returns>
public virtual ValueTask<long> CountAsync<TResult>(
[NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -115,7 +114,7 @@ namespace OpenIddict.Core
/// <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 = default)
public virtual async ValueTask CreateAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -181,7 +180,7 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the token.
/// </returns>
public virtual async ValueTask<TToken> CreateAsync(
[NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -208,7 +207,7 @@ namespace OpenIddict.Core
/// <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 = default)
public virtual async ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -231,8 +230,8 @@ namespace OpenIddict.Core
/// <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 = default)
public virtual IAsyncEnumerable<TToken> FindAsync(string subject,
string client, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -280,8 +279,8 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The tokens corresponding to the criteria.</returns>
public virtual IAsyncEnumerable<TToken> FindAsync(
[NotNull] string subject, [NotNull] string client,
[NotNull] string status, CancellationToken cancellationToken = default)
string subject, string client,
string status, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -335,8 +334,8 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>Tokens corresponding to the criteria.</returns>
public virtual IAsyncEnumerable<TToken> FindAsync(
[NotNull] string subject, [NotNull] string client,
[NotNull] string status, [NotNull] string type, CancellationToken cancellationToken = default)
string subject, string client,
string status, string type, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -392,7 +391,7 @@ namespace OpenIddict.Core
/// <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 = default)
string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -433,7 +432,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The tokens corresponding to the specified authorization.</returns>
public virtual IAsyncEnumerable<TToken> FindByAuthorizationIdAsync(
[NotNull] string identifier, CancellationToken cancellationToken = default)
string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -476,7 +475,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual async ValueTask<TToken?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -514,7 +513,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual async ValueTask<TToken?> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -552,7 +551,7 @@ namespace OpenIddict.Core
/// <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 = default)
string subject, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -595,7 +594,7 @@ namespace OpenIddict.Core
/// 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 ValueTask<string> GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetApplicationIdAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -616,7 +615,7 @@ namespace OpenIddict.Core
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual ValueTask<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -639,8 +638,8 @@ namespace OpenIddict.Core
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default)
Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -659,7 +658,7 @@ namespace OpenIddict.Core
/// 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 ValueTask<string> GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
public virtual ValueTask<string?> GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -678,7 +677,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual ValueTask<DateTimeOffset?> GetCreationDateAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -697,7 +696,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual ValueTask<DateTimeOffset?> GetExpirationDateAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -716,7 +715,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual ValueTask<string?> GetIdAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -735,7 +734,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual ValueTask<string?> GetPayloadAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -756,7 +755,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual ValueTask<string?> GetReferenceIdAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -775,7 +774,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual ValueTask<string?> GetStatusAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -794,7 +793,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual ValueTask<string?> GetSubjectAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -813,7 +812,7 @@ namespace OpenIddict.Core
/// 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 = default)
public virtual ValueTask<string?> GetTypeAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -830,7 +829,7 @@ namespace OpenIddict.Core
/// <param name="status">The expected status.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the token has the specified status, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> HasStatusAsync([NotNull] TToken token, [NotNull] string status, CancellationToken cancellationToken = default)
public virtual async ValueTask<bool> HasStatusAsync(TToken token, string status, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -852,7 +851,7 @@ namespace OpenIddict.Core
/// <param name="type">The expected type.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the token has the specified type, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> HasTypeAsync([NotNull] TToken token, [NotNull] string type, CancellationToken cancellationToken = default)
public virtual async ValueTask<bool> HasTypeAsync(TToken token, string type, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -875,7 +874,7 @@ namespace OpenIddict.Core
/// <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 = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default)
int? count = null, int? offset = null, CancellationToken cancellationToken = default)
=> Store.ListAsync(count, offset, cancellationToken);
/// <summary>
@ -886,7 +885,7 @@ namespace OpenIddict.Core
/// <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<TResult> ListAsync<TResult>(
[NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -906,8 +905,8 @@ namespace OpenIddict.Core
/// <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<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default)
Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -926,8 +925,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask PopulateAsync([NotNull] TToken token,
[NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
public virtual async ValueTask PopulateAsync(TToken token,
OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -960,8 +959,8 @@ namespace OpenIddict.Core
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask PopulateAsync(
[NotNull] OpenIddictTokenDescriptor descriptor,
[NotNull] TToken token, CancellationToken cancellationToken = default)
OpenIddictTokenDescriptor descriptor,
TToken token, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -1003,8 +1002,8 @@ namespace OpenIddict.Core
/// <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 = default)
public virtual async ValueTask SetApplicationIdAsync(TToken token,
string? identifier, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -1024,8 +1023,8 @@ namespace OpenIddict.Core
/// <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 = default)
public virtual async ValueTask SetAuthorizationIdAsync(TToken token,
string? identifier, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -1043,8 +1042,8 @@ namespace OpenIddict.Core
/// <param name="date">The date on which the token will no longer be considered valid.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the token was successfully extended, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> TryExtendAsync([NotNull] TToken token,
[CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken = default)
public virtual async ValueTask<bool> TryExtendAsync(TToken token,
DateTimeOffset? date, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -1096,7 +1095,7 @@ namespace OpenIddict.Core
/// <param name="token">The token to redeem.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the token was successfully redemeed, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> TryRedeemAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
public virtual async ValueTask<bool> TryRedeemAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -1141,7 +1140,7 @@ namespace OpenIddict.Core
/// <param name="token">The token to reject.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the token was successfully redemeed, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> TryRejectAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
public virtual async ValueTask<bool> TryRejectAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -1186,7 +1185,7 @@ namespace OpenIddict.Core
/// <param name="token">The token to revoke.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the token was successfully revoked, <c>false</c> otherwise.</returns>
public virtual async ValueTask<bool> TryRevokeAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
public virtual async ValueTask<bool> TryRevokeAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -1233,7 +1232,7 @@ namespace OpenIddict.Core
/// <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 = default)
public virtual async ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -1286,8 +1285,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async ValueTask UpdateAsync([NotNull] TToken token,
[NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
public virtual async ValueTask UpdateAsync(TToken token,
OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -1305,7 +1304,7 @@ namespace OpenIddict.Core
// If the reference identifier was updated, re-obfuscate it before persisting the changes.
var identifier = await Store.GetReferenceIdAsync(token, cancellationToken);
if (!string.Equals(identifier, comparand, StringComparison.Ordinal))
if (!string.IsNullOrEmpty(identifier) && !string.Equals(identifier, comparand, StringComparison.Ordinal))
{
identifier = await ObfuscateReferenceIdAsync(identifier, cancellationToken);
await Store.SetReferenceIdAsync(token, identifier, cancellationToken);
@ -1321,7 +1320,7 @@ namespace OpenIddict.Core
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>The validation error encountered when validating the token.</returns>
public virtual async IAsyncEnumerable<ValidationResult> ValidateAsync(
[NotNull] TToken token, [EnumeratorCancellation] CancellationToken cancellationToken = default)
TToken token, [EnumeratorCancellation] CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -1367,7 +1366,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual ValueTask<string> ObfuscateReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
protected virtual ValueTask<string> ObfuscateReferenceIdAsync(string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -1380,129 +1379,171 @@ namespace OpenIddict.Core
return new ValueTask<string>(Convert.ToBase64String(algorithm.ComputeHash(Encoding.UTF8.GetBytes(identifier))));
}
/// <inheritdoc/>
ValueTask<long> IOpenIddictTokenManager.CountAsync(CancellationToken cancellationToken)
=> CountAsync(cancellationToken);
/// <inheritdoc/>
ValueTask<long> IOpenIddictTokenManager.CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> CountAsync(query, cancellationToken);
/// <inheritdoc/>
async ValueTask<object> IOpenIddictTokenManager.CreateAsync(OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken)
=> await CreateAsync(descriptor, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictTokenManager.CreateAsync(object token, CancellationToken cancellationToken)
=> CreateAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictTokenManager.DeleteAsync(object token, CancellationToken cancellationToken)
=> DeleteAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictTokenManager.FindAsync(string subject, string client, CancellationToken cancellationToken)
=> FindAsync(subject, client, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictTokenManager.FindAsync(string subject, string client, string status, CancellationToken cancellationToken)
=> FindAsync(subject, client, status, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictTokenManager.FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken)
=> FindAsync(subject, client, status, type, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictTokenManager.FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken)
=> FindByApplicationIdAsync(identifier, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictTokenManager.FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken)
=> FindByAuthorizationIdAsync(identifier, cancellationToken);
async ValueTask<object> IOpenIddictTokenManager.FindByIdAsync(string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
async ValueTask<object?> IOpenIddictTokenManager.FindByIdAsync(string identifier, CancellationToken cancellationToken)
=> await FindByIdAsync(identifier, cancellationToken);
async ValueTask<object> IOpenIddictTokenManager.FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
async ValueTask<object?> IOpenIddictTokenManager.FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken)
=> await FindByReferenceIdAsync(identifier, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictTokenManager.FindBySubjectAsync(string subject, CancellationToken cancellationToken)
=> FindBySubjectAsync(subject, cancellationToken);
ValueTask<string> IOpenIddictTokenManager.GetApplicationIdAsync(object token, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictTokenManager.GetApplicationIdAsync(object token, CancellationToken cancellationToken)
=> GetApplicationIdAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask<TResult> IOpenIddictTokenManager.GetAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> GetAsync(query, cancellationToken);
/// <inheritdoc/>
ValueTask<TResult> IOpenIddictTokenManager.GetAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> GetAsync(query, state, cancellationToken);
ValueTask<string> IOpenIddictTokenManager.GetAuthorizationIdAsync(object token, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictTokenManager.GetAuthorizationIdAsync(object token, CancellationToken cancellationToken)
=> GetAuthorizationIdAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask<DateTimeOffset?> IOpenIddictTokenManager.GetCreationDateAsync(object token, CancellationToken cancellationToken)
=> GetCreationDateAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask<DateTimeOffset?> IOpenIddictTokenManager.GetExpirationDateAsync(object token, CancellationToken cancellationToken)
=> GetExpirationDateAsync((TToken) token, cancellationToken);
ValueTask<string> IOpenIddictTokenManager.GetIdAsync(object token, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictTokenManager.GetIdAsync(object token, CancellationToken cancellationToken)
=> GetIdAsync((TToken) token, cancellationToken);
ValueTask<string> IOpenIddictTokenManager.GetPayloadAsync(object token, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictTokenManager.GetPayloadAsync(object token, CancellationToken cancellationToken)
=> GetPayloadAsync((TToken) token, cancellationToken);
ValueTask<string> IOpenIddictTokenManager.GetReferenceIdAsync(object token, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictTokenManager.GetReferenceIdAsync(object token, CancellationToken cancellationToken)
=> GetReferenceIdAsync((TToken) token, cancellationToken);
ValueTask<string> IOpenIddictTokenManager.GetStatusAsync(object token, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictTokenManager.GetStatusAsync(object token, CancellationToken cancellationToken)
=> GetStatusAsync((TToken) token, cancellationToken);
ValueTask<string> IOpenIddictTokenManager.GetSubjectAsync(object token, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictTokenManager.GetSubjectAsync(object token, CancellationToken cancellationToken)
=> GetSubjectAsync((TToken) token, cancellationToken);
ValueTask<string> IOpenIddictTokenManager.GetTypeAsync(object token, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask<string?> IOpenIddictTokenManager.GetTypeAsync(object token, CancellationToken cancellationToken)
=> GetTypeAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictTokenManager.HasStatusAsync(object token, string status, CancellationToken cancellationToken)
=> HasStatusAsync((TToken) token, status, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictTokenManager.HasTypeAsync(object token, string type, CancellationToken cancellationToken)
=> HasTypeAsync((TToken) token, type, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<object> IOpenIddictTokenManager.ListAsync(int? count, int? offset, CancellationToken cancellationToken)
=> ListAsync(count, offset, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<TResult> IOpenIddictTokenManager.ListAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken)
=> ListAsync(query, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<TResult> IOpenIddictTokenManager.ListAsync<TState, TResult>(Func<IQueryable<object>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)
=> ListAsync(query, state, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictTokenManager.PopulateAsync(OpenIddictTokenDescriptor descriptor, object token, CancellationToken cancellationToken)
=> PopulateAsync(descriptor, (TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictTokenManager.PopulateAsync(object token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken)
=> PopulateAsync((TToken) token, descriptor, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictTokenManager.PruneAsync(CancellationToken cancellationToken)
=> PruneAsync(cancellationToken);
ValueTask IOpenIddictTokenManager.SetApplicationIdAsync(object token, string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask IOpenIddictTokenManager.SetApplicationIdAsync(object token, string? identifier, CancellationToken cancellationToken)
=> SetApplicationIdAsync((TToken) token, identifier, cancellationToken);
ValueTask IOpenIddictTokenManager.SetAuthorizationIdAsync(object token, string identifier, CancellationToken cancellationToken)
/// <inheritdoc/>
ValueTask IOpenIddictTokenManager.SetAuthorizationIdAsync(object token, string? identifier, CancellationToken cancellationToken)
=> SetAuthorizationIdAsync((TToken) token, identifier, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictTokenManager.TryExtendAsync(object token, DateTimeOffset? date, CancellationToken cancellationToken)
=> TryExtendAsync((TToken) token, date, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictTokenManager.TryRedeemAsync(object token, CancellationToken cancellationToken)
=> TryRedeemAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictTokenManager.TryRejectAsync(object token, CancellationToken cancellationToken)
=> TryRejectAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask<bool> IOpenIddictTokenManager.TryRevokeAsync(object token, CancellationToken cancellationToken)
=> TryRevokeAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictTokenManager.UpdateAsync(object token, CancellationToken cancellationToken)
=> UpdateAsync((TToken) token, cancellationToken);
/// <inheritdoc/>
ValueTask IOpenIddictTokenManager.UpdateAsync(object token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken)
=> UpdateAsync((TToken) token, descriptor, cancellationToken);
/// <inheritdoc/>
IAsyncEnumerable<ValidationResult> IOpenIddictTokenManager.ValidateAsync(object token, CancellationToken cancellationToken)
=> ValidateAsync((TToken) token, cancellationToken);
}

1
src/OpenIddict.Core/OpenIddict.Core.csproj

@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFrameworks>net461;net472;netcoreapp2.1;netcoreapp3.1;netstandard2.0;netstandard2.1</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>

45
src/OpenIddict.Core/OpenIddictCoreBuilder.cs

@ -6,7 +6,6 @@
using System;
using System.ComponentModel;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection.Extensions;
using OpenIddict.Abstractions;
using OpenIddict.Core;
@ -24,7 +23,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// Initializes a new instance of <see cref="OpenIddictCoreBuilder"/>.
/// </summary>
/// <param name="services">The services collection.</param>
public OpenIddictCoreBuilder([NotNull] IServiceCollection services)
public OpenIddictCoreBuilder(IServiceCollection services)
=> Services = services ?? throw new ArgumentNullException(nameof(services));
/// <summary>
@ -39,7 +38,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="configuration">The delegate used to configure the OpenIddict options.</param>
/// <remarks>This extension can be safely called multiple times.</remarks>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder Configure([NotNull] Action<OpenIddictCoreOptions> configuration)
public OpenIddictCoreBuilder Configure(Action<OpenIddictCoreOptions> configuration)
{
if (configuration == null)
{
@ -73,8 +72,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="type">The type of the custom store.</param>
/// <param name="lifetime">The lifetime of the registered service.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder AddApplicationStore(
[NotNull] Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
public OpenIddictCoreBuilder AddApplicationStore(Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
if (type == null)
{
@ -130,8 +128,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="type">The type of the custom store.</param>
/// <param name="lifetime">The lifetime of the registered service.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder AddAuthorizationStore(
[NotNull] Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
public OpenIddictCoreBuilder AddAuthorizationStore(Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
if (type == null)
{
@ -187,8 +184,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="type">The type of the custom store.</param>
/// <param name="lifetime">The lifetime of the registered service.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder AddScopeStore(
[NotNull] Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
public OpenIddictCoreBuilder AddScopeStore(Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
if (type == null)
{
@ -244,8 +240,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="type">The type of the custom store.</param>
/// <param name="lifetime">The lifetime of the registered service.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder AddTokenStore(
[NotNull] Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
public OpenIddictCoreBuilder AddTokenStore(Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
if (type == null)
{
@ -299,7 +294,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <param name="type">The type of the custom manager.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder ReplaceApplicationManager([NotNull] Type type)
public OpenIddictCoreBuilder ReplaceApplicationManager(Type type)
{
if (type == null)
{
@ -356,7 +351,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="lifetime">The lifetime of the registered service.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder ReplaceApplicationStoreResolver(
[NotNull] Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
if (type == null)
{
@ -393,7 +388,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <param name="type">The type of the custom manager.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder ReplaceAuthorizationManager([NotNull] Type type)
public OpenIddictCoreBuilder ReplaceAuthorizationManager(Type type)
{
if (type == null)
{
@ -450,7 +445,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="lifetime">The lifetime of the registered service.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder ReplaceAuthorizationStoreResolver(
[NotNull] Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
if (type == null)
{
@ -487,7 +482,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <param name="type">The type of the custom manager.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder ReplaceScopeManager([NotNull] Type type)
public OpenIddictCoreBuilder ReplaceScopeManager(Type type)
{
if (type == null)
{
@ -544,7 +539,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="lifetime">The lifetime of the registered service.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder ReplaceScopeStoreResolver(
[NotNull] Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
if (type == null)
{
@ -581,7 +576,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <param name="type">The type of the custom manager.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder ReplaceTokenManager([NotNull] Type type)
public OpenIddictCoreBuilder ReplaceTokenManager(Type type)
{
if (type == null)
{
@ -638,7 +633,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="lifetime">The lifetime of the registered service.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder ReplaceTokenStoreResolver(
[NotNull] Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
Type type, ServiceLifetime lifetime = ServiceLifetime.Scoped)
{
if (type == null)
{
@ -687,7 +682,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <param name="type">The application entity type.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder SetDefaultApplicationEntity([NotNull] Type type)
public OpenIddictCoreBuilder SetDefaultApplicationEntity(Type type)
{
if (type == null)
{
@ -714,7 +709,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <param name="type">The authorization entity type.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder SetDefaultAuthorizationEntity([NotNull] Type type)
public OpenIddictCoreBuilder SetDefaultAuthorizationEntity(Type type)
{
if (type == null)
{
@ -741,7 +736,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <param name="type">The scope entity type.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder SetDefaultScopeEntity([NotNull] Type type)
public OpenIddictCoreBuilder SetDefaultScopeEntity(Type type)
{
if (type == null)
{
@ -768,7 +763,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <param name="type">The token entity type.</param>
/// <returns>The <see cref="OpenIddictCoreBuilder"/>.</returns>
public OpenIddictCoreBuilder SetDefaultTokenEntity([NotNull] Type type)
public OpenIddictCoreBuilder SetDefaultTokenEntity(Type type)
{
if (type == null)
{
@ -805,7 +800,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="obj">The object to compare with the current object.</param>
/// <returns><c>true</c> if the specified object is equal to the current object; otherwise, false.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals([CanBeNull] object obj) => base.Equals(obj);
public override bool Equals(object? obj) => base.Equals(obj);
/// <summary>
/// Serves as the default hash function.
@ -819,6 +814,6 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary>
/// <returns>A string that represents the current object.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public override string ToString() => base.ToString();
public override string? ToString() => base.ToString();
}
}

7
src/OpenIddict.Core/OpenIddictCoreExtensions.cs

@ -5,7 +5,6 @@
*/
using System;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging.Abstractions;
@ -28,7 +27,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="builder">The services builder used by OpenIddict to register new services.</param>
/// <remarks>This extension can be safely called multiple times.</remarks>
/// <returns>The <see cref="OpenIddictBuilder"/>.</returns>
public static OpenIddictCoreBuilder AddCore([NotNull] this OpenIddictBuilder builder)
public static OpenIddictCoreBuilder AddCore(this OpenIddictBuilder builder)
{
if (builder == null)
{
@ -125,9 +124,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="configuration">The configuration delegate used to configure the core services.</param>
/// <remarks>This extension can be safely called multiple times.</remarks>
/// <returns>The <see cref="OpenIddictBuilder"/>.</returns>
public static OpenIddictBuilder AddCore(
[NotNull] this OpenIddictBuilder builder,
[NotNull] Action<OpenIddictCoreBuilder> configuration)
public static OpenIddictBuilder AddCore(this OpenIddictBuilder builder, Action<OpenIddictCoreBuilder> configuration)
{
if (builder == null)
{

8
src/OpenIddict.Core/OpenIddictCoreOptions.cs

@ -17,25 +17,25 @@ namespace OpenIddict.Core
/// Gets or sets the type corresponding to the default Application entity,
/// used by the non-generic application manager and the server/validation services.
/// </summary>
public Type DefaultApplicationType { get; set; }
public Type? DefaultApplicationType { get; set; }
/// <summary>
/// Gets or sets the type corresponding to the default Authorization entity,
/// used by the non-generic authorization manager and the server/validation services.
/// </summary>
public Type DefaultAuthorizationType { get; set; }
public Type? DefaultAuthorizationType { get; set; }
/// <summary>
/// Gets or sets the type corresponding to the default Scope entity,
/// used by the non-generic scope manager and the server/validation services.
/// </summary>
public Type DefaultScopeType { get; set; }
public Type? DefaultScopeType { get; set; }
/// <summary>
/// Gets or sets the type corresponding to the default Token entity,
/// used by the non-generic token manager and the server/validation services.
/// </summary>
public Type DefaultTokenType { get; set; }
public Type? DefaultTokenType { get; set; }
/// <summary>
/// Gets or sets a boolean indicating whether additional filtering should be disabled,

3
src/OpenIddict.Core/Resolvers/OpenIddictApplicationStoreResolver.cs

@ -1,5 +1,4 @@
using System;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using OpenIddict.Abstractions;
using SR = OpenIddict.Abstractions.OpenIddictResources;
@ -13,7 +12,7 @@ namespace OpenIddict.Core
{
private readonly IServiceProvider _provider;
public OpenIddictApplicationStoreResolver([NotNull] IServiceProvider provider)
public OpenIddictApplicationStoreResolver(IServiceProvider provider)
=> _provider = provider;
/// <summary>

3
src/OpenIddict.Core/Resolvers/OpenIddictAuthorizationStoreResolver.cs

@ -1,5 +1,4 @@
using System;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using OpenIddict.Abstractions;
using SR = OpenIddict.Abstractions.OpenIddictResources;
@ -13,7 +12,7 @@ namespace OpenIddict.Core
{
private readonly IServiceProvider _provider;
public OpenIddictAuthorizationStoreResolver([NotNull] IServiceProvider provider)
public OpenIddictAuthorizationStoreResolver(IServiceProvider provider)
=> _provider = provider;
/// <summary>

3
src/OpenIddict.Core/Resolvers/OpenIddictScopeStoreResolver.cs

@ -1,5 +1,4 @@
using System;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using OpenIddict.Abstractions;
using SR = OpenIddict.Abstractions.OpenIddictResources;
@ -13,7 +12,7 @@ namespace OpenIddict.Core
{
private readonly IServiceProvider _provider;
public OpenIddictScopeStoreResolver([NotNull] IServiceProvider provider)
public OpenIddictScopeStoreResolver(IServiceProvider provider)
=> _provider = provider;
/// <summary>

3
src/OpenIddict.Core/Resolvers/OpenIddictTokenStoreResolver.cs

@ -1,5 +1,4 @@
using System;
using JetBrains.Annotations;
using Microsoft.Extensions.DependencyInjection;
using OpenIddict.Abstractions;
using SR = OpenIddict.Abstractions.OpenIddictResources;
@ -13,7 +12,7 @@ namespace OpenIddict.Core
{
private readonly IServiceProvider _provider;
public OpenIddictTokenStoreResolver([NotNull] IServiceProvider provider)
public OpenIddictTokenStoreResolver(IServiceProvider provider)
=> _provider = provider;
/// <summary>

Loading…
Cancel
Save