Browse Source

Add nullable annotations to OpenIddict.Abstractions

pull/1038/head
Kévin Chalet 6 years ago
parent
commit
27ebff1bea
  1. 5
      Directory.Build.props
  2. 1
      Directory.Packages.props
  3. 15
      src/OpenIddict.Abstractions/Caches/IOpenIddictApplicationCache.cs
  4. 26
      src/OpenIddict.Abstractions/Caches/IOpenIddictAuthorizationCache.cs
  5. 11
      src/OpenIddict.Abstractions/Caches/IOpenIddictScopeCache.cs
  6. 26
      src/OpenIddict.Abstractions/Caches/IOpenIddictTokenCache.cs
  7. 28
      src/OpenIddict.Abstractions/Descriptors/OpenIddictApplicationDescriptor.cs
  8. 10
      src/OpenIddict.Abstractions/Descriptors/OpenIddictAuthorizationDescriptor.cs
  9. 15
      src/OpenIddict.Abstractions/Descriptors/OpenIddictScopeDescriptor.cs
  10. 16
      src/OpenIddict.Abstractions/Descriptors/OpenIddictTokenDescriptor.cs
  11. 81
      src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs
  12. 79
      src/OpenIddict.Abstractions/Managers/IOpenIddictAuthorizationManager.cs
  13. 61
      src/OpenIddict.Abstractions/Managers/IOpenIddictScopeManager.cs
  14. 91
      src/OpenIddict.Abstractions/Managers/IOpenIddictTokenManager.cs
  15. 1
      src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj
  16. 7
      src/OpenIddict.Abstractions/OpenIddictBuilder.cs
  17. 24
      src/OpenIddict.Abstractions/OpenIddictExceptions.cs
  18. 7
      src/OpenIddict.Abstractions/OpenIddictExtensions.cs
  19. 3
      src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs
  20. 286
      src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs
  21. 21
      src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs
  22. 107
      src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs
  23. 161
      src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs
  24. 57
      src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs
  25. 17
      src/OpenIddict.Abstractions/Resources/OpenIddictResources.resx
  26. 77
      src/OpenIddict.Abstractions/Stores/IOpenIddictApplicationStore.cs
  27. 71
      src/OpenIddict.Abstractions/Stores/IOpenIddictAuthorizationStore.cs
  28. 61
      src/OpenIddict.Abstractions/Stores/IOpenIddictScopeStore.cs
  29. 83
      src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs
  30. 2
      src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs
  31. 147
      test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs

5
Directory.Build.props

@ -62,6 +62,11 @@
<PackageReference Include="JetBrains.Annotations" PrivateAssets="All" /> <PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" PrivateAssets="All" /> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" PrivateAssets="All" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" />
<PackageReference Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageDownload Include="Microsoft.NETCore.App.Ref" Version="[3.1.0]" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

1
Directory.Packages.props

@ -21,6 +21,7 @@
<PackageVersion Include="System.Linq.Async" Version="4.1.1" /> <PackageVersion Include="System.Linq.Async" Version="4.1.1" />
<PackageVersion Include="System.Net.Http.Json" Version="3.2.1" /> <PackageVersion Include="System.Net.Http.Json" Version="3.2.1" />
<PackageVersion Include="System.Text.Json" Version="4.7.2" /> <PackageVersion Include="System.Text.Json" Version="4.7.2" />
<PackageVersion Include="TunnelVisionLabs.ReferenceAssemblyAnnotator" Version="1.0.0-alpha.154" />
</ItemGroup> </ItemGroup>
<ItemGroup <ItemGroup

15
src/OpenIddict.Abstractions/Caches/IOpenIddictApplicationCache.cs

@ -7,7 +7,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -23,7 +22,7 @@ namespace OpenIddict.Abstractions
/// <param name="application">The application to add to the cache.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask AddAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask AddAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves an application using its client identifier. /// Retrieves an application using its client identifier.
@ -34,7 +33,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier. /// whose result returns the client application corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<TApplication> FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TApplication?> FindByClientIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves an application using its unique identifier. /// Retrieves an application using its unique identifier.
@ -45,7 +44,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier. /// whose result returns the client application corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<TApplication> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TApplication?> FindByIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves all the applications associated with the specified redirect_uri. /// Retrieves all the applications associated with the specified redirect_uri.
@ -53,8 +52,7 @@ namespace OpenIddict.Abstractions
/// <param name="address">The redirect_uri associated with the applications.</param> /// <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> /// <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> /// <returns>The client applications corresponding to the specified redirect_uri.</returns>
IAsyncEnumerable<TApplication> FindByPostLogoutRedirectUriAsync( IAsyncEnumerable<TApplication> FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken);
[NotNull] string address, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves all the applications associated with the specified redirect_uri. /// Retrieves all the applications associated with the specified redirect_uri.
@ -62,8 +60,7 @@ namespace OpenIddict.Abstractions
/// <param name="address">The redirect_uri associated with the applications.</param> /// <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> /// <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> /// <returns>The client applications corresponding to the specified redirect_uri.</returns>
IAsyncEnumerable<TApplication> FindByRedirectUriAsync( IAsyncEnumerable<TApplication> FindByRedirectUriAsync(string address, CancellationToken cancellationToken);
[NotNull] string address, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes the specified application from the cache. /// Removes the specified application from the cache.
@ -71,6 +68,6 @@ namespace OpenIddict.Abstractions
/// <param name="application">The application to remove from the cache.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask RemoveAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask RemoveAsync(TApplication application, CancellationToken cancellationToken);
} }
} }

26
src/OpenIddict.Abstractions/Caches/IOpenIddictAuthorizationCache.cs

@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -24,7 +23,7 @@ namespace OpenIddict.Abstractions
/// <param name="authorization">The authorization to add to the cache.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask AddAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask AddAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the authorizations corresponding to the specified /// Retrieves the authorizations corresponding to the specified
@ -34,8 +33,7 @@ namespace OpenIddict.Abstractions
/// <param name="client">The client 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> /// <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> /// <returns>The authorizations corresponding to the subject/client.</returns>
IAsyncEnumerable<TAuthorization> FindAsync( IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, CancellationToken cancellationToken);
[NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the authorizations matching the specified parameters. /// Retrieves the authorizations matching the specified parameters.
@ -45,8 +43,7 @@ namespace OpenIddict.Abstractions
/// <param name="status">The authorization status.</param> /// <param name="status">The authorization status.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The authorizations corresponding to the criteria.</returns>
IAsyncEnumerable<TAuthorization> FindAsync( IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, string status, CancellationToken cancellationToken);
[NotNull] string subject, [NotNull] string client, [NotNull] string status, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the authorizations matching the specified parameters. /// Retrieves the authorizations matching the specified parameters.
@ -58,8 +55,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The authorizations corresponding to the criteria.</returns>
IAsyncEnumerable<TAuthorization> FindAsync( IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client, [NotNull] string status, string subject, string client, string status,
[NotNull] string type, CancellationToken cancellationToken); string type, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the authorizations matching the specified parameters. /// Retrieves the authorizations matching the specified parameters.
@ -72,8 +69,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The authorizations corresponding to the criteria.</returns>
IAsyncEnumerable<TAuthorization> FindAsync( IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client, [NotNull] string status, string subject, string client, string status,
[NotNull] string type, ImmutableArray<string> scopes, CancellationToken cancellationToken); string type, ImmutableArray<string> scopes, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the list of authorizations corresponding to the specified application identifier. /// Retrieves the list of authorizations corresponding to the specified application identifier.
@ -81,8 +78,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The application identifier associated with the authorizations.</param> /// <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> /// <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> /// <returns>The authorizations corresponding to the specified application.</returns>
IAsyncEnumerable<TAuthorization> FindByApplicationIdAsync( IAsyncEnumerable<TAuthorization> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken);
[NotNull] string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves an authorization using its unique identifier. /// Retrieves an authorization using its unique identifier.
@ -93,7 +89,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the identifier. /// whose result returns the authorization corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<TAuthorization> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TAuthorization?> FindByIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves all the authorizations corresponding to the specified subject. /// Retrieves all the authorizations corresponding to the specified subject.
@ -101,7 +97,7 @@ namespace OpenIddict.Abstractions
/// <param name="subject">The subject associated with the authorization.</param> /// <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> /// <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> /// <returns>The authorizations corresponding to the specified subject.</returns>
IAsyncEnumerable<TAuthorization> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken); IAsyncEnumerable<TAuthorization> FindBySubjectAsync(string subject, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes the specified authorization from the cache. /// Removes the specified authorization from the cache.
@ -109,6 +105,6 @@ namespace OpenIddict.Abstractions
/// <param name="authorization">The authorization to remove from the cache.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask RemoveAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask RemoveAsync(TAuthorization authorization, CancellationToken cancellationToken);
} }
} }

11
src/OpenIddict.Abstractions/Caches/IOpenIddictScopeCache.cs

@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -24,7 +23,7 @@ namespace OpenIddict.Abstractions
/// <param name="scope">The scope to add to the cache.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask AddAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask AddAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves a scope using its unique identifier. /// Retrieves a scope using its unique identifier.
@ -35,7 +34,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scope corresponding to the identifier. /// whose result returns the scope corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<TScope> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TScope?> FindByIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves a scope using its name. /// Retrieves a scope using its name.
@ -46,7 +45,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scope corresponding to the specified name. /// whose result returns the scope corresponding to the specified name.
/// </returns> /// </returns>
ValueTask<TScope> FindByNameAsync([NotNull] string name, CancellationToken cancellationToken); ValueTask<TScope?> FindByNameAsync(string name, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves a list of scopes using their name. /// Retrieves a list of scopes using their name.
@ -62,7 +61,7 @@ namespace OpenIddict.Abstractions
/// <param name="resource">The resource associated with the scopes.</param> /// <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> /// <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> /// <returns>The scopes associated with the specified resource.</returns>
IAsyncEnumerable<TScope> FindByResourceAsync([NotNull] string resource, CancellationToken cancellationToken); IAsyncEnumerable<TScope> FindByResourceAsync(string resource, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes the specified scope from the cache. /// Removes the specified scope from the cache.
@ -70,6 +69,6 @@ namespace OpenIddict.Abstractions
/// <param name="scope">The scope to remove from the cache.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask RemoveAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask RemoveAsync(TScope scope, CancellationToken cancellationToken);
} }
} }

26
src/OpenIddict.Abstractions/Caches/IOpenIddictTokenCache.cs

@ -7,7 +7,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -23,7 +22,7 @@ namespace OpenIddict.Abstractions
/// <param name="token">The token to add to the cache.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask AddAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask AddAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the tokens corresponding to the specified /// Retrieves the tokens corresponding to the specified
@ -33,8 +32,7 @@ namespace OpenIddict.Abstractions
/// <param name="client">The client 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> /// <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> /// <returns>The tokens corresponding to the subject/client.</returns>
IAsyncEnumerable<TToken> FindAsync([NotNull] string subject, IAsyncEnumerable<TToken> FindAsync(string subject, string client, CancellationToken cancellationToken);
[NotNull] string client, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the tokens matching the specified parameters. /// Retrieves the tokens matching the specified parameters.
@ -44,9 +42,7 @@ namespace OpenIddict.Abstractions
/// <param name="status">The token status.</param> /// <param name="status">The token status.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The tokens corresponding to the criteria.</returns>
IAsyncEnumerable<TToken> FindAsync( IAsyncEnumerable<TToken> FindAsync(string subject, string client, string status, CancellationToken cancellationToken);
[NotNull] string subject, [NotNull] string client,
[NotNull] string status, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the tokens matching the specified parameters. /// Retrieves the tokens matching the specified parameters.
@ -58,8 +54,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The tokens corresponding to the criteria.</returns>
IAsyncEnumerable<TToken> FindAsync( IAsyncEnumerable<TToken> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, [NotNull] string type, CancellationToken cancellationToken); string status, string type, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified application identifier. /// Retrieves the list of tokens corresponding to the specified application identifier.
@ -67,7 +63,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The application identifier associated with the tokens.</param> /// <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> /// <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> /// <returns>The tokens corresponding to the specified application.</returns>
IAsyncEnumerable<TToken> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); IAsyncEnumerable<TToken> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified authorization identifier. /// Retrieves the list of tokens corresponding to the specified authorization identifier.
@ -75,7 +71,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The authorization identifier associated with the tokens.</param> /// <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> /// <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> /// <returns>The tokens corresponding to the specified authorization.</returns>
IAsyncEnumerable<TToken> FindByAuthorizationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); IAsyncEnumerable<TToken> FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves a token using its unique identifier. /// Retrieves a token using its unique identifier.
@ -86,7 +82,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the token corresponding to the unique identifier. /// whose result returns the token corresponding to the unique identifier.
/// </returns> /// </returns>
ValueTask<TToken> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TToken?> FindByIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified reference identifier. /// Retrieves the list of tokens corresponding to the specified reference identifier.
@ -98,7 +94,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the tokens corresponding to the specified reference identifier.
/// </returns> /// </returns>
ValueTask<TToken> FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TToken?> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified subject. /// Retrieves the list of tokens corresponding to the specified subject.
@ -106,7 +102,7 @@ namespace OpenIddict.Abstractions
/// <param name="subject">The subject associated with the tokens.</param> /// <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> /// <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> /// <returns>The tokens corresponding to the specified subject.</returns>
IAsyncEnumerable<TToken> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken); IAsyncEnumerable<TToken> FindBySubjectAsync(string subject, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes the specified token from the cache. /// Removes the specified token from the cache.
@ -114,6 +110,6 @@ namespace OpenIddict.Abstractions
/// <param name="token">The token to remove from the cache.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask RemoveAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask RemoveAsync(TToken token, CancellationToken cancellationToken);
} }
} }

28
src/OpenIddict.Abstractions/Descriptors/OpenIddictApplicationDescriptor.cs

@ -10,29 +10,26 @@ namespace OpenIddict.Abstractions
public class OpenIddictApplicationDescriptor public class OpenIddictApplicationDescriptor
{ {
/// <summary> /// <summary>
/// Gets or sets the client identifier /// Gets or sets the client identifier associated with the application.
/// associated with the application.
/// </summary> /// </summary>
public string ClientId { get; set; } public string? ClientId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the client secret associated with the application. /// Gets or sets the client secret associated with the application.
/// Note: depending on the application manager used when creating it, /// Note: depending on the application manager used when creating it,
/// this property may be hashed or encrypted for security reasons. /// this property may be hashed or encrypted for security reasons.
/// </summary> /// </summary>
public string ClientSecret { get; set; } public string? ClientSecret { get; set; }
/// <summary> /// <summary>
/// Gets or sets the consent type /// Gets or sets the consent type associated with the application.
/// associated with the application.
/// </summary> /// </summary>
public string ConsentType { get; set; } public string? ConsentType { get; set; }
/// <summary> /// <summary>
/// Gets or sets the display name /// Gets or sets the display name associated with the application.
/// associated with the application.
/// </summary> /// </summary>
public string DisplayName { get; set; } public string? DisplayName { get; set; }
/// <summary> /// <summary>
/// Gets the localized display names associated with the application. /// Gets the localized display names associated with the application.
@ -46,14 +43,12 @@ namespace OpenIddict.Abstractions
public HashSet<string> Permissions { get; } = new HashSet<string>(StringComparer.Ordinal); public HashSet<string> Permissions { get; } = new HashSet<string>(StringComparer.Ordinal);
/// <summary> /// <summary>
/// Gets the logout callback URLs /// Gets the logout callback URLs associated with the application.
/// associated with the application.
/// </summary> /// </summary>
public HashSet<Uri> PostLogoutRedirectUris { get; } = new HashSet<Uri>(); public HashSet<Uri> PostLogoutRedirectUris { get; } = new HashSet<Uri>();
/// <summary> /// <summary>
/// Gets the callback URLs /// Gets the callback URLs associated with the application.
/// associated with the application.
/// </summary> /// </summary>
public HashSet<Uri> RedirectUris { get; } = new HashSet<Uri>(); public HashSet<Uri> RedirectUris { get; } = new HashSet<Uri>();
@ -63,9 +58,8 @@ namespace OpenIddict.Abstractions
public HashSet<string> Requirements { get; } = new HashSet<string>(StringComparer.Ordinal); public HashSet<string> Requirements { get; } = new HashSet<string>(StringComparer.Ordinal);
/// <summary> /// <summary>
/// Gets or sets the application type /// Gets or sets the application type associated with the application.
/// associated with the application.
/// </summary> /// </summary>
public string Type { get; set; } public string? Type { get; set; }
} }
} }

10
src/OpenIddict.Abstractions/Descriptors/OpenIddictAuthorizationDescriptor.cs

@ -12,13 +12,13 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the application identifier associated with the authorization. /// Gets or sets the application identifier associated with the authorization.
/// </summary> /// </summary>
public string ApplicationId { get; set; } public string? ApplicationId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the optional principal associated with the authorization. /// Gets or sets the optional principal associated with the authorization.
/// Note: this property is not stored by the default authorization stores. /// Note: this property is not stored by the default authorization stores.
/// </summary> /// </summary>
public ClaimsPrincipal Principal { get; set; } public ClaimsPrincipal? Principal { get; set; }
/// <summary> /// <summary>
/// Gets the scopes associated with the authorization. /// Gets the scopes associated with the authorization.
@ -28,16 +28,16 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the status associated with the authorization. /// Gets or sets the status associated with the authorization.
/// </summary> /// </summary>
public string Status { get; set; } public string? Status { get; set; }
/// <summary> /// <summary>
/// Gets or sets the subject associated with the authorization. /// Gets or sets the subject associated with the authorization.
/// </summary> /// </summary>
public string Subject { get; set; } public string? Subject { get; set; }
/// <summary> /// <summary>
/// Gets or sets the type of the authorization. /// Gets or sets the type of the authorization.
/// </summary> /// </summary>
public string Type { get; set; } public string? Type { get; set; }
} }
} }

15
src/OpenIddict.Abstractions/Descriptors/OpenIddictScopeDescriptor.cs

@ -10,10 +10,9 @@ namespace OpenIddict.Abstractions
public class OpenIddictScopeDescriptor public class OpenIddictScopeDescriptor
{ {
/// <summary> /// <summary>
/// Gets or sets the description /// Gets or sets the description associated with the scope.
/// associated with the scope.
/// </summary> /// </summary>
public string Description { get; set; } public string? Description { get; set; }
/// <summary> /// <summary>
/// Gets the localized descriptions associated with the scope. /// Gets the localized descriptions associated with the scope.
@ -21,10 +20,9 @@ namespace OpenIddict.Abstractions
public Dictionary<CultureInfo, string> Descriptions { get; } = new Dictionary<CultureInfo, string>(); public Dictionary<CultureInfo, string> Descriptions { get; } = new Dictionary<CultureInfo, string>();
/// <summary> /// <summary>
/// Gets or sets the display name /// Gets or sets the display name associated with the scope.
/// associated with the scope.
/// </summary> /// </summary>
public string DisplayName { get; set; } public string? DisplayName { get; set; }
/// <summary> /// <summary>
/// Gets the localized display names associated with the scope. /// Gets the localized display names associated with the scope.
@ -32,10 +30,9 @@ namespace OpenIddict.Abstractions
public Dictionary<CultureInfo, string> DisplayNames { get; } = new Dictionary<CultureInfo, string>(); public Dictionary<CultureInfo, string> DisplayNames { get; } = new Dictionary<CultureInfo, string>();
/// <summary> /// <summary>
/// Gets or sets the unique name /// Gets or sets the unique name associated with the scope.
/// associated with the scope.
/// </summary> /// </summary>
public string Name { get; set; } public string? Name { get; set; }
/// <summary> /// <summary>
/// Gets the resources associated with the scope. /// Gets the resources associated with the scope.

16
src/OpenIddict.Abstractions/Descriptors/OpenIddictTokenDescriptor.cs

@ -11,12 +11,12 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the application identifier associated with the token. /// Gets or sets the application identifier associated with the token.
/// </summary> /// </summary>
public string ApplicationId { get; set; } public string? ApplicationId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the authorization identifier associated with the token. /// Gets or sets the authorization identifier associated with the token.
/// </summary> /// </summary>
public string AuthorizationId { get; set; } public string? AuthorizationId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the creation date associated with the token. /// Gets or sets the creation date associated with the token.
@ -31,34 +31,34 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the payload associated with the token. /// Gets or sets the payload associated with the token.
/// </summary> /// </summary>
public string Payload { get; set; } public string? Payload { get; set; }
/// <summary> /// <summary>
/// Gets or sets the optional principal associated with the token. /// Gets or sets the optional principal associated with the token.
/// Note: this property is not stored by the default token stores. /// Note: this property is not stored by the default token stores.
/// </summary> /// </summary>
public ClaimsPrincipal Principal { get; set; } public ClaimsPrincipal? Principal { get; set; }
/// <summary> /// <summary>
/// Gets or sets the reference identifier associated with the token. /// Gets or sets the reference identifier associated with the token.
/// Note: depending on the application manager used when creating it, /// Note: depending on the application manager used when creating it,
/// this property may be hashed or encrypted for security reasons. /// this property may be hashed or encrypted for security reasons.
/// </summary> /// </summary>
public string ReferenceId { get; set; } public string? ReferenceId { get; set; }
/// <summary> /// <summary>
/// Gets or sets the status associated with the token. /// Gets or sets the status associated with the token.
/// </summary> /// </summary>
public string Status { get; set; } public string? Status { get; set; }
/// <summary> /// <summary>
/// Gets or sets the subject associated with the token. /// Gets or sets the subject associated with the token.
/// </summary> /// </summary>
public string Subject { get; set; } public string? Subject { get; set; }
/// <summary> /// <summary>
/// Gets or sets the token type. /// Gets or sets the token type.
/// </summary> /// </summary>
public string Type { get; set; } public string? Type { get; set; }
} }
} }

81
src/OpenIddict.Abstractions/Managers/IOpenIddictApplicationManager.cs

@ -6,7 +6,6 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -40,7 +39,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of applications that match the specified query. /// whose result returns the number of applications that match the specified query.
/// </returns> /// </returns>
ValueTask<long> CountAsync<TResult>([NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); ValueTask<long> CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new application based on the specified descriptor. /// Creates a new application based on the specified descriptor.
@ -53,7 +52,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application. /// whose result returns the unique identifier associated with the application.
/// </returns> /// </returns>
ValueTask<object> CreateAsync([NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask<object> CreateAsync(OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new application. /// Creates a new application.
@ -63,7 +62,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask CreateAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask CreateAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new application. /// Creates a new application.
@ -76,7 +75,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask CreateAsync([NotNull] object application, [CanBeNull] string secret, CancellationToken cancellationToken = default); ValueTask CreateAsync(object application, string? secret, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Removes an existing application. /// Removes an existing application.
@ -86,7 +85,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask DeleteAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask DeleteAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves an application using its client identifier. /// Retrieves an application using its client identifier.
@ -97,7 +96,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier. /// whose result returns the client application corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<object> FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); ValueTask<object?> FindByClientIdAsync(string identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves an application using its unique identifier. /// Retrieves an application using its unique identifier.
@ -108,7 +107,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier. /// whose result returns the client application corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<object> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); ValueTask<object?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves all the applications associated with the specified post_logout_redirect_uri. /// Retrieves all the applications associated with the specified post_logout_redirect_uri.
@ -116,7 +115,7 @@ namespace OpenIddict.Abstractions
/// <param name="address">The post_logout_redirect_uri associated with the applications.</param> /// <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> /// <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> /// <returns>The client applications corresponding to the specified post_logout_redirect_uri.</returns>
IAsyncEnumerable<object> FindByPostLogoutRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken = default); IAsyncEnumerable<object> FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves all the applications associated with the specified redirect_uri. /// Retrieves all the applications associated with the specified redirect_uri.
@ -124,7 +123,7 @@ namespace OpenIddict.Abstractions
/// <param name="address">The redirect_uri associated with the applications.</param> /// <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> /// <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> /// <returns>The client applications corresponding to the specified redirect_uri.</returns>
IAsyncEnumerable<object> FindByRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken = default); IAsyncEnumerable<object> FindByRedirectUriAsync(string address, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -137,7 +136,7 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TResult>( ValueTask<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -152,8 +151,8 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TState, TResult>( ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<object>, TState, IQueryable<TResult>> query, Func<IQueryable<object>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default); TState state, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the client identifier associated with an application. /// Retrieves the client identifier associated with an application.
@ -164,7 +163,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client identifier associated with the application. /// whose result returns the client identifier associated with the application.
/// </returns> /// </returns>
ValueTask<string> GetClientIdAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<string?> GetClientIdAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the client type associated with an application. /// Retrieves the client type associated with an application.
@ -175,7 +174,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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"). /// whose result returns the client type of the application (by default, "public").
/// </returns> /// </returns>
ValueTask<string> GetClientTypeAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<string?> GetClientTypeAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the consent type associated with an application. /// Retrieves the consent type associated with an application.
@ -186,7 +185,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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"). /// whose result returns the consent type of the application (by default, "explicit").
/// </returns> /// </returns>
ValueTask<string> GetConsentTypeAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<string?> GetConsentTypeAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the display name associated with an application. /// Retrieves the display name associated with an application.
@ -197,7 +196,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the application. /// whose result returns the display name associated with the application.
/// </returns> /// </returns>
ValueTask<string> GetDisplayNameAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<string?> GetDisplayNameAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the localized display names associated with an application. /// Retrieves the localized display names associated with an application.
@ -208,7 +207,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the localized display names associated with the application. /// whose result returns all the localized display names associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the unique identifier associated with an application. /// Retrieves the unique identifier associated with an application.
@ -219,7 +218,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application. /// whose result returns the unique identifier associated with the application.
/// </returns> /// </returns>
ValueTask<string> GetIdAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<string?> GetIdAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the localized display name associated with an application /// Retrieves the localized display name associated with an application
@ -232,7 +231,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the matching localized display name associated with the application.
/// </returns> /// </returns>
ValueTask<string> GetLocalizedDisplayNameAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<string?> GetLocalizedDisplayNameAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the localized display name associated with an application /// Retrieves the localized display name associated with an application
@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the matching localized display name associated with the application.
/// </returns> /// </returns>
ValueTask<string> GetLocalizedDisplayNameAsync([NotNull] object application, [NotNull] CultureInfo culture, CancellationToken cancellationToken = default); ValueTask<string?> GetLocalizedDisplayNameAsync(object application, CultureInfo culture, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the permissions associated with an application. /// Retrieves the permissions associated with an application.
@ -257,7 +256,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the permissions associated with the application. /// whose result returns all the permissions associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetPermissionsAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<ImmutableArray<string>> GetPermissionsAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the logout callback addresses associated with an application. /// Retrieves the logout callback addresses associated with an application.
@ -268,7 +267,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the post_logout_redirect_uri associated with the application. /// whose result returns all the post_logout_redirect_uri associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetPostLogoutRedirectUrisAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<ImmutableArray<string>> GetPostLogoutRedirectUrisAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the callback addresses associated with an application. /// Retrieves the callback addresses associated with an application.
@ -279,7 +278,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the redirect_uri associated with the application. /// whose result returns all the redirect_uri associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetRedirectUrisAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<ImmutableArray<string>> GetRedirectUrisAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the requirements associated with an application. /// Retrieves the requirements associated with an application.
@ -290,7 +289,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the requirements associated with the application. /// whose result returns all the requirements associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetRequirementsAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask<ImmutableArray<string>> GetRequirementsAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Determines whether a given application has the specified client type. /// Determines whether a given application has the specified client type.
@ -299,7 +298,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The expected client type.</param> /// <param name="type">The expected client type.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns><c>true</c> if the application has the specified client type, <c>false</c> otherwise.</returns>
ValueTask<bool> HasClientTypeAsync([NotNull] object application, [NotNull] string type, CancellationToken cancellationToken = default); ValueTask<bool> HasClientTypeAsync(object application, string type, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Determines whether a given application has the specified consent type. /// Determines whether a given application has the specified consent type.
@ -308,7 +307,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The expected consent type.</param> /// <param name="type">The expected consent type.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns><c>true</c> if the application has the specified consent type, <c>false</c> otherwise.</returns>
ValueTask<bool> HasConsentTypeAsync([NotNull] object application, [NotNull] string type, CancellationToken cancellationToken = default); ValueTask<bool> HasConsentTypeAsync(object application, string type, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Determines whether the specified permission has been granted to the application. /// Determines whether the specified permission has been granted to the application.
@ -317,7 +316,7 @@ namespace OpenIddict.Abstractions
/// <param name="permission">The permission.</param> /// <param name="permission">The permission.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns><c>true</c> if the application has been granted the specified permission, <c>false</c> otherwise.</returns>
ValueTask<bool> HasPermissionAsync([NotNull] object application, [NotNull] string permission, CancellationToken cancellationToken = default); ValueTask<bool> HasPermissionAsync(object application, string permission, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Determines whether the specified requirement has been enforced for the specified application. /// Determines whether the specified requirement has been enforced for the specified application.
@ -326,7 +325,7 @@ namespace OpenIddict.Abstractions
/// <param name="requirement">The requirement.</param> /// <param name="requirement">The requirement.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns><c>true</c> if the requirement has been enforced for the specified application, <c>false</c> otherwise.</returns>
ValueTask<bool> HasRequirementAsync([NotNull] object application, [NotNull] string requirement, CancellationToken cancellationToken = default); ValueTask<bool> HasRequirementAsync(object application, string requirement, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -336,7 +335,7 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<object> ListAsync( IAsyncEnumerable<object> ListAsync(
[CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default); int? count = null, int? offset = null, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -346,7 +345,7 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TResult>( IAsyncEnumerable<TResult> ListAsync<TResult>(
[NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -358,8 +357,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TState, TResult>( IAsyncEnumerable<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<object>, TState, IQueryable<TResult>> query, Func<IQueryable<object>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default); TState state, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Populates the specified descriptor using the properties exposed by the application. /// Populates the specified descriptor using the properties exposed by the application.
@ -370,7 +369,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask PopulateAsync([NotNull] OpenIddictApplicationDescriptor descriptor, [NotNull] object application, CancellationToken cancellationToken = default); ValueTask PopulateAsync(OpenIddictApplicationDescriptor descriptor, object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Populates the application using the specified descriptor. /// Populates the application using the specified descriptor.
@ -381,7 +380,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask PopulateAsync([NotNull] object application, [NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask PopulateAsync(object application, OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing application. /// Updates an existing application.
@ -391,7 +390,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask UpdateAsync([NotNull] object application, CancellationToken cancellationToken = default); ValueTask UpdateAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing application. /// Updates an existing application.
@ -402,7 +401,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask UpdateAsync([NotNull] object application, [NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask UpdateAsync(object application, OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing application and replaces the existing secret. /// Updates an existing application and replaces the existing secret.
@ -415,7 +414,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask UpdateAsync([NotNull] object application, [CanBeNull] string secret, CancellationToken cancellationToken = default); ValueTask UpdateAsync(object application, string? secret, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Validates the application to ensure it's in a consistent state. /// Validates the application to ensure it's in a consistent state.
@ -423,7 +422,7 @@ namespace OpenIddict.Abstractions
/// <param name="application">The application.</param> /// <param name="application">The application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>The validation error encountered when validating the application.</returns>
IAsyncEnumerable<ValidationResult> ValidateAsync([NotNull] object application, CancellationToken cancellationToken = default); IAsyncEnumerable<ValidationResult> ValidateAsync(object application, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Validates the client_secret associated with an application. /// Validates the client_secret associated with an application.
@ -436,7 +435,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns a boolean indicating whether the client secret was valid. /// whose result returns a boolean indicating whether the client secret was valid.
/// </returns> /// </returns>
ValueTask<bool> ValidateClientSecretAsync([NotNull] object application, [NotNull] string secret, CancellationToken cancellationToken = default); ValueTask<bool> ValidateClientSecretAsync(object application, string secret, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Validates the redirect_uri to ensure it's associated with an application. /// Validates the redirect_uri to ensure it's associated with an application.
@ -448,6 +447,6 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns a boolean indicating whether the redirect_uri was valid. /// whose result returns a boolean indicating whether the redirect_uri was valid.
/// </returns> /// </returns>
ValueTask<bool> ValidateRedirectUriAsync([NotNull] object application, [NotNull] string address, CancellationToken cancellationToken = default); ValueTask<bool> ValidateRedirectUriAsync(object application, string address, CancellationToken cancellationToken = default);
} }
} }

79
src/OpenIddict.Abstractions/Managers/IOpenIddictAuthorizationManager.cs

@ -6,7 +6,6 @@ using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -41,7 +40,7 @@ namespace OpenIddict.Abstractions
/// whose result returns the number of authorizations that match the specified query. /// whose result returns the number of authorizations that match the specified query.
/// </returns> /// </returns>
ValueTask<long> CountAsync<TResult>( ValueTask<long> CountAsync<TResult>(
[NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new permanent authorization based on the specified parameters. /// Creates a new permanent authorization based on the specified parameters.
@ -56,8 +55,8 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the authorization. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the authorization.
/// </returns> /// </returns>
ValueTask<object> CreateAsync( ValueTask<object> CreateAsync(
[NotNull] ClaimsPrincipal principal, [NotNull] string subject, [NotNull] string client, ClaimsPrincipal principal, string subject, string client,
[NotNull] string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = default); string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new authorization based on the specified descriptor. /// Creates a new authorization based on the specified descriptor.
@ -67,7 +66,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the authorization. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the authorization.
/// </returns> /// </returns>
ValueTask<object> CreateAsync([NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask<object> CreateAsync(OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new authorization. /// Creates a new authorization.
@ -77,7 +76,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask CreateAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask CreateAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Removes an existing authorization. /// Removes an existing authorization.
@ -87,7 +86,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask DeleteAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask DeleteAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the authorizations corresponding to the specified /// Retrieves the authorizations corresponding to the specified
@ -97,7 +96,7 @@ namespace OpenIddict.Abstractions
/// <param name="client">The client 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> /// <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> /// <returns>The authorizations corresponding to the subject/client.</returns>
IAsyncEnumerable<object> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken = default); IAsyncEnumerable<object> FindAsync(string subject, string client, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the authorizations matching the specified parameters. /// Retrieves the authorizations matching the specified parameters.
@ -108,8 +107,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The authorizations corresponding to the criteria.</returns>
IAsyncEnumerable<object> FindAsync( IAsyncEnumerable<object> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, CancellationToken cancellationToken = default); string status, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the authorizations matching the specified parameters. /// Retrieves the authorizations matching the specified parameters.
@ -121,8 +120,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The authorizations corresponding to the criteria.</returns>
IAsyncEnumerable<object> FindAsync( IAsyncEnumerable<object> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, [NotNull] string type, CancellationToken cancellationToken = default); string status, string type, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the authorizations matching the specified parameters. /// Retrieves the authorizations matching the specified parameters.
@ -135,8 +134,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The authorizations corresponding to the criteria.</returns>
IAsyncEnumerable<object> FindAsync( IAsyncEnumerable<object> FindAsync(
[NotNull] string subject, [NotNull] string client, [NotNull] string status, string subject, string client, string status,
[NotNull] string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = default); string type, ImmutableArray<string> scopes, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the list of authorizations corresponding to the specified application identifier. /// Retrieves the list of authorizations corresponding to the specified application identifier.
@ -144,7 +143,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The application identifier associated with the authorizations.</param> /// <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> /// <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> /// <returns>The authorizations corresponding to the specified application.</returns>
IAsyncEnumerable<object> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); IAsyncEnumerable<object> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves an authorization using its unique identifier. /// Retrieves an authorization using its unique identifier.
@ -155,7 +154,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the identifier. /// whose result returns the authorization corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<object> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); ValueTask<object?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves all the authorizations corresponding to the specified subject. /// Retrieves all the authorizations corresponding to the specified subject.
@ -163,7 +162,7 @@ namespace OpenIddict.Abstractions
/// <param name="subject">The subject associated with the authorization.</param> /// <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> /// <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> /// <returns>The authorizations corresponding to the specified subject.</returns>
IAsyncEnumerable<object> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken = default); IAsyncEnumerable<object> FindBySubjectAsync(string subject, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the optional application identifier associated with an authorization. /// Retrieves the optional application identifier associated with an authorization.
@ -174,7 +173,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the authorization. /// whose result returns the application identifier associated with the authorization.
/// </returns> /// </returns>
ValueTask<string> GetApplicationIdAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask<string?> GetApplicationIdAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -187,7 +186,7 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TResult>( ValueTask<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -202,8 +201,8 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TState, TResult>( ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<object>, TState, IQueryable<TResult>> query, Func<IQueryable<object>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default); TState state, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the unique identifier associated with an authorization. /// Retrieves the unique identifier associated with an authorization.
@ -214,7 +213,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the authorization. /// whose result returns the unique identifier associated with the authorization.
/// </returns> /// </returns>
ValueTask<string> GetIdAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask<string?> GetIdAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the scopes associated with an authorization. /// Retrieves the scopes associated with an authorization.
@ -225,7 +224,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scopes associated with the specified authorization. /// whose result returns the scopes associated with the specified authorization.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetScopesAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask<ImmutableArray<string>> GetScopesAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the status associated with an authorization. /// Retrieves the status associated with an authorization.
@ -236,7 +235,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified authorization. /// whose result returns the status associated with the specified authorization.
/// </returns> /// </returns>
ValueTask<string> GetStatusAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask<string?> GetStatusAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the subject associated with an authorization. /// Retrieves the subject associated with an authorization.
@ -247,7 +246,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the subject associated with the specified authorization. /// whose result returns the subject associated with the specified authorization.
/// </returns> /// </returns>
ValueTask<string> GetSubjectAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask<string?> GetSubjectAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the type associated with an authorization. /// Retrieves the type associated with an authorization.
@ -258,7 +257,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the type associated with the specified authorization. /// whose result returns the type associated with the specified authorization.
/// </returns> /// </returns>
ValueTask<string> GetTypeAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask<string?> GetTypeAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Determines whether the specified scopes are included in the authorization. /// Determines whether the specified scopes are included in the authorization.
@ -267,7 +266,7 @@ namespace OpenIddict.Abstractions
/// <param name="scopes">The scopes.</param> /// <param name="scopes">The scopes.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns><c>true</c> if the scopes are included in the authorization, <c>false</c> otherwise.</returns>
ValueTask<bool> HasScopesAsync([NotNull] object authorization, ImmutableArray<string> scopes, CancellationToken cancellationToken = default); ValueTask<bool> HasScopesAsync(object authorization, ImmutableArray<string> scopes, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Determines whether a given authorization has the specified status. /// Determines whether a given authorization has the specified status.
@ -276,7 +275,7 @@ namespace OpenIddict.Abstractions
/// <param name="status">The expected status.</param> /// <param name="status">The expected status.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns><c>true</c> if the authorization has the specified status, <c>false</c> otherwise.</returns>
ValueTask<bool> HasStatusAsync([NotNull] object authorization, [NotNull] string status, CancellationToken cancellationToken = default); ValueTask<bool> HasStatusAsync(object authorization, string status, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Determines whether a given authorization has the specified type. /// Determines whether a given authorization has the specified type.
@ -285,7 +284,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The expected type.</param> /// <param name="type">The expected type.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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 type, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the authorization has the specified type, <c>false</c> otherwise.</returns>
ValueTask<bool> HasTypeAsync([NotNull] object authorization, [NotNull] string type, CancellationToken cancellationToken = default); ValueTask<bool> HasTypeAsync(object authorization, string type, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -295,7 +294,7 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<object> ListAsync( IAsyncEnumerable<object> ListAsync(
[CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default); int? count = null, int? offset = null, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -305,7 +304,7 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TResult>( IAsyncEnumerable<TResult> ListAsync<TResult>(
[NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -317,8 +316,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TState, TResult>( IAsyncEnumerable<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<object>, TState, IQueryable<TResult>> query, Func<IQueryable<object>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default); TState state, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Populates the specified descriptor using the properties exposed by the authorization. /// Populates the specified descriptor using the properties exposed by the authorization.
@ -329,7 +328,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask PopulateAsync([NotNull] OpenIddictAuthorizationDescriptor descriptor, [NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask PopulateAsync(OpenIddictAuthorizationDescriptor descriptor, object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Populates the authorization using the specified descriptor. /// Populates the authorization using the specified descriptor.
@ -340,7 +339,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask PopulateAsync([NotNull] object authorization, [NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask PopulateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Removes the authorizations that are marked as invalid and the ad-hoc ones that have no valid/nonexpired token attached. /// Removes the authorizations that are marked as invalid and the ad-hoc ones that have no valid/nonexpired token attached.
@ -360,7 +359,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask SetApplicationIdAsync([NotNull] object authorization, [CanBeNull] string identifier, CancellationToken cancellationToken = default); ValueTask SetApplicationIdAsync(object authorization, string? identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Tries to revoke an authorization. /// Tries to revoke an authorization.
@ -368,7 +367,7 @@ namespace OpenIddict.Abstractions
/// <param name="authorization">The authorization to revoke.</param> /// <param name="authorization">The authorization to revoke.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns><c>true</c> if the authorization was successfully revoked, <c>false</c> otherwise.</returns>
ValueTask<bool> TryRevokeAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask<bool> TryRevokeAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing authorization. /// Updates an existing authorization.
@ -378,7 +377,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask UpdateAsync([NotNull] object authorization, CancellationToken cancellationToken = default); ValueTask UpdateAsync(object authorization, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing authorization. /// Updates an existing authorization.
@ -389,7 +388,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask UpdateAsync([NotNull] object authorization, [NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask UpdateAsync(object authorization, OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Validates the authorization to ensure it's in a consistent state. /// Validates the authorization to ensure it's in a consistent state.
@ -397,6 +396,6 @@ namespace OpenIddict.Abstractions
/// <param name="authorization">The authorization.</param> /// <param name="authorization">The authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>The validation error encountered when validating the authorization.</returns>
IAsyncEnumerable<ValidationResult> ValidateAsync([NotNull] object authorization, CancellationToken cancellationToken = default); IAsyncEnumerable<ValidationResult> ValidateAsync(object authorization, CancellationToken cancellationToken = default);
} }
} }

61
src/OpenIddict.Abstractions/Managers/IOpenIddictScopeManager.cs

@ -6,7 +6,6 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -40,7 +39,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of scopes that match the specified query. /// whose result returns the number of scopes that match the specified query.
/// </returns> /// </returns>
ValueTask<long> CountAsync<TResult>([NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); ValueTask<long> CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new scope based on the specified descriptor. /// Creates a new scope based on the specified descriptor.
@ -50,7 +49,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the scope. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the scope.
/// </returns> /// </returns>
ValueTask<object> CreateAsync([NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask<object> CreateAsync(OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new scope. /// Creates a new scope.
@ -60,7 +59,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask CreateAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask CreateAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Removes an existing scope. /// Removes an existing scope.
@ -70,7 +69,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask DeleteAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask DeleteAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves a scope using its unique identifier. /// Retrieves a scope using its unique identifier.
@ -81,7 +80,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scope corresponding to the identifier. /// whose result returns the scope corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<object> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); ValueTask<object?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves a scope using its name. /// Retrieves a scope using its name.
@ -92,7 +91,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scope corresponding to the specified name. /// whose result returns the scope corresponding to the specified name.
/// </returns> /// </returns>
ValueTask<object> FindByNameAsync([NotNull] string name, CancellationToken cancellationToken = default); ValueTask<object?> FindByNameAsync(string name, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves a list of scopes using their name. /// Retrieves a list of scopes using their name.
@ -108,7 +107,7 @@ namespace OpenIddict.Abstractions
/// <param name="resource">The resource associated with the scopes.</param> /// <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> /// <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> /// <returns>The scopes associated with the specified resource.</returns>
IAsyncEnumerable<object> FindByResourceAsync([NotNull] string resource, CancellationToken cancellationToken = default); IAsyncEnumerable<object> FindByResourceAsync(string resource, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -121,7 +120,7 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TResult>( ValueTask<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -136,8 +135,8 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TState, TResult>( ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<object>, TState, IQueryable<TResult>> query, Func<IQueryable<object>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default); TState state, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the description associated with a scope. /// Retrieves the description associated with a scope.
@ -148,7 +147,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the description associated with the specified scope. /// whose result returns the description associated with the specified scope.
/// </returns> /// </returns>
ValueTask<string> GetDescriptionAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask<string?> GetDescriptionAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the localized descriptions associated with an scope. /// Retrieves the localized descriptions associated with an scope.
@ -159,7 +158,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the localized descriptions associated with the scope. /// whose result returns all the localized descriptions associated with the scope.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<CultureInfo, string>> GetDescriptionsAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask<ImmutableDictionary<CultureInfo, string>> GetDescriptionsAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the display name associated with a scope. /// Retrieves the display name associated with a scope.
@ -170,7 +169,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope. /// whose result returns the display name associated with the scope.
/// </returns> /// </returns>
ValueTask<string> GetDisplayNameAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask<string?> GetDisplayNameAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the localized display names associated with an scope. /// Retrieves the localized display names associated with an scope.
@ -181,7 +180,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the localized display names associated with the scope. /// whose result returns all the localized display names associated with the scope.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the unique identifier associated with a scope. /// Retrieves the unique identifier associated with a scope.
@ -192,7 +191,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the scope. /// whose result returns the unique identifier associated with the scope.
/// </returns> /// </returns>
ValueTask<string> GetIdAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask<string?> GetIdAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the localized description associated with an scope /// Retrieves the localized description associated with an scope
@ -205,7 +204,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the matching localized description associated with the scope.
/// </returns> /// </returns>
ValueTask<string> GetLocalizedDescriptionAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask<string?> GetLocalizedDescriptionAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the localized description associated with an scope /// Retrieves the localized description associated with an scope
@ -219,7 +218,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the matching localized description associated with the scope.
/// </returns> /// </returns>
ValueTask<string> GetLocalizedDescriptionAsync([NotNull] object scope, [NotNull] CultureInfo culture, CancellationToken cancellationToken = default); ValueTask<string?> GetLocalizedDescriptionAsync(object scope, CultureInfo culture, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the localized display name associated with an scope /// Retrieves the localized display name associated with an scope
@ -232,7 +231,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope. /// whose result returns the display name associated with the scope.
/// </returns> /// </returns>
ValueTask<string> GetLocalizedDisplayNameAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask<string?> GetLocalizedDisplayNameAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the localized display name associated with an scope /// Retrieves the localized display name associated with an scope
@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope. /// whose result returns the display name associated with the scope.
/// </returns> /// </returns>
ValueTask<string> GetLocalizedDisplayNameAsync([NotNull] object scope, [NotNull] CultureInfo culture, CancellationToken cancellationToken = default); ValueTask<string?> GetLocalizedDisplayNameAsync(object scope, CultureInfo culture, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the name associated with a scope. /// Retrieves the name associated with a scope.
@ -257,7 +256,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the name associated with the specified scope. /// whose result returns the name associated with the specified scope.
/// </returns> /// </returns>
ValueTask<string> GetNameAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask<string?> GetNameAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the resources associated with a scope. /// Retrieves the resources associated with a scope.
@ -268,7 +267,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the resources associated with the scope. /// whose result returns all the resources associated with the scope.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetResourcesAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask<ImmutableArray<string>> GetResourcesAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -278,7 +277,7 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<object> ListAsync( IAsyncEnumerable<object> ListAsync(
[CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default); int? count = null, int? offset = null, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -288,7 +287,7 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TResult>( IAsyncEnumerable<TResult> ListAsync<TResult>(
[NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -300,8 +299,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TState, TResult>( IAsyncEnumerable<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<object>, TState, IQueryable<TResult>> query, Func<IQueryable<object>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default); TState state, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Lists all the resources associated with the specified scopes. /// Lists all the resources associated with the specified scopes.
@ -320,7 +319,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask PopulateAsync([NotNull] OpenIddictScopeDescriptor descriptor, [NotNull] object scope, CancellationToken cancellationToken = default); ValueTask PopulateAsync(OpenIddictScopeDescriptor descriptor, object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Populates the scope using the specified descriptor. /// Populates the scope using the specified descriptor.
@ -331,7 +330,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask PopulateAsync([NotNull] object scope, [NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask PopulateAsync(object scope, OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing scope. /// Updates an existing scope.
@ -341,7 +340,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask UpdateAsync([NotNull] object scope, CancellationToken cancellationToken = default); ValueTask UpdateAsync(object scope, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing scope. /// Updates an existing scope.
@ -352,7 +351,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask UpdateAsync([NotNull] object scope, [NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask UpdateAsync(object scope, OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Validates the scope to ensure it's in a consistent state. /// Validates the scope to ensure it's in a consistent state.
@ -360,6 +359,6 @@ namespace OpenIddict.Abstractions
/// <param name="scope">The scope.</param> /// <param name="scope">The scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>The validation error encountered when validating the scope.</returns>
IAsyncEnumerable<ValidationResult> ValidateAsync([NotNull] object scope, CancellationToken cancellationToken = default); IAsyncEnumerable<ValidationResult> ValidateAsync(object scope, CancellationToken cancellationToken = default);
} }
} }

91
src/OpenIddict.Abstractions/Managers/IOpenIddictTokenManager.cs

@ -4,7 +4,6 @@ using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -38,7 +37,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of tokens that match the specified query. /// whose result returns the number of tokens that match the specified query.
/// </returns> /// </returns>
ValueTask<long> CountAsync<TResult>([NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); ValueTask<long> CountAsync<TResult>(Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new token based on the specified descriptor. /// Creates a new token based on the specified descriptor.
@ -48,7 +47,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the token. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, whose result returns the token.
/// </returns> /// </returns>
ValueTask<object> CreateAsync([NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask<object> CreateAsync(OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Creates a new token. /// Creates a new token.
@ -58,7 +57,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask CreateAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask CreateAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Removes an existing token. /// Removes an existing token.
@ -68,7 +67,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask DeleteAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask DeleteAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the tokens corresponding to the specified /// Retrieves the tokens corresponding to the specified
@ -78,8 +77,8 @@ namespace OpenIddict.Abstractions
/// <param name="client">The client 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> /// <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> /// <returns>The tokens corresponding to the subject/client.</returns>
IAsyncEnumerable<object> FindAsync([NotNull] string subject, IAsyncEnumerable<object> FindAsync(string subject,
[NotNull] string client, CancellationToken cancellationToken = default); string client, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the tokens matching the specified parameters. /// Retrieves the tokens matching the specified parameters.
@ -90,8 +89,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The tokens corresponding to the criteria.</returns>
IAsyncEnumerable<object> FindAsync( IAsyncEnumerable<object> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, CancellationToken cancellationToken = default); string status, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the tokens matching the specified parameters. /// Retrieves the tokens matching the specified parameters.
@ -103,8 +102,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The tokens corresponding to the criteria.</returns>
IAsyncEnumerable<object> FindAsync( IAsyncEnumerable<object> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, [NotNull] string type, CancellationToken cancellationToken = default); string status, string type, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified application identifier. /// Retrieves the list of tokens corresponding to the specified application identifier.
@ -112,7 +111,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The application identifier associated with the tokens.</param> /// <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> /// <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> /// <returns>The tokens corresponding to the specified application.</returns>
IAsyncEnumerable<object> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); IAsyncEnumerable<object> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified authorization identifier. /// Retrieves the list of tokens corresponding to the specified authorization identifier.
@ -120,7 +119,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The authorization identifier associated with the tokens.</param> /// <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> /// <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> /// <returns>The tokens corresponding to the specified authorization.</returns>
IAsyncEnumerable<object> FindByAuthorizationIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); IAsyncEnumerable<object> FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves a token using its unique identifier. /// Retrieves a token using its unique identifier.
@ -131,7 +130,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the token corresponding to the unique identifier. /// whose result returns the token corresponding to the unique identifier.
/// </returns> /// </returns>
ValueTask<object> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); ValueTask<object?> FindByIdAsync(string identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified reference identifier. /// Retrieves the list of tokens corresponding to the specified reference identifier.
@ -143,7 +142,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified reference identifier. /// whose result returns the tokens corresponding to the specified reference identifier.
/// </returns> /// </returns>
ValueTask<object> FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default); ValueTask<object?> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified subject. /// Retrieves the list of tokens corresponding to the specified subject.
@ -151,7 +150,7 @@ namespace OpenIddict.Abstractions
/// <param name="subject">The subject associated with the tokens.</param> /// <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> /// <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> /// <returns>The tokens corresponding to the specified subject.</returns>
IAsyncEnumerable<object> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken = default); IAsyncEnumerable<object> FindBySubjectAsync(string subject, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the optional application identifier associated with a token. /// Retrieves the optional application identifier associated with a token.
@ -162,7 +161,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the token. /// whose result returns the application identifier associated with the token.
/// </returns> /// </returns>
ValueTask<string> GetApplicationIdAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<string?> GetApplicationIdAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -175,7 +174,7 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TResult>( ValueTask<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -190,8 +189,8 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TState, TResult>( ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<object>, TState, IQueryable<TResult>> query, Func<IQueryable<object>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default); TState state, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the optional authorization identifier associated with a token. /// Retrieves the optional authorization identifier associated with a token.
@ -202,7 +201,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization identifier associated with the token. /// whose result returns the authorization identifier associated with the token.
/// </returns> /// </returns>
ValueTask<string> GetAuthorizationIdAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<string?> GetAuthorizationIdAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the creation date associated with a token. /// Retrieves the creation date associated with a token.
@ -213,7 +212,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the creation date associated with the specified token.
/// </returns> /// </returns>
ValueTask<DateTimeOffset?> GetCreationDateAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<DateTimeOffset?> GetCreationDateAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the expiration date associated with a token. /// Retrieves the expiration date associated with a token.
@ -224,7 +223,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the expiration date associated with the specified token.
/// </returns> /// </returns>
ValueTask<DateTimeOffset?> GetExpirationDateAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<DateTimeOffset?> GetExpirationDateAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the unique identifier associated with a token. /// Retrieves the unique identifier associated with a token.
@ -235,7 +234,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the token. /// whose result returns the unique identifier associated with the token.
/// </returns> /// </returns>
ValueTask<string> GetIdAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<string?> GetIdAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the payload associated with a token. /// Retrieves the payload associated with a token.
@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the payload associated with the specified token. /// whose result returns the payload associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetPayloadAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<string?> GetPayloadAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the reference identifier associated with a token. /// Retrieves the reference identifier associated with a token.
@ -259,7 +258,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the reference identifier associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetReferenceIdAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<string?> GetReferenceIdAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the status associated with a token. /// Retrieves the status associated with a token.
@ -270,7 +269,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified token. /// whose result returns the status associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetStatusAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<string?> GetStatusAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the subject associated with a token. /// Retrieves the subject associated with a token.
@ -281,7 +280,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the subject associated with the specified token. /// whose result returns the subject associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetSubjectAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<string?> GetSubjectAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Retrieves the token type associated with a token. /// Retrieves the token type associated with a token.
@ -292,7 +291,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the token type associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetTypeAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<string?> GetTypeAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Determines whether a given token has the specified status. /// Determines whether a given token has the specified status.
@ -301,7 +300,7 @@ namespace OpenIddict.Abstractions
/// <param name="status">The expected status.</param> /// <param name="status">The expected status.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns><c>true</c> if the token has the specified status, <c>false</c> otherwise.</returns>
ValueTask<bool> HasStatusAsync([NotNull] object token, [NotNull] string status, CancellationToken cancellationToken = default); ValueTask<bool> HasStatusAsync(object token, string status, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Determines whether a given token has the specified type. /// Determines whether a given token has the specified type.
@ -310,7 +309,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The expected type.</param> /// <param name="type">The expected type.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns><c>true</c> if the token has the specified type, <c>false</c> otherwise.</returns>
ValueTask<bool> HasTypeAsync([NotNull] object token, [NotNull] string type, CancellationToken cancellationToken = default); ValueTask<bool> HasTypeAsync(object token, string type, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -320,7 +319,7 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<object> ListAsync( IAsyncEnumerable<object> ListAsync(
[CanBeNull] int? count = null, [CanBeNull] int? offset = null, CancellationToken cancellationToken = default); int? count = null, int? offset = null, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -330,7 +329,7 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TResult>( IAsyncEnumerable<TResult> ListAsync<TResult>(
[NotNull] Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default); Func<IQueryable<object>, IQueryable<TResult>> query, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -342,8 +341,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TState, TResult>( IAsyncEnumerable<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<object>, TState, IQueryable<TResult>> query, Func<IQueryable<object>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken = default); TState state, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Populates the specified descriptor using the properties exposed by the token. /// Populates the specified descriptor using the properties exposed by the token.
@ -354,7 +353,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask PopulateAsync([NotNull] OpenIddictTokenDescriptor descriptor, [NotNull] object token, CancellationToken cancellationToken = default); ValueTask PopulateAsync(OpenIddictTokenDescriptor descriptor, object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Populates the token using the specified descriptor. /// Populates the token using the specified descriptor.
@ -365,7 +364,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask PopulateAsync([NotNull] object token, [NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask PopulateAsync(object token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Removes the tokens that are marked as expired or invalid. /// Removes the tokens that are marked as expired or invalid.
@ -385,7 +384,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask SetApplicationIdAsync([NotNull] object token, [CanBeNull] string identifier, CancellationToken cancellationToken = default); ValueTask SetApplicationIdAsync(object token, string? identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Sets the authorization identifier associated with a token. /// Sets the authorization identifier associated with a token.
@ -396,7 +395,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask SetAuthorizationIdAsync([NotNull] object token, [CanBeNull] string identifier, CancellationToken cancellationToken = default); ValueTask SetAuthorizationIdAsync(object token, string? identifier, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Tries to extend the specified token by replacing its expiration date. /// Tries to extend the specified token by replacing its expiration date.
@ -405,7 +404,7 @@ namespace OpenIddict.Abstractions
/// <param name="date">The date on which the token will no longer be considered valid.</param> /// <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> /// <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> /// <returns><c>true</c> if the token was successfully extended, <c>false</c> otherwise.</returns>
ValueTask<bool> TryExtendAsync([NotNull] object token, [CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken = default); ValueTask<bool> TryExtendAsync(object token, DateTimeOffset? date, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Tries to redeem a token. /// Tries to redeem a token.
@ -413,7 +412,7 @@ namespace OpenIddict.Abstractions
/// <param name="token">The token to redeem.</param> /// <param name="token">The token to redeem.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns><c>true</c> if the token was successfully redemeed, <c>false</c> otherwise.</returns>
ValueTask<bool> TryRedeemAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<bool> TryRedeemAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Tries to reject a token. /// Tries to reject a token.
@ -421,7 +420,7 @@ namespace OpenIddict.Abstractions
/// <param name="token">The token to reject.</param> /// <param name="token">The token to reject.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns><c>true</c> if the token was successfully redemeed, <c>false</c> otherwise.</returns>
ValueTask<bool> TryRejectAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<bool> TryRejectAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Tries to revoke a token. /// Tries to revoke a token.
@ -429,7 +428,7 @@ namespace OpenIddict.Abstractions
/// <param name="token">The token to revoke.</param> /// <param name="token">The token to revoke.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns><c>true</c> if the token was successfully revoked, <c>false</c> otherwise.</returns>
ValueTask<bool> TryRevokeAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask<bool> TryRevokeAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing token. /// Updates an existing token.
@ -439,7 +438,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask UpdateAsync([NotNull] object token, CancellationToken cancellationToken = default); ValueTask UpdateAsync(object token, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Updates an existing token. /// Updates an existing token.
@ -450,7 +449,7 @@ namespace OpenIddict.Abstractions
/// <returns> /// <returns>
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation. /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.
/// </returns> /// </returns>
ValueTask UpdateAsync([NotNull] object token, [NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default); ValueTask UpdateAsync(object token, OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default);
/// <summary> /// <summary>
/// Validates the token to ensure it's in a consistent state. /// Validates the token to ensure it's in a consistent state.
@ -458,6 +457,6 @@ namespace OpenIddict.Abstractions
/// <param name="token">The token.</param> /// <param name="token">The token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>The validation error encountered when validating the token.</returns>
IAsyncEnumerable<ValidationResult> ValidateAsync([NotNull] object token, CancellationToken cancellationToken = default); IAsyncEnumerable<ValidationResult> ValidateAsync(object token, CancellationToken cancellationToken = default);
} }
} }

1
src/OpenIddict.Abstractions/OpenIddict.Abstractions.csproj

@ -3,6 +3,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net461;netstandard2.0;netstandard2.1</TargetFrameworks> <TargetFrameworks>net461;netstandard2.0;netstandard2.1</TargetFrameworks>
<GenerateResxSourceEmitFormatMethods>true</GenerateResxSourceEmitFormatMethods> <GenerateResxSourceEmitFormatMethods>true</GenerateResxSourceEmitFormatMethods>
<Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>

7
src/OpenIddict.Abstractions/OpenIddictBuilder.cs

@ -6,7 +6,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using JetBrains.Annotations;
namespace Microsoft.Extensions.DependencyInjection namespace Microsoft.Extensions.DependencyInjection
{ {
@ -19,7 +18,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// Initializes a new instance of <see cref="OpenIddictBuilder"/>. /// Initializes a new instance of <see cref="OpenIddictBuilder"/>.
/// </summary> /// </summary>
/// <param name="services">The services collection.</param> /// <param name="services">The services collection.</param>
public OpenIddictBuilder([NotNull] IServiceCollection services) public OpenIddictBuilder(IServiceCollection services)
=> Services = services ?? throw new ArgumentNullException(nameof(services)); => Services = services ?? throw new ArgumentNullException(nameof(services));
/// <summary> /// <summary>
@ -34,7 +33,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="obj">The object to compare with the current object.</param> /// <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> /// <returns><c>true</c> if the specified object is equal to the current object; otherwise, false.</returns>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals([CanBeNull] object obj) => base.Equals(obj); public override bool Equals(object? obj) => base.Equals(obj);
/// <summary> /// <summary>
/// Serves as the default hash function. /// Serves as the default hash function.
@ -48,6 +47,6 @@ namespace Microsoft.Extensions.DependencyInjection
/// </summary> /// </summary>
/// <returns>A string that represents the current object.</returns> /// <returns>A string that represents the current object.</returns>
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public override string ToString() => base.ToString(); public override string? ToString() => base.ToString();
} }
} }

24
src/OpenIddict.Abstractions/OpenIddictExceptions.cs

@ -18,7 +18,7 @@ namespace OpenIddict.Abstractions
/// Creates a new <see cref="ConcurrencyException"/>. /// Creates a new <see cref="ConcurrencyException"/>.
/// </summary> /// </summary>
/// <param name="message">The exception message.</param> /// <param name="message">The exception message.</param>
public ConcurrencyException(string message) public ConcurrencyException(string? message)
: this(message, exception: null) : this(message, exception: null)
{ {
} }
@ -28,7 +28,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="message">The exception message.</param> /// <param name="message">The exception message.</param>
/// <param name="exception">The inner exception.</param> /// <param name="exception">The inner exception.</param>
public ConcurrencyException(string message, Exception exception) public ConcurrencyException(string? message, Exception? exception)
: base(message, exception) : base(message, exception)
{ {
} }
@ -43,7 +43,7 @@ namespace OpenIddict.Abstractions
/// Creates a new <see cref="GenericException"/>. /// Creates a new <see cref="GenericException"/>.
/// </summary> /// </summary>
/// <param name="message">The exception message.</param> /// <param name="message">The exception message.</param>
public GenericException(string message) public GenericException(string? message)
: this(message, null) : this(message, null)
{ {
} }
@ -53,7 +53,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="message">The exception message.</param> /// <param name="message">The exception message.</param>
/// <param name="error">The error type.</param> /// <param name="error">The error type.</param>
public GenericException(string message, string error) public GenericException(string? message, string? error)
: this(message, error, description: null) : this(message, error, description: null)
{ {
} }
@ -64,7 +64,7 @@ namespace OpenIddict.Abstractions
/// <param name="message">The exception message.</param> /// <param name="message">The exception message.</param>
/// <param name="error">The error type.</param> /// <param name="error">The error type.</param>
/// <param name="description">The error description.</param> /// <param name="description">The error description.</param>
public GenericException(string message, string error, string description) public GenericException(string? message, string? error, string? description)
: this(message, error, description, uri: null) : this(message, error, description, uri: null)
{ {
} }
@ -76,7 +76,7 @@ namespace OpenIddict.Abstractions
/// <param name="error">The error type.</param> /// <param name="error">The error type.</param>
/// <param name="description">The error description.</param> /// <param name="description">The error description.</param>
/// <param name="uri">The error URI.</param> /// <param name="uri">The error URI.</param>
public GenericException(string message, string error, string description, string uri) public GenericException(string? message, string? error, string? description, string? uri)
: base(message) : base(message)
{ {
Error = error; Error = error;
@ -87,17 +87,17 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets the error type. /// Gets the error type.
/// </summary> /// </summary>
public string Error { get; } public string? Error { get; }
/// <summary> /// <summary>
/// Gets the error description. /// Gets the error description.
/// </summary> /// </summary>
public string ErrorDescription { get; } public string? ErrorDescription { get; }
/// <summary> /// <summary>
/// Gets the error URI. /// Gets the error URI.
/// </summary> /// </summary>
public string ErrorUri { get; } public string? ErrorUri { get; }
} }
/// <summary> /// <summary>
@ -109,7 +109,7 @@ namespace OpenIddict.Abstractions
/// Creates a new <see cref="ValidationException"/>. /// Creates a new <see cref="ValidationException"/>.
/// </summary> /// </summary>
/// <param name="message">The exception message.</param> /// <param name="message">The exception message.</param>
public ValidationException(string message) public ValidationException(string? message)
: this(message, ImmutableArray.Create<ValidationResult>()) : this(message, ImmutableArray.Create<ValidationResult>())
{ {
} }
@ -119,7 +119,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="message">The exception message.</param> /// <param name="message">The exception message.</param>
/// <param name="results">The validation results.</param> /// <param name="results">The validation results.</param>
public ValidationException(string message, ImmutableArray<ValidationResult> results) public ValidationException(string? message, ImmutableArray<ValidationResult> results)
: this(message, results, exception: null) : this(message, results, exception: null)
{ {
} }
@ -130,7 +130,7 @@ namespace OpenIddict.Abstractions
/// <param name="message">The exception message.</param> /// <param name="message">The exception message.</param>
/// <param name="results">The validation results.</param> /// <param name="results">The validation results.</param>
/// <param name="exception">The inner exception.</param> /// <param name="exception">The inner exception.</param>
public ValidationException(string message, ImmutableArray<ValidationResult> results, Exception exception) public ValidationException(string? message, ImmutableArray<ValidationResult> results, Exception? exception)
: base(message, exception) : base(message, exception)
{ {
Results = results; Results = results;

7
src/OpenIddict.Abstractions/OpenIddictExtensions.cs

@ -5,7 +5,6 @@
*/ */
using System; using System;
using JetBrains.Annotations;
namespace Microsoft.Extensions.DependencyInjection namespace Microsoft.Extensions.DependencyInjection
{ {
@ -20,7 +19,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="services">The services collection.</param> /// <param name="services">The services collection.</param>
/// <remarks>This extension can be safely called multiple times.</remarks> /// <remarks>This extension can be safely called multiple times.</remarks>
/// <returns>The <see cref="OpenIddictBuilder"/>.</returns> /// <returns>The <see cref="OpenIddictBuilder"/>.</returns>
public static OpenIddictBuilder AddOpenIddict([NotNull] this IServiceCollection services) public static OpenIddictBuilder AddOpenIddict(this IServiceCollection services)
{ {
if (services == null) if (services == null)
{ {
@ -37,9 +36,7 @@ namespace Microsoft.Extensions.DependencyInjection
/// <param name="configuration">The configuration delegate used to register new services.</param> /// <param name="configuration">The configuration delegate used to register new services.</param>
/// <remarks>This extension can be safely called multiple times.</remarks> /// <remarks>This extension can be safely called multiple times.</remarks>
/// <returns>The <see cref="IServiceCollection"/>.</returns> /// <returns>The <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddOpenIddict( public static IServiceCollection AddOpenIddict(this IServiceCollection services, Action<OpenIddictBuilder> configuration)
[NotNull] this IServiceCollection services,
[NotNull] Action<OpenIddictBuilder> configuration)
{ {
if (services == null) if (services == null)
{ {

3
src/OpenIddict.Abstractions/Primitives/OpenIddictConverter.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using JetBrains.Annotations;
using SR = OpenIddict.Abstractions.OpenIddictResources; using SR = OpenIddict.Abstractions.OpenIddictResources;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
@ -22,7 +21,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="typeToConvert">The type to convert.</param> /// <param name="typeToConvert">The type to convert.</param>
/// <returns><c>true</c> if the type is supported, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the type is supported, <c>false</c> otherwise.</returns>
public override bool CanConvert([NotNull] Type typeToConvert) public override bool CanConvert(Type typeToConvert)
{ {
if (typeToConvert == null) if (typeToConvert == null)
{ {

286
src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs

@ -13,7 +13,6 @@ using System.Linq;
using System.Security.Claims; using System.Security.Claims;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using JetBrains.Annotations;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
using static OpenIddict.Abstractions.OpenIddictConstants; using static OpenIddict.Abstractions.OpenIddictConstants;
using SR = OpenIddict.Abstractions.OpenIddictResources; using SR = OpenIddict.Abstractions.OpenIddictResources;
@ -30,76 +29,56 @@ namespace OpenIddict.Abstractions
/// Extracts the authentication context class values from an <see cref="OpenIddictRequest"/>. /// Extracts the authentication context class values from an <see cref="OpenIddictRequest"/>.
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
public static ImmutableArray<string> GetAcrValues([NotNull] this OpenIddictRequest request) public static ImmutableArray<string> GetAcrValues(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
throw new ArgumentNullException(nameof(request)); throw new ArgumentNullException(nameof(request));
} }
if (string.IsNullOrEmpty(request.AcrValues)) return GetValues(request.AcrValues, Separators.Space);
{
return ImmutableArray.Create<string>();
}
return GetValues(request.AcrValues, Separators.Space).Distinct(StringComparer.Ordinal).ToImmutableArray();
} }
/// <summary> /// <summary>
/// Extracts the prompt values from an <see cref="OpenIddictRequest"/>. /// Extracts the prompt values from an <see cref="OpenIddictRequest"/>.
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
public static ImmutableArray<string> GetPrompts([NotNull] this OpenIddictRequest request) public static ImmutableArray<string> GetPrompts(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
throw new ArgumentNullException(nameof(request)); throw new ArgumentNullException(nameof(request));
} }
if (string.IsNullOrEmpty(request.Prompt)) return GetValues(request.Prompt, Separators.Space);
{
return ImmutableArray.Create<string>();
}
return GetValues(request.Prompt, Separators.Space).Distinct(StringComparer.Ordinal).ToImmutableArray();
} }
/// <summary> /// <summary>
/// Extracts the response types from an <see cref="OpenIddictRequest"/>. /// Extracts the response types from an <see cref="OpenIddictRequest"/>.
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
public static ImmutableArray<string> GetResponseTypes([NotNull] this OpenIddictRequest request) public static ImmutableArray<string> GetResponseTypes(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
throw new ArgumentNullException(nameof(request)); throw new ArgumentNullException(nameof(request));
} }
if (string.IsNullOrEmpty(request.ResponseType)) return GetValues(request.ResponseType, Separators.Space);
{
return ImmutableArray.Create<string>();
}
return GetValues(request.ResponseType, Separators.Space).Distinct(StringComparer.Ordinal).ToImmutableArray();
} }
/// <summary> /// <summary>
/// Extracts the scopes from an <see cref="OpenIddictRequest"/>. /// Extracts the scopes from an <see cref="OpenIddictRequest"/>.
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
public static ImmutableArray<string> GetScopes([NotNull] this OpenIddictRequest request) public static ImmutableArray<string> GetScopes(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
throw new ArgumentNullException(nameof(request)); throw new ArgumentNullException(nameof(request));
} }
if (string.IsNullOrEmpty(request.Scope)) return GetValues(request.Scope, Separators.Space);
{
return ImmutableArray.Create<string>();
}
return GetValues(request.Scope, Separators.Space).Distinct(StringComparer.Ordinal).ToImmutableArray();
} }
/// <summary> /// <summary>
@ -107,7 +86,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <param name="value">The component to look for in the parameter.</param> /// <param name="value">The component to look for in the parameter.</param>
public static bool HasAcrValue([NotNull] this OpenIddictRequest request, [NotNull] string value) public static bool HasAcrValue(this OpenIddictRequest request, string value)
{ {
if (request == null) if (request == null)
{ {
@ -127,7 +106,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <param name="prompt">The component to look for in the parameter.</param> /// <param name="prompt">The component to look for in the parameter.</param>
public static bool HasPrompt([NotNull] this OpenIddictRequest request, [NotNull] string prompt) public static bool HasPrompt(this OpenIddictRequest request, string prompt)
{ {
if (request == null) if (request == null)
{ {
@ -147,7 +126,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <param name="type">The component to look for in the parameter.</param> /// <param name="type">The component to look for in the parameter.</param>
public static bool HasResponseType([NotNull] this OpenIddictRequest request, [NotNull] string type) public static bool HasResponseType(this OpenIddictRequest request, string type)
{ {
if (request == null) if (request == null)
{ {
@ -167,7 +146,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <param name="scope">The component to look for in the parameter.</param> /// <param name="scope">The component to look for in the parameter.</param>
public static bool HasScope([NotNull] this OpenIddictRequest request, [NotNull] string scope) public static bool HasScope(this OpenIddictRequest request, string scope)
{ {
if (request == null) if (request == null)
{ {
@ -188,7 +167,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <returns><c>true</c> if the request is a response_type=none request, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the request is a response_type=none request, <c>false</c> otherwise.</returns>
public static bool IsNoneFlow([NotNull] this OpenIddictRequest request) public static bool IsNoneFlow(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -215,7 +194,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <returns><c>true</c> if the request is a code flow request, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the request is a code flow request, <c>false</c> otherwise.</returns>
public static bool IsAuthorizationCodeFlow([NotNull] this OpenIddictRequest request) public static bool IsAuthorizationCodeFlow(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -243,7 +222,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <returns><c>true</c> if the request is an implicit flow request, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the request is an implicit flow request, <c>false</c> otherwise.</returns>
public static bool IsImplicitFlow([NotNull] this OpenIddictRequest request) public static bool IsImplicitFlow(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -297,7 +276,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <returns><c>true</c> if the request is an hybrid flow request, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the request is an hybrid flow request, <c>false</c> otherwise.</returns>
public static bool IsHybridFlow([NotNull] this OpenIddictRequest request) public static bool IsHybridFlow(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -364,7 +343,7 @@ namespace OpenIddict.Abstractions
/// <c>true</c> if the request specified the fragment response mode or if /// <c>true</c> if the request specified the fragment response mode or if
/// it's the default value for the requested flow, <c>false</c> otherwise. /// it's the default value for the requested flow, <c>false</c> otherwise.
/// </returns> /// </returns>
public static bool IsFragmentResponseMode([NotNull] this OpenIddictRequest request) public static bool IsFragmentResponseMode(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -397,7 +376,7 @@ namespace OpenIddict.Abstractions
/// <c>true</c> if the request specified the query response mode or if /// <c>true</c> if the request specified the query response mode or if
/// it's the default value for the requested flow, <c>false</c> otherwise. /// it's the default value for the requested flow, <c>false</c> otherwise.
/// </returns> /// </returns>
public static bool IsQueryResponseMode([NotNull] this OpenIddictRequest request) public static bool IsQueryResponseMode(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -429,7 +408,7 @@ namespace OpenIddict.Abstractions
/// <c>true</c> if the request specified the form post response mode or if /// <c>true</c> if the request specified the form post response mode or if
/// it's the default value for the requested flow, <c>false</c> otherwise. /// it's the default value for the requested flow, <c>false</c> otherwise.
/// </returns> /// </returns>
public static bool IsFormPostResponseMode([NotNull] this OpenIddictRequest request) public static bool IsFormPostResponseMode(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -445,7 +424,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <returns><c>true</c> if the request is a code grant request, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the request is a code grant request, <c>false</c> otherwise.</returns>
public static bool IsAuthorizationCodeGrantType([NotNull] this OpenIddictRequest request) public static bool IsAuthorizationCodeGrantType(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -461,7 +440,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <returns><c>true</c> if the request is a client credentials grant request, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the request is a client credentials grant request, <c>false</c> otherwise.</returns>
public static bool IsClientCredentialsGrantType([NotNull] this OpenIddictRequest request) public static bool IsClientCredentialsGrantType(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -477,7 +456,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <returns><c>true</c> if the request is a device code grant request, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the request is a device code grant request, <c>false</c> otherwise.</returns>
public static bool IsDeviceCodeGrantType([NotNull] this OpenIddictRequest request) public static bool IsDeviceCodeGrantType(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -493,7 +472,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <returns><c>true</c> if the request is a password grant request, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the request is a password grant request, <c>false</c> otherwise.</returns>
public static bool IsPasswordGrantType([NotNull] this OpenIddictRequest request) public static bool IsPasswordGrantType(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -509,7 +488,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param> /// <param name="request">The <see cref="OpenIddictRequest"/> instance.</param>
/// <returns><c>true</c> if the request is a refresh token grant request, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the request is a refresh token grant request, <c>false</c> otherwise.</returns>
public static bool IsRefreshTokenGrantType([NotNull] this OpenIddictRequest request) public static bool IsRefreshTokenGrantType(this OpenIddictRequest request)
{ {
if (request == null) if (request == null)
{ {
@ -524,14 +503,14 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="claim">The <see cref="Claim"/> instance.</param> /// <param name="claim">The <see cref="Claim"/> instance.</param>
/// <returns>The destinations associated with the claim.</returns> /// <returns>The destinations associated with the claim.</returns>
public static ImmutableArray<string> GetDestinations([NotNull] this Claim claim) public static ImmutableArray<string> GetDestinations(this Claim claim)
{ {
if (claim == null) if (claim == null)
{ {
throw new ArgumentNullException(nameof(claim)); throw new ArgumentNullException(nameof(claim));
} }
claim.Properties.TryGetValue(Properties.Destinations, out string destinations); claim.Properties.TryGetValue(Properties.Destinations, out string? destinations);
if (string.IsNullOrEmpty(destinations)) if (string.IsNullOrEmpty(destinations))
{ {
@ -548,7 +527,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="claim">The <see cref="Claim"/> instance.</param> /// <param name="claim">The <see cref="Claim"/> instance.</param>
/// <param name="destination">The required destination.</param> /// <param name="destination">The required destination.</param>
public static bool HasDestination([NotNull] this Claim claim, [NotNull] string destination) public static bool HasDestination(this Claim claim, string destination)
{ {
if (claim == null) if (claim == null)
{ {
@ -560,7 +539,7 @@ namespace OpenIddict.Abstractions
throw new ArgumentException(SR.GetResourceString(SR.ID1180), nameof(destination)); throw new ArgumentException(SR.GetResourceString(SR.ID1180), nameof(destination));
} }
claim.Properties.TryGetValue(Properties.Destinations, out string destinations); claim.Properties.TryGetValue(Properties.Destinations, out string? destinations);
if (string.IsNullOrEmpty(destinations)) if (string.IsNullOrEmpty(destinations))
{ {
@ -576,7 +555,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="claim">The <see cref="Claim"/> instance.</param> /// <param name="claim">The <see cref="Claim"/> instance.</param>
/// <param name="destinations">The destinations.</param> /// <param name="destinations">The destinations.</param>
public static Claim SetDestinations([NotNull] this Claim claim, ImmutableArray<string> destinations) public static Claim SetDestinations(this Claim claim, ImmutableArray<string> destinations)
{ {
if (claim == null) if (claim == null)
{ {
@ -610,7 +589,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="claim">The <see cref="Claim"/> instance.</param> /// <param name="claim">The <see cref="Claim"/> instance.</param>
/// <param name="destinations">The destinations.</param> /// <param name="destinations">The destinations.</param>
public static Claim SetDestinations([NotNull] this Claim claim, [CanBeNull] IEnumerable<string> destinations) public static Claim SetDestinations(this Claim claim, IEnumerable<string>? destinations)
=> claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -618,7 +597,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="claim">The <see cref="Claim"/> instance.</param> /// <param name="claim">The <see cref="Claim"/> instance.</param>
/// <param name="destinations">The destinations.</param> /// <param name="destinations">The destinations.</param>
public static Claim SetDestinations([NotNull] this Claim claim, [CanBeNull] params string[] destinations) public static Claim SetDestinations(this Claim claim, params string[]? destinations)
=> claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -626,7 +605,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The principal.</param> /// <param name="principal">The principal.</param>
/// <returns>The destinations, returned as a flattened dictionary.</returns> /// <returns>The destinations, returned as a flattened dictionary.</returns>
public static ImmutableDictionary<string, string[]> GetDestinations([NotNull] this ClaimsPrincipal principal) public static ImmutableDictionary<string, string[]> GetDestinations(this ClaimsPrincipal principal)
{ {
if (principal == null) if (principal == null)
{ {
@ -664,9 +643,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The principal.</param> /// <param name="principal">The principal.</param>
/// <param name="destinations">The destinations, as a flattened dictionary.</param> /// <param name="destinations">The destinations, as a flattened dictionary.</param>
/// <returns>The principal.</returns> /// <returns>The principal.</returns>
public static ClaimsPrincipal SetDestinations( public static ClaimsPrincipal SetDestinations(this ClaimsPrincipal principal, ImmutableDictionary<string, string[]> destinations)
[NotNull] this ClaimsPrincipal principal,
[NotNull] ImmutableDictionary<string, string[]> destinations)
{ {
if (principal == null) if (principal == null)
{ {
@ -697,9 +674,7 @@ namespace OpenIddict.Abstractions
/// The delegate filtering the claims: return <c>true</c> /// The delegate filtering the claims: return <c>true</c>
/// to accept the claim, <c>false</c> to remove it. /// to accept the claim, <c>false</c> to remove it.
/// </param> /// </param>
public static ClaimsIdentity Clone( public static ClaimsIdentity Clone(this ClaimsIdentity identity, Func<Claim, bool> filter)
[NotNull] this ClaimsIdentity identity,
[NotNull] Func<Claim, bool> filter)
{ {
if (identity == null) if (identity == null)
{ {
@ -739,9 +714,7 @@ namespace OpenIddict.Abstractions
/// The delegate filtering the claims: return <c>true</c> /// The delegate filtering the claims: return <c>true</c>
/// to accept the claim, <c>false</c> to remove it. /// to accept the claim, <c>false</c> to remove it.
/// </param> /// </param>
public static ClaimsPrincipal Clone( public static ClaimsPrincipal Clone(this ClaimsPrincipal principal, Func<Claim, bool> filter)
[NotNull] this ClaimsPrincipal principal,
[NotNull] Func<Claim, bool> filter)
{ {
if (principal == null) if (principal == null)
{ {
@ -769,9 +742,7 @@ namespace OpenIddict.Abstractions
/// <param name="identity">The identity.</param> /// <param name="identity">The identity.</param>
/// <param name="type">The type associated with the claim.</param> /// <param name="type">The type associated with the claim.</param>
/// <param name="value">The value associated with the claim.</param> /// <param name="value">The value associated with the claim.</param>
public static ClaimsIdentity AddClaim( public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value)
[NotNull] this ClaimsIdentity identity,
[NotNull] string type, [NotNull] string value)
{ {
if (identity == null) if (identity == null)
{ {
@ -799,10 +770,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The type associated with the claim.</param> /// <param name="type">The type associated with the claim.</param>
/// <param name="value">The value associated with the claim.</param> /// <param name="value">The value associated with the claim.</param>
/// <param name="destinations">The destinations associated with the claim.</param> /// <param name="destinations">The destinations associated with the claim.</param>
public static ClaimsIdentity AddClaim( public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, ImmutableArray<string> destinations)
[NotNull] this ClaimsIdentity identity,
[NotNull] string type, [NotNull] string value,
[NotNull] ImmutableArray<string> destinations)
{ {
if (identity == null) if (identity == null)
{ {
@ -835,10 +803,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The type associated with the claim.</param> /// <param name="type">The type associated with the claim.</param>
/// <param name="value">The value associated with the claim.</param> /// <param name="value">The value associated with the claim.</param>
/// <param name="destinations">The destinations associated with the claim.</param> /// <param name="destinations">The destinations associated with the claim.</param>
public static ClaimsIdentity AddClaim( public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, params string[]? destinations)
[NotNull] this ClaimsIdentity identity,
[NotNull] string type, [NotNull] string value,
[NotNull] params string[] destinations)
=> identity.AddClaim(type, value, destinations?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => identity.AddClaim(type, value, destinations?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -847,7 +812,7 @@ namespace OpenIddict.Abstractions
/// <param name="identity">The identity.</param> /// <param name="identity">The identity.</param>
/// <param name="type">The type associated with the claim.</param> /// <param name="type">The type associated with the claim.</param>
/// <returns>The claim value.</returns> /// <returns>The claim value.</returns>
public static string GetClaim([NotNull] this ClaimsIdentity identity, [NotNull] string type) public static string? GetClaim(this ClaimsIdentity identity, string type)
{ {
if (identity == null) if (identity == null)
{ {
@ -868,7 +833,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The principal.</param> /// <param name="principal">The principal.</param>
/// <param name="type">The type associated with the claim.</param> /// <param name="type">The type associated with the claim.</param>
/// <returns>The claim value.</returns> /// <returns>The claim value.</returns>
public static string GetClaim([NotNull] this ClaimsPrincipal principal, [NotNull] string type) public static string? GetClaim(this ClaimsPrincipal principal, string type)
{ {
if (principal == null) if (principal == null)
{ {
@ -889,7 +854,7 @@ namespace OpenIddict.Abstractions
/// <param name="identity">The identity.</param> /// <param name="identity">The identity.</param>
/// <param name="type">The type associated with the claims.</param> /// <param name="type">The type associated with the claims.</param>
/// <returns>The claim values.</returns> /// <returns>The claim values.</returns>
public static ImmutableArray<string> GetClaims([NotNull] this ClaimsIdentity identity, [NotNull] string type) public static ImmutableArray<string> GetClaims(this ClaimsIdentity identity, string type)
{ {
if (identity == null) if (identity == null)
{ {
@ -910,7 +875,7 @@ namespace OpenIddict.Abstractions
/// <param name="identity">The claims identity.</param> /// <param name="identity">The claims identity.</param>
/// <param name="type">The claim type.</param> /// <param name="type">The claim type.</param>
/// <returns><c>true</c> if the identity contains at least one claim of the specified type.</returns> /// <returns><c>true</c> if the identity contains at least one claim of the specified type.</returns>
public static bool HasClaim([NotNull] this ClaimsIdentity identity, [NotNull] string type) public static bool HasClaim(this ClaimsIdentity identity, string type)
{ {
if (identity == null) if (identity == null)
{ {
@ -931,7 +896,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The principal.</param> /// <param name="principal">The principal.</param>
/// <param name="type">The type associated with the claims.</param> /// <param name="type">The type associated with the claims.</param>
/// <returns>The claim values.</returns> /// <returns>The claim values.</returns>
public static ImmutableArray<string> GetClaims([NotNull] this ClaimsPrincipal principal, [NotNull] string type) public static ImmutableArray<string> GetClaims(this ClaimsPrincipal principal, string type)
{ {
if (principal == null) if (principal == null)
{ {
@ -952,7 +917,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="type">The claim type.</param> /// <param name="type">The claim type.</param>
/// <returns><c>true</c> if the principal contains at least one claim of the specified type.</returns> /// <returns><c>true</c> if the principal contains at least one claim of the specified type.</returns>
public static bool HasClaim([NotNull] this ClaimsPrincipal principal, [NotNull] string type) public static bool HasClaim(this ClaimsPrincipal principal, string type)
{ {
if (principal == null) if (principal == null)
{ {
@ -973,7 +938,7 @@ namespace OpenIddict.Abstractions
/// <param name="identity">The identity.</param> /// <param name="identity">The identity.</param>
/// <param name="type">The type associated with the claims.</param> /// <param name="type">The type associated with the claims.</param>
/// <returns>The claims identity.</returns> /// <returns>The claims identity.</returns>
public static ClaimsIdentity RemoveClaims([NotNull] this ClaimsIdentity identity, [NotNull] string type) public static ClaimsIdentity RemoveClaims(this ClaimsIdentity identity, string type)
{ {
if (identity == null) if (identity == null)
{ {
@ -999,7 +964,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The principal.</param> /// <param name="principal">The principal.</param>
/// <param name="type">The type associated with the claims.</param> /// <param name="type">The type associated with the claims.</param>
/// <returns>The claims identity.</returns> /// <returns>The claims identity.</returns>
public static ClaimsPrincipal RemoveClaims([NotNull] this ClaimsPrincipal principal, [NotNull] string type) public static ClaimsPrincipal RemoveClaims(this ClaimsPrincipal principal, string type)
{ {
if (principal == null) if (principal == null)
{ {
@ -1029,9 +994,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The type associated with the claims.</param> /// <param name="type">The type associated with the claims.</param>
/// <param name="value">The claim value.</param> /// <param name="value">The claim value.</param>
/// <returns>The claims identity.</returns> /// <returns>The claims identity.</returns>
public static ClaimsIdentity SetClaims( public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, string? value)
[NotNull] this ClaimsIdentity identity,
[NotNull] string type, [CanBeNull] string value)
{ {
if (identity == null) if (identity == null)
{ {
@ -1060,9 +1023,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The type associated with the claims.</param> /// <param name="type">The type associated with the claims.</param>
/// <param name="value">The claim value.</param> /// <param name="value">The claim value.</param>
/// <returns>The claims identity.</returns> /// <returns>The claims identity.</returns>
public static ClaimsPrincipal SetClaim( public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, string? value)
[NotNull] this ClaimsPrincipal principal,
[NotNull] string type, [CanBeNull] string value)
{ {
if (principal == null) if (principal == null)
{ {
@ -1091,8 +1052,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The type associated with the claims.</param> /// <param name="type">The type associated with the claims.</param>
/// <param name="values">The claim values.</param> /// <param name="values">The claim values.</param>
/// <returns>The claims identity.</returns> /// <returns>The claims identity.</returns>
public static ClaimsIdentity SetClaims([NotNull] this ClaimsIdentity identity, public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, ImmutableArray<string> values)
[NotNull] string type, [NotNull] ImmutableArray<string> values)
{ {
if (identity == null) if (identity == null)
{ {
@ -1121,8 +1081,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The type associated with the claims.</param> /// <param name="type">The type associated with the claims.</param>
/// <param name="values">The claim values.</param> /// <param name="values">The claim values.</param>
/// <returns>The claims identity.</returns> /// <returns>The claims identity.</returns>
public static ClaimsPrincipal SetClaims([NotNull] this ClaimsPrincipal principal, public static ClaimsPrincipal SetClaims(this ClaimsPrincipal principal, string type, ImmutableArray<string> values)
[NotNull] string type, [NotNull] ImmutableArray<string> values)
{ {
if (principal == null) if (principal == null)
{ {
@ -1149,7 +1108,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The creation date or <c>null</c> if the claim cannot be found.</returns> /// <returns>The creation date or <c>null</c> if the claim cannot be found.</returns>
public static DateTimeOffset? GetCreationDate([NotNull] this ClaimsPrincipal principal) public static DateTimeOffset? GetCreationDate(this ClaimsPrincipal principal)
{ {
if (principal == null) if (principal == null)
{ {
@ -1175,7 +1134,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The expiration date or <c>null</c> if the claim cannot be found.</returns> /// <returns>The expiration date or <c>null</c> if the claim cannot be found.</returns>
public static DateTimeOffset? GetExpirationDate([NotNull] this ClaimsPrincipal principal) public static DateTimeOffset? GetExpirationDate(this ClaimsPrincipal principal)
{ {
if (principal == null) if (principal == null)
{ {
@ -1201,7 +1160,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The audiences list or an empty set if the claims cannot be found.</returns> /// <returns>The audiences list or an empty set if the claims cannot be found.</returns>
public static ImmutableArray<string> GetAudiences([NotNull] this ClaimsPrincipal principal) public static ImmutableArray<string> GetAudiences(this ClaimsPrincipal principal)
=> principal.GetClaims(Claims.Private.Audience); => principal.GetClaims(Claims.Private.Audience);
/// <summary> /// <summary>
@ -1209,7 +1168,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The presenters list or an empty set if the claims cannot be found.</returns> /// <returns>The presenters list or an empty set if the claims cannot be found.</returns>
public static ImmutableArray<string> GetPresenters([NotNull] this ClaimsPrincipal principal) public static ImmutableArray<string> GetPresenters(this ClaimsPrincipal principal)
=> principal.GetClaims(Claims.Private.Presenter); => principal.GetClaims(Claims.Private.Presenter);
/// <summary> /// <summary>
@ -1217,7 +1176,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The resources list or an empty set if the claims cannot be found.</returns> /// <returns>The resources list or an empty set if the claims cannot be found.</returns>
public static ImmutableArray<string> GetResources([NotNull] this ClaimsPrincipal principal) public static ImmutableArray<string> GetResources(this ClaimsPrincipal principal)
=> principal.GetClaims(Claims.Private.Resource); => principal.GetClaims(Claims.Private.Resource);
/// <summary> /// <summary>
@ -1225,7 +1184,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The scopes list or an empty set if the claim cannot be found.</returns> /// <returns>The scopes list or an empty set if the claim cannot be found.</returns>
public static ImmutableArray<string> GetScopes([NotNull] this ClaimsPrincipal principal) public static ImmutableArray<string> GetScopes(this ClaimsPrincipal principal)
=> principal.GetClaims(Claims.Private.Scope); => principal.GetClaims(Claims.Private.Scope);
/// <summary> /// <summary>
@ -1233,7 +1192,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The access token lifetime or <c>null</c> if the claim cannot be found.</returns> /// <returns>The access token lifetime or <c>null</c> if the claim cannot be found.</returns>
public static TimeSpan? GetAccessTokenLifetime([NotNull] this ClaimsPrincipal principal) public static TimeSpan? GetAccessTokenLifetime(this ClaimsPrincipal principal)
=> GetLifetime(principal, Claims.Private.AccessTokenLifetime); => GetLifetime(principal, Claims.Private.AccessTokenLifetime);
/// <summary> /// <summary>
@ -1241,7 +1200,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The authorization code lifetime or <c>null</c> if the claim cannot be found.</returns> /// <returns>The authorization code lifetime or <c>null</c> if the claim cannot be found.</returns>
public static TimeSpan? GetAuthorizationCodeLifetime([NotNull] this ClaimsPrincipal principal) public static TimeSpan? GetAuthorizationCodeLifetime(this ClaimsPrincipal principal)
=> GetLifetime(principal, Claims.Private.AuthorizationCodeLifetime); => GetLifetime(principal, Claims.Private.AuthorizationCodeLifetime);
/// <summary> /// <summary>
@ -1249,7 +1208,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The device code lifetime or <c>null</c> if the claim cannot be found.</returns> /// <returns>The device code lifetime or <c>null</c> if the claim cannot be found.</returns>
public static TimeSpan? GetDeviceCodeLifetime([NotNull] this ClaimsPrincipal principal) public static TimeSpan? GetDeviceCodeLifetime(this ClaimsPrincipal principal)
=> GetLifetime(principal, Claims.Private.DeviceCodeLifetime); => GetLifetime(principal, Claims.Private.DeviceCodeLifetime);
/// <summary> /// <summary>
@ -1257,7 +1216,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The identity token lifetime or <c>null</c> if the claim cannot be found.</returns> /// <returns>The identity token lifetime or <c>null</c> if the claim cannot be found.</returns>
public static TimeSpan? GetIdentityTokenLifetime([NotNull] this ClaimsPrincipal principal) public static TimeSpan? GetIdentityTokenLifetime(this ClaimsPrincipal principal)
=> GetLifetime(principal, Claims.Private.IdentityTokenLifetime); => GetLifetime(principal, Claims.Private.IdentityTokenLifetime);
/// <summary> /// <summary>
@ -1265,7 +1224,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The refresh token lifetime or <c>null</c> if the claim cannot be found.</returns> /// <returns>The refresh token lifetime or <c>null</c> if the claim cannot be found.</returns>
public static TimeSpan? GetRefreshTokenLifetime([NotNull] this ClaimsPrincipal principal) public static TimeSpan? GetRefreshTokenLifetime(this ClaimsPrincipal principal)
=> GetLifetime(principal, Claims.Private.RefreshTokenLifetime); => GetLifetime(principal, Claims.Private.RefreshTokenLifetime);
/// <summary> /// <summary>
@ -1273,7 +1232,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The user code lifetime or <c>null</c> if the claim cannot be found.</returns> /// <returns>The user code lifetime or <c>null</c> if the claim cannot be found.</returns>
public static TimeSpan? GetUserCodeLifetime([NotNull] this ClaimsPrincipal principal) public static TimeSpan? GetUserCodeLifetime(this ClaimsPrincipal principal)
=> GetLifetime(principal, Claims.Private.UserCodeLifetime); => GetLifetime(principal, Claims.Private.UserCodeLifetime);
/// <summary> /// <summary>
@ -1281,7 +1240,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The unique identifier or <c>null</c> if the claim cannot be found.</returns> /// <returns>The unique identifier or <c>null</c> if the claim cannot be found.</returns>
public static string GetAuthorizationId([NotNull] this ClaimsPrincipal principal) public static string? GetAuthorizationId(this ClaimsPrincipal principal)
=> principal.GetClaim(Claims.Private.AuthorizationId); => principal.GetClaim(Claims.Private.AuthorizationId);
/// <summary> /// <summary>
@ -1289,7 +1248,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The unique identifier or <c>null</c> if the claim cannot be found.</returns> /// <returns>The unique identifier or <c>null</c> if the claim cannot be found.</returns>
public static string GetTokenId([NotNull] this ClaimsPrincipal principal) public static string? GetTokenId(this ClaimsPrincipal principal)
=> principal.GetClaim(Claims.Private.TokenId); => principal.GetClaim(Claims.Private.TokenId);
/// <summary> /// <summary>
@ -1297,7 +1256,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns>The token type or <c>null</c> if the claim cannot be found.</returns> /// <returns>The token type or <c>null</c> if the claim cannot be found.</returns>
public static string GetTokenType([NotNull] this ClaimsPrincipal principal) public static string? GetTokenType(this ClaimsPrincipal principal)
=> principal.GetClaim(Claims.Private.TokenType); => principal.GetClaim(Claims.Private.TokenType);
/// <summary> /// <summary>
@ -1305,7 +1264,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns><c>true</c> if the principal contains at least one audience.</returns> /// <returns><c>true</c> if the principal contains at least one audience.</returns>
public static bool HasAudience([NotNull] this ClaimsPrincipal principal) public static bool HasAudience(this ClaimsPrincipal principal)
=> principal.HasClaim(Claims.Private.Audience); => principal.HasClaim(Claims.Private.Audience);
/// <summary> /// <summary>
@ -1314,7 +1273,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="audience">The audience.</param> /// <param name="audience">The audience.</param>
/// <returns><c>true</c> if the principal contains the given audience.</returns> /// <returns><c>true</c> if the principal contains the given audience.</returns>
public static bool HasAudience([NotNull] this ClaimsPrincipal principal, [NotNull] string audience) public static bool HasAudience(this ClaimsPrincipal principal, string audience)
{ {
if (principal == null) if (principal == null)
{ {
@ -1334,7 +1293,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns><c>true</c> if the principal contains at least one presenter.</returns> /// <returns><c>true</c> if the principal contains at least one presenter.</returns>
public static bool HasPresenter([NotNull] this ClaimsPrincipal principal) public static bool HasPresenter(this ClaimsPrincipal principal)
=> principal.HasClaim(Claims.Private.Presenter); => principal.HasClaim(Claims.Private.Presenter);
/// <summary> /// <summary>
@ -1343,7 +1302,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="presenter">The presenter.</param> /// <param name="presenter">The presenter.</param>
/// <returns><c>true</c> if the principal contains the given presenter.</returns> /// <returns><c>true</c> if the principal contains the given presenter.</returns>
public static bool HasPresenter([NotNull] this ClaimsPrincipal principal, [NotNull] string presenter) public static bool HasPresenter(this ClaimsPrincipal principal, string presenter)
{ {
if (principal == null) if (principal == null)
{ {
@ -1363,7 +1322,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns><c>true</c> if the principal contains at least one resource.</returns> /// <returns><c>true</c> if the principal contains at least one resource.</returns>
public static bool HasResource([NotNull] this ClaimsPrincipal principal) public static bool HasResource(this ClaimsPrincipal principal)
=> principal.HasClaim(Claims.Private.Resource); => principal.HasClaim(Claims.Private.Resource);
/// <summary> /// <summary>
@ -1372,7 +1331,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="resource">The resource.</param> /// <param name="resource">The resource.</param>
/// <returns><c>true</c> if the principal contains the given resource.</returns> /// <returns><c>true</c> if the principal contains the given resource.</returns>
public static bool HasResource([NotNull] this ClaimsPrincipal principal, [NotNull] string resource) public static bool HasResource(this ClaimsPrincipal principal, string resource)
{ {
if (principal == null) if (principal == null)
{ {
@ -1392,7 +1351,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <returns><c>true</c> if the principal contains at least one scope.</returns> /// <returns><c>true</c> if the principal contains at least one scope.</returns>
public static bool HasScope([NotNull] this ClaimsPrincipal principal) public static bool HasScope(this ClaimsPrincipal principal)
=> principal.HasClaim(Claims.Private.Scope); => principal.HasClaim(Claims.Private.Scope);
/// <summary> /// <summary>
@ -1401,7 +1360,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="scope">The scope.</param> /// <param name="scope">The scope.</param>
/// <returns><c>true</c> if the principal contains the given scope.</returns> /// <returns><c>true</c> if the principal contains the given scope.</returns>
public static bool HasScope([NotNull] this ClaimsPrincipal principal, [NotNull] string scope) public static bool HasScope(this ClaimsPrincipal principal, string scope)
{ {
if (principal == null) if (principal == null)
{ {
@ -1422,7 +1381,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="type">The token type.</param> /// <param name="type">The token type.</param>
/// <returns><c>true</c> if the token type matches the specified type.</returns> /// <returns><c>true</c> if the token type matches the specified type.</returns>
public static bool HasTokenType([NotNull] this ClaimsPrincipal principal, [NotNull] string type) public static bool HasTokenType(this ClaimsPrincipal principal, string type)
{ {
if (principal == null) if (principal == null)
{ {
@ -1443,7 +1402,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="date">The creation date</param> /// <param name="date">The creation date</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetCreationDate([NotNull] this ClaimsPrincipal principal, [CanBeNull] DateTimeOffset? date) public static ClaimsPrincipal SetCreationDate(this ClaimsPrincipal principal, DateTimeOffset? date)
=> principal.SetClaim(Claims.Private.CreationDate, date?.ToString("r", CultureInfo.InvariantCulture)); => principal.SetClaim(Claims.Private.CreationDate, date?.ToString("r", CultureInfo.InvariantCulture));
/// <summary> /// <summary>
@ -1452,7 +1411,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="date">The expiration date</param> /// <param name="date">The expiration date</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetExpirationDate([NotNull] this ClaimsPrincipal principal, [CanBeNull] DateTimeOffset? date) public static ClaimsPrincipal SetExpirationDate(this ClaimsPrincipal principal, DateTimeOffset? date)
=> principal.SetClaim(Claims.Private.ExpirationDate, date?.ToString("r", CultureInfo.InvariantCulture)); => principal.SetClaim(Claims.Private.ExpirationDate, date?.ToString("r", CultureInfo.InvariantCulture));
/// <summary> /// <summary>
@ -1462,8 +1421,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="audiences">The audiences to store.</param> /// <param name="audiences">The audiences to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetAudiences( public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, ImmutableArray<string> audiences)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] ImmutableArray<string> audiences)
=> principal.SetClaims(Claims.Private.Audience, audiences); => principal.SetClaims(Claims.Private.Audience, audiences);
/// <summary> /// <summary>
@ -1473,8 +1431,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="audiences">The audiences to store.</param> /// <param name="audiences">The audiences to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetAudiences( public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, IEnumerable<string>? audiences)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] IEnumerable<string> audiences)
=> principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -1484,8 +1441,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="audiences">The audiences to store.</param> /// <param name="audiences">The audiences to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetAudiences( public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, params string[]? audiences)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] params string[] audiences)
=> principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -1495,8 +1451,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="presenters">The presenters to store.</param> /// <param name="presenters">The presenters to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetPresenters( public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, ImmutableArray<string> presenters)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] ImmutableArray<string> presenters)
=> principal.SetClaims(Claims.Private.Presenter, presenters); => principal.SetClaims(Claims.Private.Presenter, presenters);
/// <summary> /// <summary>
@ -1506,8 +1461,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="presenters">The presenters to store.</param> /// <param name="presenters">The presenters to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetPresenters( public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, IEnumerable<string>? presenters)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] IEnumerable<string> presenters)
=> principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -1517,8 +1471,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="presenters">The presenters to store.</param> /// <param name="presenters">The presenters to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetPresenters( public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, params string[]? presenters)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] params string[] presenters)
=> principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -1528,8 +1481,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="resources">The resources to store.</param> /// <param name="resources">The resources to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetResources( public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, ImmutableArray<string> resources)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] ImmutableArray<string> resources)
=> principal.SetClaims(Claims.Private.Resource, resources); => principal.SetClaims(Claims.Private.Resource, resources);
/// <summary> /// <summary>
@ -1539,8 +1491,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="resources">The resources to store.</param> /// <param name="resources">The resources to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetResources( public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, IEnumerable<string>? resources)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] IEnumerable<string> resources)
=> principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -1550,8 +1501,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="resources">The resources to store.</param> /// <param name="resources">The resources to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetResources( public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, params string[]? resources)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] params string[] resources)
=> principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -1561,8 +1511,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="scopes">The scopes to store.</param> /// <param name="scopes">The scopes to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetScopes( public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, ImmutableArray<string> scopes)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] ImmutableArray<string> scopes)
=> principal.SetClaims(Claims.Private.Scope, scopes); => principal.SetClaims(Claims.Private.Scope, scopes);
/// <summary> /// <summary>
@ -1572,8 +1521,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="scopes">The scopes to store.</param> /// <param name="scopes">The scopes to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetScopes( public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, IEnumerable<string>? scopes)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] IEnumerable<string> scopes)
=> principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -1583,8 +1531,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="scopes">The scopes to store.</param> /// <param name="scopes">The scopes to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetScopes( public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, params string[]? scopes)
[NotNull] this ClaimsPrincipal principal, [CanBeNull] params string[] scopes)
=> principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Create<string>()); => principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray.Create<string>());
/// <summary> /// <summary>
@ -1593,7 +1540,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="lifetime">The access token lifetime to store.</param> /// <param name="lifetime">The access token lifetime to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetAccessTokenLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) public static ClaimsPrincipal SetAccessTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
=> principal.SetClaim(Claims.Private.AccessTokenLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); => principal.SetClaim(Claims.Private.AccessTokenLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture));
/// <summary> /// <summary>
@ -1602,7 +1549,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="lifetime">The authorization code lifetime to store.</param> /// <param name="lifetime">The authorization code lifetime to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetAuthorizationCodeLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) public static ClaimsPrincipal SetAuthorizationCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
=> principal.SetClaim(Claims.Private.AuthorizationCodeLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); => principal.SetClaim(Claims.Private.AuthorizationCodeLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture));
/// <summary> /// <summary>
@ -1611,7 +1558,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="lifetime">The device code lifetime to store.</param> /// <param name="lifetime">The device code lifetime to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetDeviceCodeLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) public static ClaimsPrincipal SetDeviceCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
=> principal.SetClaim(Claims.Private.DeviceCodeLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); => principal.SetClaim(Claims.Private.DeviceCodeLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture));
/// <summary> /// <summary>
@ -1620,7 +1567,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="lifetime">The identity token lifetime to store.</param> /// <param name="lifetime">The identity token lifetime to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetIdentityTokenLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) public static ClaimsPrincipal SetIdentityTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
=> principal.SetClaim(Claims.Private.IdentityTokenLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); => principal.SetClaim(Claims.Private.IdentityTokenLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture));
/// <summary> /// <summary>
@ -1629,7 +1576,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="lifetime">The refresh token lifetime to store.</param> /// <param name="lifetime">The refresh token lifetime to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetRefreshTokenLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) public static ClaimsPrincipal SetRefreshTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
=> principal.SetClaim(Claims.Private.RefreshTokenLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); => principal.SetClaim(Claims.Private.RefreshTokenLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture));
/// <summary> /// <summary>
@ -1638,7 +1585,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="lifetime">The user code lifetime to store.</param> /// <param name="lifetime">The user code lifetime to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetUserCodeLifetime([NotNull] this ClaimsPrincipal principal, TimeSpan? lifetime) public static ClaimsPrincipal SetUserCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)
=> principal.SetClaim(Claims.Private.UserCodeLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture)); => principal.SetClaim(Claims.Private.UserCodeLifetime, lifetime?.TotalSeconds.ToString(CultureInfo.InvariantCulture));
/// <summary> /// <summary>
@ -1647,7 +1594,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="identifier">The unique identifier to store.</param> /// <param name="identifier">The unique identifier to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetAuthorizationId([NotNull] this ClaimsPrincipal principal, string identifier) public static ClaimsPrincipal SetAuthorizationId(this ClaimsPrincipal principal, string? identifier)
=> principal.SetClaim(Claims.Private.AuthorizationId, identifier); => principal.SetClaim(Claims.Private.AuthorizationId, identifier);
/// <summary> /// <summary>
@ -1656,7 +1603,7 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="identifier">The unique identifier to store.</param> /// <param name="identifier">The unique identifier to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetTokenId([NotNull] this ClaimsPrincipal principal, string identifier) public static ClaimsPrincipal SetTokenId(this ClaimsPrincipal principal, string? identifier)
=> principal.SetClaim(Claims.Private.TokenId, identifier); => principal.SetClaim(Claims.Private.TokenId, identifier);
/// <summary> /// <summary>
@ -1665,13 +1612,19 @@ namespace OpenIddict.Abstractions
/// <param name="principal">The claims principal.</param> /// <param name="principal">The claims principal.</param>
/// <param name="type">The token type to store.</param> /// <param name="type">The token type to store.</param>
/// <returns>The claims principal.</returns> /// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetTokenType([NotNull] this ClaimsPrincipal principal, string type) public static ClaimsPrincipal SetTokenType(this ClaimsPrincipal principal, string? type)
=> principal.SetClaim(Claims.Private.TokenType, type); => principal.SetClaim(Claims.Private.TokenType, type);
private static IEnumerable<string> GetValues(string source, char[] separators) private static ImmutableArray<string> GetValues(string? source, char[] separators)
{ {
Debug.Assert(!string.IsNullOrEmpty(source), SR.GetResourceString(SR.ID5000)); Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001));
Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001));
if (string.IsNullOrEmpty(source))
{
return ImmutableArray.Create<string>();
}
var builder = ImmutableArray.CreateBuilder<string>();
foreach (var element in new StringTokenizer(source, separators)) foreach (var element in new StringTokenizer(source, separators))
{ {
@ -1681,22 +1634,27 @@ namespace OpenIddict.Abstractions
continue; continue;
} }
yield return segment.Value; if (builder.Contains(segment.Value, StringComparer.Ordinal))
{
continue;
}
builder.Add(segment.Value);
} }
yield break; return builder.ToImmutable();
} }
private static bool HasValue(string source, string value, char[] separators) private static bool HasValue(string? source, string value, char[] separators)
{ {
Debug.Assert(!string.IsNullOrEmpty(value), SR.GetResourceString(SR.ID5002));
Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001));
if (string.IsNullOrEmpty(source)) if (string.IsNullOrEmpty(source))
{ {
return false; return false;
} }
Debug.Assert(!string.IsNullOrEmpty(value), SR.GetResourceString(SR.ID5002));
Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001));
foreach (var element in new StringTokenizer(source, separators)) foreach (var element in new StringTokenizer(source, separators))
{ {
var segment = Trim(element, separators); var segment = Trim(element, separators);
@ -1716,7 +1674,7 @@ namespace OpenIddict.Abstractions
private static StringSegment TrimStart(StringSegment segment, char[] separators) private static StringSegment TrimStart(StringSegment segment, char[] separators)
{ {
Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001));
var index = segment.Offset; var index = segment.Offset;
@ -1735,7 +1693,7 @@ namespace OpenIddict.Abstractions
private static StringSegment TrimEnd(StringSegment segment, char[] separators) private static StringSegment TrimEnd(StringSegment segment, char[] separators)
{ {
Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001));
var index = segment.Offset + segment.Length - 1; var index = segment.Offset + segment.Length - 1;
@ -1754,16 +1712,16 @@ namespace OpenIddict.Abstractions
private static StringSegment Trim(StringSegment segment, char[] separators) private static StringSegment Trim(StringSegment segment, char[] separators)
{ {
Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001));
return TrimEnd(TrimStart(segment, separators), separators); return TrimEnd(TrimStart(segment, separators), separators);
} }
private static bool IsSeparator(char character, char[] separators) private static bool IsSeparator(char character, char[] separators)
{ {
Debug.Assert(separators?.Length != 0, SR.GetResourceString(SR.ID5001)); Debug.Assert(separators != null && separators.Length != 0, SR.GetResourceString(SR.ID5001));
for (var index = 0; index < separators.Length; index++) for (var index = 0; index < separators!.Length; index++)
{ {
if (character == separators[index]) if (character == separators[index])
{ {

21
src/OpenIddict.Abstractions/Primitives/OpenIddictMessage.cs

@ -14,7 +14,6 @@ using System.Text;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using JetBrains.Annotations;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
using SR = OpenIddict.Abstractions.OpenIddictResources; using SR = OpenIddict.Abstractions.OpenIddictResources;
@ -67,7 +66,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict message. /// Initializes a new OpenIddict message.
/// </summary> /// </summary>
/// <param name="parameters">The message parameters.</param> /// <param name="parameters">The message parameters.</param>
public OpenIddictMessage([NotNull] IEnumerable<KeyValuePair<string, OpenIddictParameter>> parameters) public OpenIddictMessage(IEnumerable<KeyValuePair<string, OpenIddictParameter>> parameters)
{ {
if (parameters == null) if (parameters == null)
{ {
@ -84,7 +83,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict message. /// Initializes a new OpenIddict message.
/// </summary> /// </summary>
/// <param name="parameters">The message parameters.</param> /// <param name="parameters">The message parameters.</param>
public OpenIddictMessage([NotNull] IEnumerable<KeyValuePair<string, string>> parameters) public OpenIddictMessage(IEnumerable<KeyValuePair<string, string?>> parameters)
{ {
if (parameters == null) if (parameters == null)
{ {
@ -112,7 +111,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict message. /// Initializes a new OpenIddict message.
/// </summary> /// </summary>
/// <param name="parameters">The message parameters.</param> /// <param name="parameters">The message parameters.</param>
public OpenIddictMessage([NotNull] IEnumerable<KeyValuePair<string, string[]>> parameters) public OpenIddictMessage(IEnumerable<KeyValuePair<string, string?[]?>> parameters)
{ {
if (parameters == null) if (parameters == null)
{ {
@ -139,7 +138,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict message. /// Initializes a new OpenIddict message.
/// </summary> /// </summary>
/// <param name="parameters">The message parameters.</param> /// <param name="parameters">The message parameters.</param>
public OpenIddictMessage([NotNull] IEnumerable<KeyValuePair<string, StringValues>> parameters) public OpenIddictMessage(IEnumerable<KeyValuePair<string, StringValues>> parameters)
{ {
if (parameters == null) if (parameters == null)
{ {
@ -189,7 +188,7 @@ namespace OpenIddict.Abstractions
/// <param name="name">The parameter name.</param> /// <param name="name">The parameter name.</param>
/// <param name="value">The parameter value.</param> /// <param name="value">The parameter value.</param>
/// <returns>The current instance, which allows chaining calls.</returns> /// <returns>The current instance, which allows chaining calls.</returns>
public OpenIddictMessage AddParameter([NotNull] string name, OpenIddictParameter value) public OpenIddictMessage AddParameter(string name, OpenIddictParameter value)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -211,7 +210,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="name">The parameter name.</param> /// <param name="name">The parameter name.</param>
/// <returns>The parameter value, or <c>null</c> if it cannot be found.</returns> /// <returns>The parameter value, or <c>null</c> if it cannot be found.</returns>
public OpenIddictParameter? GetParameter([NotNull] string name) public OpenIddictParameter? GetParameter(string name)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -238,7 +237,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="name">The parameter name.</param> /// <param name="name">The parameter name.</param>
/// <returns><c>true</c> if the parameter is present, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the parameter is present, <c>false</c> otherwise.</returns>
public bool HasParameter([NotNull] string name) public bool HasParameter(string name)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -253,7 +252,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="name">The parameter name.</param> /// <param name="name">The parameter name.</param>
/// <returns>The current instance, which allows chaining calls.</returns> /// <returns>The current instance, which allows chaining calls.</returns>
public OpenIddictMessage RemoveParameter([NotNull] string name) public OpenIddictMessage RemoveParameter(string name)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -272,7 +271,7 @@ namespace OpenIddict.Abstractions
/// <param name="name">The parameter name.</param> /// <param name="name">The parameter name.</param>
/// <param name="value">The parameter value.</param> /// <param name="value">The parameter value.</param>
/// <returns>The current instance, which allows chaining calls.</returns> /// <returns>The current instance, which allows chaining calls.</returns>
public OpenIddictMessage SetParameter([NotNull] string name, [CanBeNull] OpenIddictParameter? value) public OpenIddictMessage SetParameter(string name, OpenIddictParameter? value)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -299,7 +298,7 @@ namespace OpenIddict.Abstractions
/// <param name="name">The parameter name.</param> /// <param name="name">The parameter name.</param>
/// <param name="value">The parameter value.</param> /// <param name="value">The parameter value.</param>
/// <returns><c>true</c> if the parameter could be found, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the parameter could be found, <c>false</c> otherwise.</returns>
public bool TryGetParameter([NotNull] string name, out OpenIddictParameter value) public bool TryGetParameter(string name, out OpenIddictParameter value)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {

107
src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs

@ -12,7 +12,6 @@ using System.Globalization;
using System.Linq; using System.Linq;
using System.Text.Encodings.Web; using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using JetBrains.Annotations;
using SR = OpenIddict.Abstractions.OpenIddictResources; using SR = OpenIddict.Abstractions.OpenIddictResources;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
@ -57,13 +56,13 @@ namespace OpenIddict.Abstractions
/// Initializes a new parameter using the specified value. /// Initializes a new parameter using the specified value.
/// </summary> /// </summary>
/// <param name="value">The parameter value.</param> /// <param name="value">The parameter value.</param>
public OpenIddictParameter(string value) => Value = value; public OpenIddictParameter(string? value) => Value = value;
/// <summary> /// <summary>
/// Initializes a new parameter using the specified value. /// Initializes a new parameter using the specified value.
/// </summary> /// </summary>
/// <param name="value">The parameter value.</param> /// <param name="value">The parameter value.</param>
public OpenIddictParameter(string[] value) => Value = value; public OpenIddictParameter(string?[]? value) => Value = value;
/// <summary> /// <summary>
/// Gets the child item corresponding to the specified index. /// Gets the child item corresponding to the specified index.
@ -86,7 +85,7 @@ namespace OpenIddict.Abstractions
public int Count => Value switch public int Count => Value switch
{ {
// If the parameter is a primitive array of strings, return its length. // If the parameter is a primitive array of strings, return its length.
string[] value => value.Length, string?[] value => value.Length,
// If the parameter is a JSON array, return its length. // If the parameter is a JSON array, return its length.
JsonElement value when value.ValueKind == JsonValueKind.Array => value.GetArrayLength(), JsonElement value when value.ValueKind == JsonValueKind.Array => value.GetArrayLength(),
@ -100,7 +99,7 @@ namespace OpenIddict.Abstractions
/// (e.g bool, string, long), an array of strings or a complex JSON object. /// (e.g bool, string, long), an array of strings or a complex JSON object.
/// </summary> /// </summary>
[EditorBrowsable(EditorBrowsableState.Advanced)] [EditorBrowsable(EditorBrowsableState.Advanced)]
public object Value { get; } public object? Value { get; }
/// <summary> /// <summary>
/// Determines whether the current <see cref="OpenIddictParameter"/> /// Determines whether the current <see cref="OpenIddictParameter"/>
@ -121,7 +120,7 @@ namespace OpenIddict.Abstractions
(_, null) => false, (_, null) => false,
// If the two parameters are string arrays, use SequenceEqual(). // If the two parameters are string arrays, use SequenceEqual().
(string[] left, string[] right) => left.SequenceEqual(right), (string?[] left, string?[] right) => left.SequenceEqual(right),
// If the two parameters are JsonElement instances, use the custom comparer. // If the two parameters are JsonElement instances, use the custom comparer.
(JsonElement left, JsonElement right) => Equals(left, right), (JsonElement left, JsonElement right) => Equals(left, right),
@ -220,7 +219,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="obj">The other object to which to compare this instance.</param> /// <param name="obj">The other object to which to compare this instance.</param>
/// <returns><c>true</c> if the two instances are equal, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the two instances are equal, <c>false</c> otherwise.</returns>
public override bool Equals(object obj) => obj is OpenIddictParameter parameter && Equals(parameter); public override bool Equals(object? obj) => obj is OpenIddictParameter parameter && Equals(parameter);
/// <summary> /// <summary>
/// Returns the hash code of the current <see cref="OpenIddictParameter"/> instance. /// Returns the hash code of the current <see cref="OpenIddictParameter"/> instance.
@ -295,7 +294,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="name">The name of the child item.</param> /// <param name="name">The name of the child item.</param>
/// <returns>An <see cref="OpenIddictParameter"/> instance containing the item value.</returns> /// <returns>An <see cref="OpenIddictParameter"/> instance containing the item value.</returns>
public OpenIddictParameter? GetNamedParameter([NotNull] string name) public OpenIddictParameter? GetNamedParameter(string name)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
@ -328,7 +327,7 @@ namespace OpenIddict.Abstractions
throw new ArgumentOutOfRangeException(nameof(index), SR.GetResourceString(SR.ID1192)); throw new ArgumentOutOfRangeException(nameof(index), SR.GetResourceString(SR.ID1192));
} }
if (Value is string[] array) if (Value is string?[] array)
{ {
// If the specified index goes beyond the // If the specified index goes beyond the
// number of items in the array, return null. // number of items in the array, return null.
@ -385,7 +384,7 @@ namespace OpenIddict.Abstractions
/// <returns>An enumeration of all the unnamed parameters associated with the current instance.</returns> /// <returns>An enumeration of all the unnamed parameters associated with the current instance.</returns>
public IReadOnlyList<OpenIddictParameter> GetUnnamedParameters() public IReadOnlyList<OpenIddictParameter> GetUnnamedParameters()
{ {
if (Value is string[] array) if (Value is string?[] array)
{ {
var parameters = new List<OpenIddictParameter>(); var parameters = new List<OpenIddictParameter>();
@ -416,12 +415,12 @@ namespace OpenIddict.Abstractions
/// Returns the <see cref="string"/> representation of the current instance. /// Returns the <see cref="string"/> representation of the current instance.
/// </summary> /// </summary>
/// <returns>The <see cref="string"/> representation associated with the parameter value.</returns> /// <returns>The <see cref="string"/> representation associated with the parameter value.</returns>
public override string ToString() => Value switch public override string? ToString() => Value switch
{ {
null => string.Empty, null => string.Empty,
string value => value, string value => value,
string[] value => string.Join(", ", value), string?[] value => string.Join(", ", value),
JsonElement value => value.ToString(), JsonElement value => value.ToString(),
@ -434,11 +433,11 @@ namespace OpenIddict.Abstractions
/// <param name="name">The name of the child item.</param> /// <param name="name">The name of the child item.</param>
/// <param name="value">An <see cref="OpenIddictParameter"/> instance containing the item value.</param> /// <param name="value">An <see cref="OpenIddictParameter"/> instance containing the item value.</param>
/// <returns><c>true</c> if the parameter could be found, <c>false</c> otherwise.</returns> /// <returns><c>true</c> if the parameter could be found, <c>false</c> otherwise.</returns>
public bool TryGetParameter([NotNull] string name, out OpenIddictParameter value) public bool TryGetNamedParameter(string name, out OpenIddictParameter value)
{ {
if (string.IsNullOrEmpty(name)) if (string.IsNullOrEmpty(name))
{ {
throw new ArgumentException(SR.GetResourceString(SR.ID1189), nameof(name)); throw new ArgumentException(SR.GetResourceString(SR.ID1191), nameof(name));
} }
if (Value is JsonElement element && element.ValueKind == JsonValueKind.Object && if (Value is JsonElement element && element.ValueKind == JsonValueKind.Object &&
@ -454,6 +453,52 @@ namespace OpenIddict.Abstractions
return false; return false;
} }
/// <summary>
/// Tries to get the child item corresponding to the specified index.
/// </summary>
/// <param name="index">The index of the child item.</param>
/// <param name="value">An <see cref="OpenIddictParameter"/> instance containing the item value.</param>
/// <returns><c>true</c> if the parameter could be found, <c>false</c> otherwise.</returns>
public bool TryGetUnnamedParameter(int index, out OpenIddictParameter value)
{
if (index < 0)
{
throw new ArgumentOutOfRangeException(nameof(index), SR.GetResourceString(SR.ID1192));
}
if (Value is string?[] array)
{
if (index >= array.Length)
{
value = default;
return false;
}
value = new OpenIddictParameter(array[index]);
return true;
}
if (Value is JsonElement element && element.ValueKind == JsonValueKind.Array)
{
if (index >= element.GetArrayLength())
{
value = default;
return false;
}
value = new OpenIddictParameter(element[index]);
return true;
}
value = default;
return false;
}
/// <summary> /// <summary>
/// Writes the parameter value to the specified JSON writer. /// Writes the parameter value to the specified JSON writer.
/// </summary> /// </summary>
@ -485,7 +530,7 @@ namespace OpenIddict.Abstractions
writer.WriteStringValue(value); writer.WriteStringValue(value);
break; break;
case string[] value: case string?[] value:
writer.WriteStartArray(); writer.WriteStartArray();
for (var index = 0; index < value.Length; index++) for (var index = 0; index < value.Length; index++)
@ -654,7 +699,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="parameter">The parameter to convert.</param> /// <param name="parameter">The parameter to convert.</param>
/// <returns>The converted value.</returns> /// <returns>The converted value.</returns>
public static explicit operator string(OpenIddictParameter? parameter) => parameter?.Value switch public static explicit operator string?(OpenIddictParameter? parameter) => parameter?.Value switch
{ {
// When the parameter is a null value, return null. // When the parameter is a null value, return null.
null => null, null => null,
@ -692,7 +737,7 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="parameter">The parameter to convert.</param> /// <param name="parameter">The parameter to convert.</param>
/// <returns>The converted value.</returns> /// <returns>The converted value.</returns>
public static explicit operator string[](OpenIddictParameter? parameter) public static explicit operator string?[]?(OpenIddictParameter? parameter)
{ {
return parameter?.Value switch return parameter?.Value switch
{ {
@ -700,16 +745,16 @@ namespace OpenIddict.Abstractions
null => null, null => null,
// When the parameter is already an array of strings, return it as-is. // When the parameter is already an array of strings, return it as-is.
string[] value => value, string?[] value => value,
// When the parameter is a string value, return an array with a single entry. // When the parameter is a string value, return an array with a single entry.
string value => new string[] { value }, string value => new string?[] { value },
// When the parameter is a boolean value, return an array with its string representation. // When the parameter is a boolean value, return an array with its string representation.
bool value => new string[] { value.ToString() }, bool value => new string?[] { value.ToString() },
// When the parameter is an integer, return an array with its string representation. // When the parameter is an integer, return an array with its string representation.
long value => new string[] { value.ToString(CultureInfo.InvariantCulture) }, long value => new string?[] { value.ToString(CultureInfo.InvariantCulture) },
// When the parameter is a JsonElement representing null, return null. // When the parameter is a JsonElement representing null, return null.
JsonElement value when value.ValueKind == JsonValueKind.Undefined => null, JsonElement value when value.ValueKind == JsonValueKind.Undefined => null,
@ -717,15 +762,15 @@ namespace OpenIddict.Abstractions
// When the parameter is a JsonElement representing a string, return an array with a single entry. // When the parameter is a JsonElement representing a string, return an array with a single entry.
JsonElement value when value.ValueKind == JsonValueKind.String JsonElement value when value.ValueKind == JsonValueKind.String
=> new string[] { value.GetString() }, => new string?[] { value.GetString() },
// When the parameter is a JsonElement representing a number, return an array with a single entry. // When the parameter is a JsonElement representing a number, return an array with a single entry.
JsonElement value when value.ValueKind == JsonValueKind.Number JsonElement value when value.ValueKind == JsonValueKind.Number
=> new string[] { value.GetInt64().ToString(CultureInfo.InvariantCulture) }, => new string?[] { value.GetInt64().ToString(CultureInfo.InvariantCulture) },
// When the parameter is a JsonElement representing a boolean, return an array with a single entry. // When the parameter is a JsonElement representing a boolean, return an array with a single entry.
JsonElement value when value.ValueKind == JsonValueKind.False => new string[] { bool.FalseString }, JsonElement value when value.ValueKind == JsonValueKind.False => new string?[] { bool.FalseString },
JsonElement value when value.ValueKind == JsonValueKind.True => new string[] { bool.TrueString }, JsonElement value when value.ValueKind == JsonValueKind.True => new string?[] { bool.TrueString },
// When the parameter is a JsonElement representing an array of strings, return it. // When the parameter is a JsonElement representing an array of strings, return it.
JsonElement value when value.ValueKind == JsonValueKind.Array => CreateArray(value), JsonElement value when value.ValueKind == JsonValueKind.Array => CreateArray(value),
@ -734,7 +779,7 @@ namespace OpenIddict.Abstractions
_ => null _ => null
}; };
static string[] CreateArray(JsonElement value) static string?[]? CreateArray(JsonElement value)
{ {
var array = new string[value.GetArrayLength()]; var array = new string[value.GetArrayLength()];
using var enumerator = value.EnumerateArray(); using var enumerator = value.EnumerateArray();
@ -794,14 +839,14 @@ namespace OpenIddict.Abstractions
/// </summary> /// </summary>
/// <param name="value">The value to convert</param> /// <param name="value">The value to convert</param>
/// <returns>An <see cref="OpenIddictParameter"/> instance.</returns> /// <returns>An <see cref="OpenIddictParameter"/> instance.</returns>
public static implicit operator OpenIddictParameter(string value) => new OpenIddictParameter(value); public static implicit operator OpenIddictParameter(string? value) => new OpenIddictParameter(value);
/// <summary> /// <summary>
/// Converts an array of strings to an <see cref="OpenIddictParameter"/> instance. /// Converts an array of strings to an <see cref="OpenIddictParameter"/> instance.
/// </summary> /// </summary>
/// <param name="value">The value to convert</param> /// <param name="value">The value to convert</param>
/// <returns>An <see cref="OpenIddictParameter"/> instance.</returns> /// <returns>An <see cref="OpenIddictParameter"/> instance.</returns>
public static implicit operator OpenIddictParameter(string[] value) => new OpenIddictParameter(value); public static implicit operator OpenIddictParameter(string?[]? value) => new OpenIddictParameter(value);
/// <summary> /// <summary>
/// Determines whether a parameter is null or empty. /// Determines whether a parameter is null or empty.
@ -814,8 +859,8 @@ namespace OpenIddict.Abstractions
{ {
null => true, null => true,
string value => string.IsNullOrEmpty(value), string value => string.IsNullOrEmpty(value),
string[] value => value.Length == 0, string?[] value => value.Length == 0,
JsonElement value when value.ValueKind == JsonValueKind.Undefined => true, JsonElement value when value.ValueKind == JsonValueKind.Undefined => true,
JsonElement value when value.ValueKind == JsonValueKind.Null => true, JsonElement value when value.ValueKind == JsonValueKind.Null => true,

161
src/OpenIddict.Abstractions/Primitives/OpenIddictRequest.cs

@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using JetBrains.Annotations;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
@ -46,7 +45,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict request. /// Initializes a new OpenIddict request.
/// </summary> /// </summary>
/// <param name="parameters">The request parameters.</param> /// <param name="parameters">The request parameters.</param>
public OpenIddictRequest([NotNull] IEnumerable<KeyValuePair<string, OpenIddictParameter>> parameters) public OpenIddictRequest(IEnumerable<KeyValuePair<string, OpenIddictParameter>> parameters)
: base(parameters) : base(parameters)
{ {
} }
@ -55,7 +54,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict request. /// Initializes a new OpenIddict request.
/// </summary> /// </summary>
/// <param name="parameters">The request parameters.</param> /// <param name="parameters">The request parameters.</param>
public OpenIddictRequest([NotNull] IEnumerable<KeyValuePair<string, string>> parameters) public OpenIddictRequest(IEnumerable<KeyValuePair<string, string?>> parameters)
: base(parameters) : base(parameters)
{ {
} }
@ -64,7 +63,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict request. /// Initializes a new OpenIddict request.
/// </summary> /// </summary>
/// <param name="parameters">The request parameters.</param> /// <param name="parameters">The request parameters.</param>
public OpenIddictRequest([NotNull] IEnumerable<KeyValuePair<string, string[]>> parameters) public OpenIddictRequest(IEnumerable<KeyValuePair<string, string?[]?>> parameters)
: base(parameters) : base(parameters)
{ {
} }
@ -73,7 +72,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict request. /// Initializes a new OpenIddict request.
/// </summary> /// </summary>
/// <param name="parameters">The request parameters.</param> /// <param name="parameters">The request parameters.</param>
public OpenIddictRequest([NotNull] IEnumerable<KeyValuePair<string, StringValues>> parameters) public OpenIddictRequest(IEnumerable<KeyValuePair<string, StringValues>> parameters)
: base(parameters) : base(parameters)
{ {
} }
@ -81,36 +80,36 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the "access_token" parameter. /// Gets or sets the "access_token" parameter.
/// </summary> /// </summary>
public string AccessToken public string? AccessToken
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.AccessToken); get => (string?) GetParameter(OpenIddictConstants.Parameters.AccessToken);
set => SetParameter(OpenIddictConstants.Parameters.AccessToken, value); set => SetParameter(OpenIddictConstants.Parameters.AccessToken, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "acr_values" parameter. /// Gets or sets the "acr_values" parameter.
/// </summary> /// </summary>
public string AcrValues public string? AcrValues
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.AcrValues); get => (string?) GetParameter(OpenIddictConstants.Parameters.AcrValues);
set => SetParameter(OpenIddictConstants.Parameters.AcrValues, value); set => SetParameter(OpenIddictConstants.Parameters.AcrValues, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "assertion" parameter. /// Gets or sets the "assertion" parameter.
/// </summary> /// </summary>
public string Assertion public string? Assertion
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Assertion); get => (string?) GetParameter(OpenIddictConstants.Parameters.Assertion);
set => SetParameter(OpenIddictConstants.Parameters.Assertion, value); set => SetParameter(OpenIddictConstants.Parameters.Assertion, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "audience" parameters. /// Gets or sets the "audience" parameters.
/// </summary> /// </summary>
public string[] Audiences public string[]? Audiences
{ {
get => (string[]) GetParameter(OpenIddictConstants.Parameters.Audience); get => (string[]?) GetParameter(OpenIddictConstants.Parameters.Audience);
set => SetParameter(OpenIddictConstants.Parameters.Audience, value); set => SetParameter(OpenIddictConstants.Parameters.Audience, value);
} }
@ -126,135 +125,135 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the "claims_locales" parameter. /// Gets or sets the "claims_locales" parameter.
/// </summary> /// </summary>
public string ClaimsLocales public string? ClaimsLocales
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.ClaimsLocales); get => (string?) GetParameter(OpenIddictConstants.Parameters.ClaimsLocales);
set => SetParameter(OpenIddictConstants.Parameters.ClaimsLocales, value); set => SetParameter(OpenIddictConstants.Parameters.ClaimsLocales, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "client_assertion" parameter. /// Gets or sets the "client_assertion" parameter.
/// </summary> /// </summary>
public string ClientAssertion public string? ClientAssertion
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.ClientAssertion); get => (string?) GetParameter(OpenIddictConstants.Parameters.ClientAssertion);
set => SetParameter(OpenIddictConstants.Parameters.ClientAssertion, value); set => SetParameter(OpenIddictConstants.Parameters.ClientAssertion, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "client_assertion_type" parameter. /// Gets or sets the "client_assertion_type" parameter.
/// </summary> /// </summary>
public string ClientAssertionType public string? ClientAssertionType
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.ClientAssertionType); get => (string?) GetParameter(OpenIddictConstants.Parameters.ClientAssertionType);
set => SetParameter(OpenIddictConstants.Parameters.ClientAssertionType, value); set => SetParameter(OpenIddictConstants.Parameters.ClientAssertionType, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "client_id" parameter. /// Gets or sets the "client_id" parameter.
/// </summary> /// </summary>
public string ClientId public string? ClientId
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.ClientId); get => (string?) GetParameter(OpenIddictConstants.Parameters.ClientId);
set => SetParameter(OpenIddictConstants.Parameters.ClientId, value); set => SetParameter(OpenIddictConstants.Parameters.ClientId, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "client_secret" parameter. /// Gets or sets the "client_secret" parameter.
/// </summary> /// </summary>
public string ClientSecret public string? ClientSecret
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.ClientSecret); get => (string?) GetParameter(OpenIddictConstants.Parameters.ClientSecret);
set => SetParameter(OpenIddictConstants.Parameters.ClientSecret, value); set => SetParameter(OpenIddictConstants.Parameters.ClientSecret, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "code" parameter. /// Gets or sets the "code" parameter.
/// </summary> /// </summary>
public string Code public string? Code
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Code); get => (string?) GetParameter(OpenIddictConstants.Parameters.Code);
set => SetParameter(OpenIddictConstants.Parameters.Code, value); set => SetParameter(OpenIddictConstants.Parameters.Code, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "code_challenge" parameter. /// Gets or sets the "code_challenge" parameter.
/// </summary> /// </summary>
public string CodeChallenge public string? CodeChallenge
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.CodeChallenge); get => (string?) GetParameter(OpenIddictConstants.Parameters.CodeChallenge);
set => SetParameter(OpenIddictConstants.Parameters.CodeChallenge, value); set => SetParameter(OpenIddictConstants.Parameters.CodeChallenge, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "code_challenge_method" parameter. /// Gets or sets the "code_challenge_method" parameter.
/// </summary> /// </summary>
public string CodeChallengeMethod public string? CodeChallengeMethod
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.CodeChallengeMethod); get => (string?) GetParameter(OpenIddictConstants.Parameters.CodeChallengeMethod);
set => SetParameter(OpenIddictConstants.Parameters.CodeChallengeMethod, value); set => SetParameter(OpenIddictConstants.Parameters.CodeChallengeMethod, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "code_verifier" parameter. /// Gets or sets the "code_verifier" parameter.
/// </summary> /// </summary>
public string CodeVerifier public string? CodeVerifier
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.CodeVerifier); get => (string?) GetParameter(OpenIddictConstants.Parameters.CodeVerifier);
set => SetParameter(OpenIddictConstants.Parameters.CodeVerifier, value); set => SetParameter(OpenIddictConstants.Parameters.CodeVerifier, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "device_code" parameter. /// Gets or sets the "device_code" parameter.
/// </summary> /// </summary>
public string DeviceCode public string? DeviceCode
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.DeviceCode); get => (string?) GetParameter(OpenIddictConstants.Parameters.DeviceCode);
set => SetParameter(OpenIddictConstants.Parameters.DeviceCode, value); set => SetParameter(OpenIddictConstants.Parameters.DeviceCode, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "display" parameter. /// Gets or sets the "display" parameter.
/// </summary> /// </summary>
public string Display public string? Display
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Display); get => (string?) GetParameter(OpenIddictConstants.Parameters.Display);
set => SetParameter(OpenIddictConstants.Parameters.Display, value); set => SetParameter(OpenIddictConstants.Parameters.Display, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "grant_type" parameter. /// Gets or sets the "grant_type" parameter.
/// </summary> /// </summary>
public string GrantType public string? GrantType
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.GrantType); get => (string?) GetParameter(OpenIddictConstants.Parameters.GrantType);
set => SetParameter(OpenIddictConstants.Parameters.GrantType, value); set => SetParameter(OpenIddictConstants.Parameters.GrantType, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "identity_provider" parameter. /// Gets or sets the "identity_provider" parameter.
/// </summary> /// </summary>
public string IdentityProvider public string? IdentityProvider
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.IdentityProvider); get => (string?) GetParameter(OpenIddictConstants.Parameters.IdentityProvider);
set => SetParameter(OpenIddictConstants.Parameters.IdentityProvider, value); set => SetParameter(OpenIddictConstants.Parameters.IdentityProvider, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "id_token_hint" parameter. /// Gets or sets the "id_token_hint" parameter.
/// </summary> /// </summary>
public string IdTokenHint public string? IdTokenHint
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.IdTokenHint); get => (string?) GetParameter(OpenIddictConstants.Parameters.IdTokenHint);
set => SetParameter(OpenIddictConstants.Parameters.IdTokenHint, value); set => SetParameter(OpenIddictConstants.Parameters.IdTokenHint, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "login_hint" parameter. /// Gets or sets the "login_hint" parameter.
/// </summary> /// </summary>
public string LoginHint public string? LoginHint
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.LoginHint); get => (string?) GetParameter(OpenIddictConstants.Parameters.LoginHint);
set => SetParameter(OpenIddictConstants.Parameters.LoginHint, value); set => SetParameter(OpenIddictConstants.Parameters.LoginHint, value);
} }
@ -270,144 +269,144 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the "nonce" parameter. /// Gets or sets the "nonce" parameter.
/// </summary> /// </summary>
public string Nonce public string? Nonce
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Nonce); get => (string?) GetParameter(OpenIddictConstants.Parameters.Nonce);
set => SetParameter(OpenIddictConstants.Parameters.Nonce, value); set => SetParameter(OpenIddictConstants.Parameters.Nonce, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "password" parameter. /// Gets or sets the "password" parameter.
/// </summary> /// </summary>
public string Password public string? Password
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Password); get => (string?) GetParameter(OpenIddictConstants.Parameters.Password);
set => SetParameter(OpenIddictConstants.Parameters.Password, value); set => SetParameter(OpenIddictConstants.Parameters.Password, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "post_logout_redirect_uri" parameter. /// Gets or sets the "post_logout_redirect_uri" parameter.
/// </summary> /// </summary>
public string PostLogoutRedirectUri public string? PostLogoutRedirectUri
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.PostLogoutRedirectUri); get => (string?) GetParameter(OpenIddictConstants.Parameters.PostLogoutRedirectUri);
set => SetParameter(OpenIddictConstants.Parameters.PostLogoutRedirectUri, value); set => SetParameter(OpenIddictConstants.Parameters.PostLogoutRedirectUri, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "prompt" parameter. /// Gets or sets the "prompt" parameter.
/// </summary> /// </summary>
public string Prompt public string? Prompt
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Prompt); get => (string?) GetParameter(OpenIddictConstants.Parameters.Prompt);
set => SetParameter(OpenIddictConstants.Parameters.Prompt, value); set => SetParameter(OpenIddictConstants.Parameters.Prompt, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "redirect_uri" parameter. /// Gets or sets the "redirect_uri" parameter.
/// </summary> /// </summary>
public string RedirectUri public string? RedirectUri
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.RedirectUri); get => (string?) GetParameter(OpenIddictConstants.Parameters.RedirectUri);
set => SetParameter(OpenIddictConstants.Parameters.RedirectUri, value); set => SetParameter(OpenIddictConstants.Parameters.RedirectUri, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "refresh_token" parameter. /// Gets or sets the "refresh_token" parameter.
/// </summary> /// </summary>
public string RefreshToken public string? RefreshToken
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.RefreshToken); get => (string?) GetParameter(OpenIddictConstants.Parameters.RefreshToken);
set => SetParameter(OpenIddictConstants.Parameters.RefreshToken, value); set => SetParameter(OpenIddictConstants.Parameters.RefreshToken, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "request" parameter. /// Gets or sets the "request" parameter.
/// </summary> /// </summary>
public string Request public string? Request
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Request); get => (string?) GetParameter(OpenIddictConstants.Parameters.Request);
set => SetParameter(OpenIddictConstants.Parameters.Request, value); set => SetParameter(OpenIddictConstants.Parameters.Request, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "request_id" parameter. /// Gets or sets the "request_id" parameter.
/// </summary> /// </summary>
public string RequestId public string? RequestId
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.RequestId); get => (string?) GetParameter(OpenIddictConstants.Parameters.RequestId);
set => SetParameter(OpenIddictConstants.Parameters.RequestId, value); set => SetParameter(OpenIddictConstants.Parameters.RequestId, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "request_uri" parameter. /// Gets or sets the "request_uri" parameter.
/// </summary> /// </summary>
public string RequestUri public string? RequestUri
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.RequestUri); get => (string?) GetParameter(OpenIddictConstants.Parameters.RequestUri);
set => SetParameter(OpenIddictConstants.Parameters.RequestUri, value); set => SetParameter(OpenIddictConstants.Parameters.RequestUri, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "resource" parameters. /// Gets or sets the "resource" parameters.
/// </summary> /// </summary>
public string[] Resources public string[]? Resources
{ {
get => (string[]) GetParameter(OpenIddictConstants.Parameters.Resource); get => (string[]?) GetParameter(OpenIddictConstants.Parameters.Resource);
set => SetParameter(OpenIddictConstants.Parameters.Resource, value); set => SetParameter(OpenIddictConstants.Parameters.Resource, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "response_mode" parameter. /// Gets or sets the "response_mode" parameter.
/// </summary> /// </summary>
public string ResponseMode public string? ResponseMode
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.ResponseMode); get => (string?) GetParameter(OpenIddictConstants.Parameters.ResponseMode);
set => SetParameter(OpenIddictConstants.Parameters.ResponseMode, value); set => SetParameter(OpenIddictConstants.Parameters.ResponseMode, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "response_type" parameter. /// Gets or sets the "response_type" parameter.
/// </summary> /// </summary>
public string ResponseType public string? ResponseType
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.ResponseType); get => (string?) GetParameter(OpenIddictConstants.Parameters.ResponseType);
set => SetParameter(OpenIddictConstants.Parameters.ResponseType, value); set => SetParameter(OpenIddictConstants.Parameters.ResponseType, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "scope" parameter. /// Gets or sets the "scope" parameter.
/// </summary> /// </summary>
public string Scope public string? Scope
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Scope); get => (string?) GetParameter(OpenIddictConstants.Parameters.Scope);
set => SetParameter(OpenIddictConstants.Parameters.Scope, value); set => SetParameter(OpenIddictConstants.Parameters.Scope, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "state" parameter. /// Gets or sets the "state" parameter.
/// </summary> /// </summary>
public string State public string? State
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.State); get => (string?) GetParameter(OpenIddictConstants.Parameters.State);
set => SetParameter(OpenIddictConstants.Parameters.State, value); set => SetParameter(OpenIddictConstants.Parameters.State, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "token" parameter. /// Gets or sets the "token" parameter.
/// </summary> /// </summary>
public string Token public string? Token
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Token); get => (string?) GetParameter(OpenIddictConstants.Parameters.Token);
set => SetParameter(OpenIddictConstants.Parameters.Token, value); set => SetParameter(OpenIddictConstants.Parameters.Token, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "token_type_hint" parameter. /// Gets or sets the "token_type_hint" parameter.
/// </summary> /// </summary>
public string TokenTypeHint public string? TokenTypeHint
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.TokenTypeHint); get => (string?) GetParameter(OpenIddictConstants.Parameters.TokenTypeHint);
set => SetParameter(OpenIddictConstants.Parameters.TokenTypeHint, value); set => SetParameter(OpenIddictConstants.Parameters.TokenTypeHint, value);
} }
@ -423,27 +422,27 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the "ui_locales" parameter. /// Gets or sets the "ui_locales" parameter.
/// </summary> /// </summary>
public string UiLocales public string? UiLocales
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.UiLocales); get => (string?) GetParameter(OpenIddictConstants.Parameters.UiLocales);
set => SetParameter(OpenIddictConstants.Parameters.UiLocales, value); set => SetParameter(OpenIddictConstants.Parameters.UiLocales, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "user_code" parameter. /// Gets or sets the "user_code" parameter.
/// </summary> /// </summary>
public string UserCode public string? UserCode
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.UserCode); get => (string?) GetParameter(OpenIddictConstants.Parameters.UserCode);
set => SetParameter(OpenIddictConstants.Parameters.UserCode, value); set => SetParameter(OpenIddictConstants.Parameters.UserCode, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "username" parameter. /// Gets or sets the "username" parameter.
/// </summary> /// </summary>
public string Username public string? Username
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Username); get => (string?) GetParameter(OpenIddictConstants.Parameters.Username);
set => SetParameter(OpenIddictConstants.Parameters.Username, value); set => SetParameter(OpenIddictConstants.Parameters.Username, value);
} }
} }

57
src/OpenIddict.Abstractions/Primitives/OpenIddictResponse.cs

@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using JetBrains.Annotations;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
@ -46,7 +45,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict response. /// Initializes a new OpenIddict response.
/// </summary> /// </summary>
/// <param name="parameters">The response parameters.</param> /// <param name="parameters">The response parameters.</param>
public OpenIddictResponse([NotNull] IEnumerable<KeyValuePair<string, OpenIddictParameter>> parameters) public OpenIddictResponse(IEnumerable<KeyValuePair<string, OpenIddictParameter>> parameters)
: base(parameters) : base(parameters)
{ {
} }
@ -55,7 +54,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict response. /// Initializes a new OpenIddict response.
/// </summary> /// </summary>
/// <param name="parameters">The response parameters.</param> /// <param name="parameters">The response parameters.</param>
public OpenIddictResponse([NotNull] IEnumerable<KeyValuePair<string, string>> parameters) public OpenIddictResponse(IEnumerable<KeyValuePair<string, string?>> parameters)
: base(parameters) : base(parameters)
{ {
} }
@ -64,7 +63,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict response. /// Initializes a new OpenIddict response.
/// </summary> /// </summary>
/// <param name="parameters">The response parameters.</param> /// <param name="parameters">The response parameters.</param>
public OpenIddictResponse([NotNull] IEnumerable<KeyValuePair<string, string[]>> parameters) public OpenIddictResponse(IEnumerable<KeyValuePair<string, string?[]?>> parameters)
: base(parameters) : base(parameters)
{ {
} }
@ -73,7 +72,7 @@ namespace OpenIddict.Abstractions
/// Initializes a new OpenIddict response. /// Initializes a new OpenIddict response.
/// </summary> /// </summary>
/// <param name="parameters">The response parameters.</param> /// <param name="parameters">The response parameters.</param>
public OpenIddictResponse([NotNull] IEnumerable<KeyValuePair<string, StringValues>> parameters) public OpenIddictResponse(IEnumerable<KeyValuePair<string, StringValues>> parameters)
: base(parameters) : base(parameters)
{ {
} }
@ -81,54 +80,54 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the "access_token" parameter. /// Gets or sets the "access_token" parameter.
/// </summary> /// </summary>
public string AccessToken public string? AccessToken
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.AccessToken); get => (string?) GetParameter(OpenIddictConstants.Parameters.AccessToken);
set => SetParameter(OpenIddictConstants.Parameters.AccessToken, value); set => SetParameter(OpenIddictConstants.Parameters.AccessToken, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "code" parameter. /// Gets or sets the "code" parameter.
/// </summary> /// </summary>
public string Code public string? Code
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Code); get => (string?) GetParameter(OpenIddictConstants.Parameters.Code);
set => SetParameter(OpenIddictConstants.Parameters.Code, value); set => SetParameter(OpenIddictConstants.Parameters.Code, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "device_code" parameter. /// Gets or sets the "device_code" parameter.
/// </summary> /// </summary>
public string DeviceCode public string? DeviceCode
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.DeviceCode); get => (string?) GetParameter(OpenIddictConstants.Parameters.DeviceCode);
set => SetParameter(OpenIddictConstants.Parameters.DeviceCode, value); set => SetParameter(OpenIddictConstants.Parameters.DeviceCode, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "error" parameter. /// Gets or sets the "error" parameter.
/// </summary> /// </summary>
public string Error public string? Error
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Error); get => (string?) GetParameter(OpenIddictConstants.Parameters.Error);
set => SetParameter(OpenIddictConstants.Parameters.Error, value); set => SetParameter(OpenIddictConstants.Parameters.Error, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "error_description" parameter. /// Gets or sets the "error_description" parameter.
/// </summary> /// </summary>
public string ErrorDescription public string? ErrorDescription
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.ErrorDescription); get => (string?) GetParameter(OpenIddictConstants.Parameters.ErrorDescription);
set => SetParameter(OpenIddictConstants.Parameters.ErrorDescription, value); set => SetParameter(OpenIddictConstants.Parameters.ErrorDescription, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "error_uri" parameter. /// Gets or sets the "error_uri" parameter.
/// </summary> /// </summary>
public string ErrorUri public string? ErrorUri
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.ErrorUri); get => (string?) GetParameter(OpenIddictConstants.Parameters.ErrorUri);
set => SetParameter(OpenIddictConstants.Parameters.ErrorUri, value); set => SetParameter(OpenIddictConstants.Parameters.ErrorUri, value);
} }
@ -144,54 +143,54 @@ namespace OpenIddict.Abstractions
/// <summary> /// <summary>
/// Gets or sets the "id_token" parameter. /// Gets or sets the "id_token" parameter.
/// </summary> /// </summary>
public string IdToken public string? IdToken
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.IdToken); get => (string?) GetParameter(OpenIddictConstants.Parameters.IdToken);
set => SetParameter(OpenIddictConstants.Parameters.IdToken, value); set => SetParameter(OpenIddictConstants.Parameters.IdToken, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "refresh_token" parameter. /// Gets or sets the "refresh_token" parameter.
/// </summary> /// </summary>
public string RefreshToken public string? RefreshToken
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.RefreshToken); get => (string?) GetParameter(OpenIddictConstants.Parameters.RefreshToken);
set => SetParameter(OpenIddictConstants.Parameters.RefreshToken, value); set => SetParameter(OpenIddictConstants.Parameters.RefreshToken, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "scope" parameter. /// Gets or sets the "scope" parameter.
/// </summary> /// </summary>
public string Scope public string? Scope
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.Scope); get => (string?) GetParameter(OpenIddictConstants.Parameters.Scope);
set => SetParameter(OpenIddictConstants.Parameters.Scope, value); set => SetParameter(OpenIddictConstants.Parameters.Scope, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "state" parameter. /// Gets or sets the "state" parameter.
/// </summary> /// </summary>
public string State public string? State
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.State); get => (string?) GetParameter(OpenIddictConstants.Parameters.State);
set => SetParameter(OpenIddictConstants.Parameters.State, value); set => SetParameter(OpenIddictConstants.Parameters.State, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "token_type" parameter. /// Gets or sets the "token_type" parameter.
/// </summary> /// </summary>
public string TokenType public string? TokenType
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.TokenType); get => (string?) GetParameter(OpenIddictConstants.Parameters.TokenType);
set => SetParameter(OpenIddictConstants.Parameters.TokenType, value); set => SetParameter(OpenIddictConstants.Parameters.TokenType, value);
} }
/// <summary> /// <summary>
/// Gets or sets the "user_code" parameter. /// Gets or sets the "user_code" parameter.
/// </summary> /// </summary>
public string UserCode public string? UserCode
{ {
get => (string) GetParameter(OpenIddictConstants.Parameters.UserCode); get => (string?) GetParameter(OpenIddictConstants.Parameters.UserCode);
set => SetParameter(OpenIddictConstants.Parameters.UserCode, value); set => SetParameter(OpenIddictConstants.Parameters.UserCode, value);
} }
} }

17
src/OpenIddict.Abstractions/Resources/OpenIddictResources.resx

@ -1451,7 +1451,7 @@ Consider creating non-generic classes derived from the default entities for the
<value>Callback URLs must be valid absolute URLs.</value> <value>Callback URLs must be valid absolute URLs.</value>
</data> </data>
<data name="ID5000" xml:space="preserve"> <data name="ID5000" xml:space="preserve">
<value>The source string shouldn't be null or empty.</value> <value>The '{0}' parameter shouldn't be null or empty at this point.</value>
</data> </data>
<data name="ID5001" xml:space="preserve"> <data name="ID5001" xml:space="preserve">
<value>The separators collection shouldn't be null or empty.</value> <value>The separators collection shouldn't be null or empty.</value>
@ -1468,6 +1468,21 @@ Consider creating non-generic classes derived from the default entities for the
<data name="ID5005" xml:space="preserve"> <data name="ID5005" xml:space="preserve">
<value>ECDsa.ExportParameters() shouldn't return an unnamed curve.</value> <value>ECDsa.ExportParameters() shouldn't return an unnamed curve.</value>
</data> </data>
<data name="ID5006" xml:space="preserve">
<value>The principal shouldn't be null at this point.</value>
</data>
<data name="ID5007" xml:space="preserve">
<value>The response shouldn't be null at this point.</value>
</data>
<data name="ID5008" xml:space="preserve">
<value>The request shouldn't be null at this point.</value>
</data>
<data name="ID5009" xml:space="preserve">
<value>The token type shouldn't be null or empty.</value>
</data>
<data name="ID5010" xml:space="preserve">
<value>The token shouldn't be null or empty at this point.</value>
</data>
<data name="ID7000" xml:space="preserve"> <data name="ID7000" xml:space="preserve">
<value>An error occurred while validating the token '{Token}'.</value> <value>An error occurred while validating the token '{Token}'.</value>
</data> </data>

77
src/OpenIddict.Abstractions/Stores/IOpenIddictApplicationStore.cs

@ -12,7 +12,6 @@ using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -42,7 +41,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of applications that match the specified query. /// whose result returns the number of applications that match the specified query.
/// </returns> /// </returns>
ValueTask<long> CountAsync<TResult>([NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken); ValueTask<long> CountAsync<TResult>(Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Creates a new application. /// Creates a new application.
@ -50,7 +49,7 @@ namespace OpenIddict.Abstractions
/// <param name="application">The application to create.</param> /// <param name="application">The application to create.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask CreateAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes an existing application. /// Removes an existing application.
@ -58,7 +57,7 @@ namespace OpenIddict.Abstractions
/// <param name="application">The application to delete.</param> /// <param name="application">The application to delete.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask DeleteAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask DeleteAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves an application using its unique identifier. /// Retrieves an application using its unique identifier.
@ -69,7 +68,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier. /// whose result returns the client application corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<TApplication> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TApplication?> FindByIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves an application using its client identifier. /// Retrieves an application using its client identifier.
@ -80,7 +79,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier. /// whose result returns the client application corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<TApplication> FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TApplication?> FindByClientIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves all the applications associated with the specified post_logout_redirect_uri. /// Retrieves all the applications associated with the specified post_logout_redirect_uri.
@ -88,7 +87,7 @@ namespace OpenIddict.Abstractions
/// <param name="address">The post_logout_redirect_uri associated with the applications.</param> /// <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> /// <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> /// <returns>The client applications corresponding to the specified post_logout_redirect_uri.</returns>
IAsyncEnumerable<TApplication> FindByPostLogoutRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken); IAsyncEnumerable<TApplication> FindByPostLogoutRedirectUriAsync(string address, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves all the applications associated with the specified redirect_uri. /// Retrieves all the applications associated with the specified redirect_uri.
@ -96,7 +95,7 @@ namespace OpenIddict.Abstractions
/// <param name="address">The redirect_uri associated with the applications.</param> /// <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> /// <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> /// <returns>The client applications corresponding to the specified redirect_uri.</returns>
IAsyncEnumerable<TApplication> FindByRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken); IAsyncEnumerable<TApplication> FindByRedirectUriAsync(string address, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -111,8 +110,8 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TState, TResult>( ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query, Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken); TState state, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the client identifier associated with an application. /// Retrieves the client identifier associated with an application.
@ -123,7 +122,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client identifier associated with the application. /// whose result returns the client identifier associated with the application.
/// </returns> /// </returns>
ValueTask<string> GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<string?> GetClientIdAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the client secret associated with an application. /// Retrieves the client secret associated with an application.
@ -136,7 +135,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client secret associated with the application. /// whose result returns the client secret associated with the application.
/// </returns> /// </returns>
ValueTask<string> GetClientSecretAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<string?> GetClientSecretAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the client type associated with an application. /// Retrieves the client type associated with an application.
@ -147,7 +146,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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"). /// whose result returns the client type of the application (by default, "public").
/// </returns> /// </returns>
ValueTask<string> GetClientTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<string?> GetClientTypeAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the consent type associated with an application. /// Retrieves the consent type associated with an application.
@ -158,7 +157,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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"). /// whose result returns the consent type of the application (by default, "explicit").
/// </returns> /// </returns>
ValueTask<string> GetConsentTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<string?> GetConsentTypeAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the display name associated with an application. /// Retrieves the display name associated with an application.
@ -169,7 +168,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the application. /// whose result returns the display name associated with the application.
/// </returns> /// </returns>
ValueTask<string> GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<string?> GetDisplayNameAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the localized display names associated with an application. /// Retrieves the localized display names associated with an application.
@ -180,7 +179,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the localized display names associated with the application. /// whose result returns all the localized display names associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the unique identifier associated with an application. /// Retrieves the unique identifier associated with an application.
@ -191,7 +190,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application. /// whose result returns the unique identifier associated with the application.
/// </returns> /// </returns>
ValueTask<string> GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<string?> GetIdAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the permissions associated with an application. /// Retrieves the permissions associated with an application.
@ -202,7 +201,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the permissions associated with the application. /// whose result returns all the permissions associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetPermissionsAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<ImmutableArray<string>> GetPermissionsAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the logout callback addresses associated with an application. /// Retrieves the logout callback addresses associated with an application.
@ -213,7 +212,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the post_logout_redirect_uri associated with the application. /// whose result returns all the post_logout_redirect_uri associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetPostLogoutRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<ImmutableArray<string>> GetPostLogoutRedirectUrisAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the additional properties associated with an application. /// Retrieves the additional properties associated with an application.
@ -224,7 +223,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the additional properties associated with the application. /// whose result returns all the additional properties associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the callback addresses associated with an application. /// Retrieves the callback addresses associated with an application.
@ -235,7 +234,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the redirect_uri associated with the application. /// whose result returns all the redirect_uri associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<ImmutableArray<string>> GetRedirectUrisAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the requirements associated with an application. /// Retrieves the requirements associated with an application.
@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the requirements associated with the application. /// whose result returns all the requirements associated with the application.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetRequirementsAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask<ImmutableArray<string>> GetRequirementsAsync(TApplication application, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Instantiates a new application. /// Instantiates a new application.
@ -265,7 +264,7 @@ namespace OpenIddict.Abstractions
/// <param name="offset">The number of results to skip.</param> /// <param name="offset">The number of results to skip.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TApplication> ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken); IAsyncEnumerable<TApplication> ListAsync(int? count, int? offset, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -277,8 +276,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TState, TResult>( IAsyncEnumerable<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query, Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken); TState state, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the client identifier associated with an application. /// Sets the client identifier associated with an application.
@ -287,7 +286,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The client identifier associated with the application.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetClientIdAsync([NotNull] TApplication application, [CanBeNull] string identifier, CancellationToken cancellationToken); ValueTask SetClientIdAsync(TApplication application, string? identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the client secret associated with an application. /// Sets the client secret associated with an application.
@ -298,7 +297,7 @@ namespace OpenIddict.Abstractions
/// <param name="secret">The client secret associated with the application.</param> /// <param name="secret">The client secret associated with the application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetClientSecretAsync([NotNull] TApplication application, [CanBeNull] string secret, CancellationToken cancellationToken); ValueTask SetClientSecretAsync(TApplication application, string? secret, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the client type associated with an application. /// Sets the client type associated with an application.
@ -307,7 +306,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The client type associated with the application.</param> /// <param name="type">The client type associated with the application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetClientTypeAsync([NotNull] TApplication application, [CanBeNull] string type, CancellationToken cancellationToken); ValueTask SetClientTypeAsync(TApplication application, string? type, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the consent type associated with an application. /// Sets the consent type associated with an application.
@ -316,7 +315,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The consent type associated with the application.</param> /// <param name="type">The consent type associated with the application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetConsentTypeAsync([NotNull] TApplication application, [CanBeNull] string type, CancellationToken cancellationToken); ValueTask SetConsentTypeAsync(TApplication application, string? type, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the display name associated with an application. /// Sets the display name associated with an application.
@ -325,7 +324,7 @@ namespace OpenIddict.Abstractions
/// <param name="name">The display name associated with the application.</param> /// <param name="name">The display name associated with the application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetDisplayNameAsync([NotNull] TApplication application, [CanBeNull] string name, CancellationToken cancellationToken); ValueTask SetDisplayNameAsync(TApplication application, string? name, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the localized display names associated with an application. /// Sets the localized display names associated with an application.
@ -334,8 +333,8 @@ namespace OpenIddict.Abstractions
/// <param name="names">The localized display names associated with the application.</param> /// <param name="names">The localized display names associated with the application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetDisplayNamesAsync([NotNull] TApplication application, ValueTask SetDisplayNamesAsync(TApplication application,
[CanBeNull] ImmutableDictionary<CultureInfo, string> names, CancellationToken cancellationToken); ImmutableDictionary<CultureInfo, string> names, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the permissions associated with an application. /// Sets the permissions associated with an application.
@ -344,7 +343,7 @@ namespace OpenIddict.Abstractions
/// <param name="permissions">The permissions associated with the application </param> /// <param name="permissions">The permissions associated with the application </param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetPermissionsAsync([NotNull] TApplication application, ImmutableArray<string> permissions, CancellationToken cancellationToken); ValueTask SetPermissionsAsync(TApplication application, ImmutableArray<string> permissions, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the logout callback addresses associated with an application. /// Sets the logout callback addresses associated with an application.
@ -353,7 +352,7 @@ namespace OpenIddict.Abstractions
/// <param name="addresses">The logout callback addresses associated with the application </param> /// <param name="addresses">The logout callback addresses associated with the application </param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetPostLogoutRedirectUrisAsync([NotNull] TApplication application, ValueTask SetPostLogoutRedirectUrisAsync(TApplication application,
ImmutableArray<string> addresses, CancellationToken cancellationToken); ImmutableArray<string> addresses, CancellationToken cancellationToken);
/// <summary> /// <summary>
@ -363,8 +362,8 @@ namespace OpenIddict.Abstractions
/// <param name="properties">The additional properties associated with the application.</param> /// <param name="properties">The additional properties associated with the application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetPropertiesAsync([NotNull] TApplication application, ValueTask SetPropertiesAsync(TApplication application,
[CanBeNull] ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken); ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the callback addresses associated with an application. /// Sets the callback addresses associated with an application.
@ -373,7 +372,7 @@ namespace OpenIddict.Abstractions
/// <param name="addresses">The callback addresses associated with the application </param> /// <param name="addresses">The callback addresses associated with the application </param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetRedirectUrisAsync([NotNull] TApplication application, ValueTask SetRedirectUrisAsync(TApplication application,
ImmutableArray<string> addresses, CancellationToken cancellationToken); ImmutableArray<string> addresses, CancellationToken cancellationToken);
/// <summary> /// <summary>
@ -383,7 +382,7 @@ namespace OpenIddict.Abstractions
/// <param name="requirements">The requirements associated with the application </param> /// <param name="requirements">The requirements associated with the application </param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetRequirementsAsync([NotNull] TApplication application, ImmutableArray<string> requirements, CancellationToken cancellationToken); ValueTask SetRequirementsAsync(TApplication application, ImmutableArray<string> requirements, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Updates an existing application. /// Updates an existing application.
@ -391,6 +390,6 @@ namespace OpenIddict.Abstractions
/// <param name="application">The application to update.</param> /// <param name="application">The application to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask UpdateAsync([NotNull] TApplication application, CancellationToken cancellationToken); ValueTask UpdateAsync(TApplication application, CancellationToken cancellationToken);
} }
} }

71
src/OpenIddict.Abstractions/Stores/IOpenIddictAuthorizationStore.cs

@ -11,7 +11,6 @@ using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -41,7 +40,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of authorizations that match the specified query. /// whose result returns the number of authorizations that match the specified query.
/// </returns> /// </returns>
ValueTask<long> CountAsync<TResult>([NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken); ValueTask<long> CountAsync<TResult>(Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Creates a new authorization. /// Creates a new authorization.
@ -49,7 +48,7 @@ namespace OpenIddict.Abstractions
/// <param name="authorization">The authorization to create.</param> /// <param name="authorization">The authorization to create.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask CreateAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes an existing authorization. /// Removes an existing authorization.
@ -57,7 +56,7 @@ namespace OpenIddict.Abstractions
/// <param name="authorization">The authorization to delete.</param> /// <param name="authorization">The authorization to delete.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask DeleteAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the authorizations corresponding to the specified /// Retrieves the authorizations corresponding to the specified
@ -67,7 +66,7 @@ namespace OpenIddict.Abstractions
/// <param name="client">The client 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> /// <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> /// <returns>The authorizations corresponding to the subject/client.</returns>
IAsyncEnumerable<TAuthorization> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken); IAsyncEnumerable<TAuthorization> FindAsync(string subject, string client, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the authorizations matching the specified parameters. /// Retrieves the authorizations matching the specified parameters.
@ -78,8 +77,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The authorizations corresponding to the criteria.</returns>
IAsyncEnumerable<TAuthorization> FindAsync( IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, CancellationToken cancellationToken); string status, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the authorizations matching the specified parameters. /// Retrieves the authorizations matching the specified parameters.
@ -91,8 +90,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The authorizations corresponding to the criteria.</returns>
IAsyncEnumerable<TAuthorization> FindAsync( IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, [NotNull] string type, CancellationToken cancellationToken); string status, string type, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the authorizations matching the specified parameters. /// Retrieves the authorizations matching the specified parameters.
@ -105,8 +104,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The authorizations corresponding to the criteria.</returns>
IAsyncEnumerable<TAuthorization> FindAsync( IAsyncEnumerable<TAuthorization> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, [NotNull] string type, string status, string type,
ImmutableArray<string> scopes, CancellationToken cancellationToken); ImmutableArray<string> scopes, CancellationToken cancellationToken);
/// <summary> /// <summary>
@ -115,7 +114,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The application identifier associated with the authorizations.</param> /// <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> /// <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> /// <returns>The authorizations corresponding to the specified application.</returns>
IAsyncEnumerable<TAuthorization> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); IAsyncEnumerable<TAuthorization> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves an authorization using its unique identifier. /// Retrieves an authorization using its unique identifier.
@ -126,7 +125,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the identifier. /// whose result returns the authorization corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<TAuthorization> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TAuthorization?> FindByIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves all the authorizations corresponding to the specified subject. /// Retrieves all the authorizations corresponding to the specified subject.
@ -134,7 +133,7 @@ namespace OpenIddict.Abstractions
/// <param name="subject">The subject associated with the authorization.</param> /// <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> /// <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> /// <returns>The authorizations corresponding to the specified subject.</returns>
IAsyncEnumerable<TAuthorization> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken); IAsyncEnumerable<TAuthorization> FindBySubjectAsync(string subject, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the optional application identifier associated with an authorization. /// Retrieves the optional application identifier associated with an authorization.
@ -145,7 +144,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the authorization. /// whose result returns the application identifier associated with the authorization.
/// </returns> /// </returns>
ValueTask<string> GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask<string?> GetApplicationIdAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -160,8 +159,8 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TState, TResult>( ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query, Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken); TState state, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the unique identifier associated with an authorization. /// Retrieves the unique identifier associated with an authorization.
@ -172,7 +171,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the authorization. /// whose result returns the unique identifier associated with the authorization.
/// </returns> /// </returns>
ValueTask<string> GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask<string?> GetIdAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the additional properties associated with an authorization. /// Retrieves the additional properties associated with an authorization.
@ -183,7 +182,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the additional properties associated with the authorization. /// whose result returns all the additional properties associated with the authorization.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the scopes associated with an authorization. /// Retrieves the scopes associated with an authorization.
@ -194,7 +193,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scopes associated with the specified authorization. /// whose result returns the scopes associated with the specified authorization.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetScopesAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask<ImmutableArray<string>> GetScopesAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the status associated with an authorization. /// Retrieves the status associated with an authorization.
@ -205,7 +204,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified authorization. /// whose result returns the status associated with the specified authorization.
/// </returns> /// </returns>
ValueTask<string> GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask<string?> GetStatusAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the subject associated with an authorization. /// Retrieves the subject associated with an authorization.
@ -216,7 +215,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the subject associated with the specified authorization. /// whose result returns the subject associated with the specified authorization.
/// </returns> /// </returns>
ValueTask<string> GetSubjectAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask<string?> GetSubjectAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the type associated with an authorization. /// Retrieves the type associated with an authorization.
@ -227,7 +226,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the type associated with the specified authorization. /// whose result returns the type associated with the specified authorization.
/// </returns> /// </returns>
ValueTask<string> GetTypeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask<string?> GetTypeAsync(TAuthorization authorization, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Instantiates a new authorization. /// Instantiates a new authorization.
@ -246,7 +245,7 @@ namespace OpenIddict.Abstractions
/// <param name="offset">The number of results to skip.</param> /// <param name="offset">The number of results to skip.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TAuthorization> ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken); IAsyncEnumerable<TAuthorization> ListAsync(int? count, int? offset, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -258,8 +257,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TState, TResult>( IAsyncEnumerable<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query, Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken); TState state, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes the authorizations that are marked as invalid and the ad-hoc ones that have no valid/nonexpired token attached. /// Removes the authorizations that are marked as invalid and the ad-hoc ones that have no valid/nonexpired token attached.
@ -275,8 +274,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The unique identifier associated with the client application.</param> /// <param name="identifier">The unique identifier associated with the client application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetApplicationIdAsync([NotNull] TAuthorization authorization, ValueTask SetApplicationIdAsync(TAuthorization authorization, string? identifier, CancellationToken cancellationToken);
[CanBeNull] string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the additional properties associated with an authorization. /// Sets the additional properties associated with an authorization.
@ -285,8 +283,8 @@ namespace OpenIddict.Abstractions
/// <param name="properties">The additional properties associated with the authorization.</param> /// <param name="properties">The additional properties associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetPropertiesAsync([NotNull] TAuthorization authorization, ValueTask SetPropertiesAsync(TAuthorization authorization,
[CanBeNull] ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken); ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the scopes associated with an authorization. /// Sets the scopes associated with an authorization.
@ -295,7 +293,7 @@ namespace OpenIddict.Abstractions
/// <param name="scopes">The scopes associated with the authorization.</param> /// <param name="scopes">The scopes associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetScopesAsync([NotNull] TAuthorization authorization, ValueTask SetScopesAsync(TAuthorization authorization,
ImmutableArray<string> scopes, CancellationToken cancellationToken); ImmutableArray<string> scopes, CancellationToken cancellationToken);
/// <summary> /// <summary>
@ -305,8 +303,7 @@ namespace OpenIddict.Abstractions
/// <param name="status">The status associated with the authorization.</param> /// <param name="status">The status associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetStatusAsync([NotNull] TAuthorization authorization, ValueTask SetStatusAsync(TAuthorization authorization, string? status, CancellationToken cancellationToken);
[CanBeNull] string status, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the subject associated with an authorization. /// Sets the subject associated with an authorization.
@ -315,8 +312,7 @@ namespace OpenIddict.Abstractions
/// <param name="subject">The subject associated with the authorization.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetSubjectAsync([NotNull] TAuthorization authorization, ValueTask SetSubjectAsync(TAuthorization authorization, string? subject, CancellationToken cancellationToken);
[CanBeNull] string subject, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the type associated with an authorization. /// Sets the type associated with an authorization.
@ -325,8 +321,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The type associated with the authorization.</param> /// <param name="type">The type associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetTypeAsync([NotNull] TAuthorization authorization, ValueTask SetTypeAsync(TAuthorization authorization, string? type, CancellationToken cancellationToken);
[CanBeNull] string type, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Updates an existing authorization. /// Updates an existing authorization.
@ -334,6 +329,6 @@ namespace OpenIddict.Abstractions
/// <param name="authorization">The authorization to update.</param> /// <param name="authorization">The authorization to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask UpdateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken); ValueTask UpdateAsync(TAuthorization authorization, CancellationToken cancellationToken);
} }
} }

61
src/OpenIddict.Abstractions/Stores/IOpenIddictScopeStore.cs

@ -12,7 +12,6 @@ using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -42,7 +41,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of scopes that match the specified query. /// whose result returns the number of scopes that match the specified query.
/// </returns> /// </returns>
ValueTask<long> CountAsync<TResult>([NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken); ValueTask<long> CountAsync<TResult>(Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Creates a new scope. /// Creates a new scope.
@ -50,7 +49,7 @@ namespace OpenIddict.Abstractions
/// <param name="scope">The scope to create.</param> /// <param name="scope">The scope to create.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask CreateAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes an existing scope. /// Removes an existing scope.
@ -58,7 +57,7 @@ namespace OpenIddict.Abstractions
/// <param name="scope">The scope to delete.</param> /// <param name="scope">The scope to delete.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask DeleteAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask DeleteAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves a scope using its unique identifier. /// Retrieves a scope using its unique identifier.
@ -69,7 +68,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scope corresponding to the identifier. /// whose result returns the scope corresponding to the identifier.
/// </returns> /// </returns>
ValueTask<TScope> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TScope?> FindByIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves a scope using its name. /// Retrieves a scope using its name.
@ -80,7 +79,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scope corresponding to the specified name. /// whose result returns the scope corresponding to the specified name.
/// </returns> /// </returns>
ValueTask<TScope> FindByNameAsync([NotNull] string name, CancellationToken cancellationToken); ValueTask<TScope?> FindByNameAsync(string name, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves a list of scopes using their name. /// Retrieves a list of scopes using their name.
@ -96,7 +95,7 @@ namespace OpenIddict.Abstractions
/// <param name="resource">The resource associated with the scopes.</param> /// <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> /// <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> /// <returns>The scopes associated with the specified resource.</returns>
IAsyncEnumerable<TScope> FindByResourceAsync([NotNull] string resource, CancellationToken cancellationToken); IAsyncEnumerable<TScope> FindByResourceAsync(string resource, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -111,8 +110,8 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TState, TResult>( ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TScope>, TState, IQueryable<TResult>> query, Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken); TState state, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the description associated with a scope. /// Retrieves the description associated with a scope.
@ -123,7 +122,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the description associated with the specified scope. /// whose result returns the description associated with the specified scope.
/// </returns> /// </returns>
ValueTask<string> GetDescriptionAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask<string?> GetDescriptionAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the localized descriptions associated with a scope. /// Retrieves the localized descriptions associated with a scope.
@ -134,7 +133,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the localized descriptions associated with the specified scope. /// whose result returns all the localized descriptions associated with the specified scope.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<CultureInfo, string>> GetDescriptionsAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask<ImmutableDictionary<CultureInfo, string>> GetDescriptionsAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the display name associated with a scope. /// Retrieves the display name associated with a scope.
@ -145,7 +144,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the scope. /// whose result returns the display name associated with the scope.
/// </returns> /// </returns>
ValueTask<string> GetDisplayNameAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask<string?> GetDisplayNameAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the localized display names associated with a scope. /// Retrieves the localized display names associated with a scope.
@ -156,7 +155,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the localized display names associated with the scope. /// whose result returns all the localized display names associated with the scope.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask<ImmutableDictionary<CultureInfo, string>> GetDisplayNamesAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the unique identifier associated with a scope. /// Retrieves the unique identifier associated with a scope.
@ -167,7 +166,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the scope. /// whose result returns the unique identifier associated with the scope.
/// </returns> /// </returns>
ValueTask<string> GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask<string?> GetIdAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the name associated with a scope. /// Retrieves the name associated with a scope.
@ -178,7 +177,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the name associated with the specified scope. /// whose result returns the name associated with the specified scope.
/// </returns> /// </returns>
ValueTask<string> GetNameAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask<string?> GetNameAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the additional properties associated with a scope. /// Retrieves the additional properties associated with a scope.
@ -189,7 +188,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, whose /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, whose
/// result returns all the additional properties associated with the scope. /// result returns all the additional properties associated with the scope.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the resources associated with a scope. /// Retrieves the resources associated with a scope.
@ -200,7 +199,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the resources associated with the scope. /// whose result returns all the resources associated with the scope.
/// </returns> /// </returns>
ValueTask<ImmutableArray<string>> GetResourcesAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask<ImmutableArray<string>> GetResourcesAsync(TScope scope, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Instantiates a new scope. /// Instantiates a new scope.
@ -219,7 +218,7 @@ namespace OpenIddict.Abstractions
/// <param name="offset">The number of results to skip.</param> /// <param name="offset">The number of results to skip.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TScope> ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken); IAsyncEnumerable<TScope> ListAsync(int? count, int? offset, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -231,8 +230,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TState, TResult>( IAsyncEnumerable<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TScope>, TState, IQueryable<TResult>> query, Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken); TState state, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the description associated with a scope. /// Sets the description associated with a scope.
@ -241,7 +240,7 @@ namespace OpenIddict.Abstractions
/// <param name="description">The description associated with the authorization.</param> /// <param name="description">The description associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetDescriptionAsync([NotNull] TScope scope, [CanBeNull] string description, CancellationToken cancellationToken); ValueTask SetDescriptionAsync(TScope scope, string? description, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the localized descriptions associated with a scope. /// Sets the localized descriptions associated with a scope.
@ -250,8 +249,8 @@ namespace OpenIddict.Abstractions
/// <param name="descriptions">The localized descriptions associated with the authorization.</param> /// <param name="descriptions">The localized descriptions associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetDescriptionsAsync([NotNull] TScope scope, ValueTask SetDescriptionsAsync(TScope scope,
[CanBeNull] ImmutableDictionary<CultureInfo, string> descriptions, CancellationToken cancellationToken); ImmutableDictionary<CultureInfo, string> descriptions, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the display name associated with a scope. /// Sets the display name associated with a scope.
@ -260,7 +259,7 @@ namespace OpenIddict.Abstractions
/// <param name="name">The display name associated with the scope.</param> /// <param name="name">The display name associated with the scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetDisplayNameAsync([NotNull] TScope scope, [CanBeNull] string name, CancellationToken cancellationToken); ValueTask SetDisplayNameAsync(TScope scope, string? name, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the localized display names associated with a scope. /// Sets the localized display names associated with a scope.
@ -269,8 +268,8 @@ namespace OpenIddict.Abstractions
/// <param name="names">The localized display names associated with the scope.</param> /// <param name="names">The localized display names associated with the scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetDisplayNamesAsync([NotNull] TScope scope, ValueTask SetDisplayNamesAsync(TScope scope,
[CanBeNull] ImmutableDictionary<CultureInfo, string> names, CancellationToken cancellationToken); ImmutableDictionary<CultureInfo, string> names, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the name associated with a scope. /// Sets the name associated with a scope.
@ -279,7 +278,7 @@ namespace OpenIddict.Abstractions
/// <param name="name">The name associated with the authorization.</param> /// <param name="name">The name associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetNameAsync([NotNull] TScope scope, [CanBeNull] string name, CancellationToken cancellationToken); ValueTask SetNameAsync(TScope scope, string? name, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the additional properties associated with a scope. /// Sets the additional properties associated with a scope.
@ -288,8 +287,8 @@ namespace OpenIddict.Abstractions
/// <param name="properties">The additional properties associated with the scope.</param> /// <param name="properties">The additional properties associated with the scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetPropertiesAsync([NotNull] TScope scope, ValueTask SetPropertiesAsync(TScope scope,
[CanBeNull] ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken); ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the resources associated with a scope. /// Sets the resources associated with a scope.
@ -298,7 +297,7 @@ namespace OpenIddict.Abstractions
/// <param name="resources">The resources associated with the scope.</param> /// <param name="resources">The resources associated with the scope.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetResourcesAsync([NotNull] TScope scope, ImmutableArray<string> resources, CancellationToken cancellationToken); ValueTask SetResourcesAsync(TScope scope, ImmutableArray<string> resources, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Updates an existing scope. /// Updates an existing scope.
@ -306,6 +305,6 @@ namespace OpenIddict.Abstractions
/// <param name="scope">The scope to update.</param> /// <param name="scope">The scope to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask UpdateAsync([NotNull] TScope scope, CancellationToken cancellationToken); ValueTask UpdateAsync(TScope scope, CancellationToken cancellationToken);
} }
} }

83
src/OpenIddict.Abstractions/Stores/IOpenIddictTokenStore.cs

@ -11,7 +11,6 @@ using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using JetBrains.Annotations;
namespace OpenIddict.Abstractions namespace OpenIddict.Abstractions
{ {
@ -41,7 +40,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of tokens that match the specified query. /// whose result returns the number of tokens that match the specified query.
/// </returns> /// </returns>
ValueTask<long> CountAsync<TResult>([NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken); ValueTask<long> CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Creates a new token. /// Creates a new token.
@ -49,7 +48,7 @@ namespace OpenIddict.Abstractions
/// <param name="token">The token to create.</param> /// <param name="token">The token to create.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask CreateAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask CreateAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes a token. /// Removes a token.
@ -57,7 +56,7 @@ namespace OpenIddict.Abstractions
/// <param name="token">The token to delete.</param> /// <param name="token">The token to delete.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask DeleteAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the tokens corresponding to the specified /// Retrieves the tokens corresponding to the specified
@ -67,7 +66,7 @@ namespace OpenIddict.Abstractions
/// <param name="client">The client 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> /// <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> /// <returns>The tokens corresponding to the subject/client.</returns>
IAsyncEnumerable<TToken> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken); IAsyncEnumerable<TToken> FindAsync(string subject, string client, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the tokens matching the specified parameters. /// Retrieves the tokens matching the specified parameters.
@ -78,8 +77,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The tokens corresponding to the criteria.</returns>
IAsyncEnumerable<TToken> FindAsync( IAsyncEnumerable<TToken> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, CancellationToken cancellationToken); string status, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the tokens matching the specified parameters. /// Retrieves the tokens matching the specified parameters.
@ -91,8 +90,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>The tokens corresponding to the criteria.</returns>
IAsyncEnumerable<TToken> FindAsync( IAsyncEnumerable<TToken> FindAsync(
[NotNull] string subject, [NotNull] string client, string subject, string client,
[NotNull] string status, [NotNull] string type, CancellationToken cancellationToken); string status, string type, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified application identifier. /// Retrieves the list of tokens corresponding to the specified application identifier.
@ -100,7 +99,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The application identifier associated with the tokens.</param> /// <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> /// <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> /// <returns>The tokens corresponding to the specified application.</returns>
IAsyncEnumerable<TToken> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); IAsyncEnumerable<TToken> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified authorization identifier. /// Retrieves the list of tokens corresponding to the specified authorization identifier.
@ -108,7 +107,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The authorization identifier associated with the tokens.</param> /// <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> /// <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> /// <returns>The tokens corresponding to the specified authorization.</returns>
IAsyncEnumerable<TToken> FindByAuthorizationIdAsync([NotNull] string identifier, CancellationToken cancellationToken); IAsyncEnumerable<TToken> FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves a token using its unique identifier. /// Retrieves a token using its unique identifier.
@ -119,7 +118,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the token corresponding to the unique identifier. /// whose result returns the token corresponding to the unique identifier.
/// </returns> /// </returns>
ValueTask<TToken> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TToken?> FindByIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified reference identifier. /// Retrieves the list of tokens corresponding to the specified reference identifier.
@ -131,7 +130,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified reference identifier. /// whose result returns the tokens corresponding to the specified reference identifier.
/// </returns> /// </returns>
ValueTask<TToken> FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken); ValueTask<TToken?> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the list of tokens corresponding to the specified subject. /// Retrieves the list of tokens corresponding to the specified subject.
@ -139,7 +138,7 @@ namespace OpenIddict.Abstractions
/// <param name="subject">The subject associated with the tokens.</param> /// <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> /// <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> /// <returns>The tokens corresponding to the specified subject.</returns>
IAsyncEnumerable<TToken> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken); IAsyncEnumerable<TToken> FindBySubjectAsync(string subject, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the optional application identifier associated with a token. /// Retrieves the optional application identifier associated with a token.
@ -150,7 +149,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the token. /// whose result returns the application identifier associated with the token.
/// </returns> /// </returns>
ValueTask<string> GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<string?> GetApplicationIdAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Executes the specified query and returns the first element. /// Executes the specified query and returns the first element.
@ -165,8 +164,8 @@ namespace OpenIddict.Abstractions
/// whose result returns the first element returned when executing the query. /// whose result returns the first element returned when executing the query.
/// </returns> /// </returns>
ValueTask<TResult> GetAsync<TState, TResult>( ValueTask<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken); TState state, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the optional authorization identifier associated with a token. /// Retrieves the optional authorization identifier associated with a token.
@ -177,7 +176,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization identifier associated with the token. /// whose result returns the authorization identifier associated with the token.
/// </returns> /// </returns>
ValueTask<string> GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<string?> GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the creation date associated with a token. /// Retrieves the creation date associated with a token.
@ -188,7 +187,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the creation date associated with the specified token.
/// </returns> /// </returns>
ValueTask<DateTimeOffset?> GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<DateTimeOffset?> GetCreationDateAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the expiration date associated with a token. /// Retrieves the expiration date associated with a token.
@ -199,7 +198,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the expiration date associated with the specified token.
/// </returns> /// </returns>
ValueTask<DateTimeOffset?> GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<DateTimeOffset?> GetExpirationDateAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the unique identifier associated with a token. /// Retrieves the unique identifier associated with a token.
@ -210,7 +209,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the token. /// whose result returns the unique identifier associated with the token.
/// </returns> /// </returns>
ValueTask<string> GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<string?> GetIdAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the payload associated with a token. /// Retrieves the payload associated with a token.
@ -221,7 +220,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the payload associated with the specified token. /// whose result returns the payload associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<string?> GetPayloadAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the additional properties associated with a token. /// Retrieves the additional properties associated with a token.
@ -232,7 +231,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the additional properties associated with the token. /// whose result returns all the additional properties associated with the token.
/// </returns> /// </returns>
ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the reference identifier associated with a token. /// Retrieves the reference identifier associated with a token.
@ -245,7 +244,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the reference identifier associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<string?> GetReferenceIdAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the status associated with a token. /// Retrieves the status associated with a token.
@ -256,7 +255,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified token. /// whose result returns the status associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<string?> GetStatusAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the subject associated with a token. /// Retrieves the subject associated with a token.
@ -267,7 +266,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation,
/// whose result returns the subject associated with the specified token. /// whose result returns the subject associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetSubjectAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<string?> GetSubjectAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Retrieves the token type associated with a token. /// Retrieves the token type associated with a token.
@ -278,7 +277,7 @@ namespace OpenIddict.Abstractions
/// A <see cref="ValueTask{TResult}"/> that can be used to monitor the asynchronous operation, /// 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. /// whose result returns the token type associated with the specified token.
/// </returns> /// </returns>
ValueTask<string> GetTypeAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask<string?> GetTypeAsync(TToken token, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Instantiates a new token. /// Instantiates a new token.
@ -297,7 +296,7 @@ namespace OpenIddict.Abstractions
/// <param name="offset">The number of results to skip.</param> /// <param name="offset">The number of results to skip.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TToken> ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken); IAsyncEnumerable<TToken> ListAsync(int? count, int? offset, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Executes the specified query and returns all the corresponding elements. /// Executes the specified query and returns all the corresponding elements.
@ -309,8 +308,8 @@ namespace OpenIddict.Abstractions
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>All the elements returned when executing the specified query.</returns> /// <returns>All the elements returned when executing the specified query.</returns>
IAsyncEnumerable<TResult> ListAsync<TState, TResult>( IAsyncEnumerable<TResult> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken); TState state, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Removes the tokens that are marked as expired or invalid. /// Removes the tokens that are marked as expired or invalid.
@ -326,7 +325,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The unique identifier associated with the token.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetApplicationIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken); ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the authorization identifier associated with a token. /// Sets the authorization identifier associated with a token.
@ -335,7 +334,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The unique identifier associated with the token.</param> /// <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> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetAuthorizationIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken); ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the creation date associated with a token. /// Sets the creation date associated with a token.
@ -344,7 +343,7 @@ namespace OpenIddict.Abstractions
/// <param name="date">The creation date.</param> /// <param name="date">The creation date.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetCreationDateAsync([NotNull] TToken token, [CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken); ValueTask SetCreationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the expiration date associated with a token. /// Sets the expiration date associated with a token.
@ -353,7 +352,7 @@ namespace OpenIddict.Abstractions
/// <param name="date">The expiration date.</param> /// <param name="date">The expiration date.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetExpirationDateAsync([NotNull] TToken token, [CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken); ValueTask SetExpirationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the payload associated with a token. /// Sets the payload associated with a token.
@ -362,7 +361,7 @@ namespace OpenIddict.Abstractions
/// <param name="payload">The payload associated with the token.</param> /// <param name="payload">The payload associated with the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetPayloadAsync([NotNull] TToken token, [CanBeNull] string payload, CancellationToken cancellationToken); ValueTask SetPayloadAsync(TToken token, string? payload, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the additional properties associated with a token. /// Sets the additional properties associated with a token.
@ -371,8 +370,8 @@ namespace OpenIddict.Abstractions
/// <param name="properties">The additional properties associated with the token.</param> /// <param name="properties">The additional properties associated with the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetPropertiesAsync([NotNull] TToken token, ValueTask SetPropertiesAsync(TToken token,
[CanBeNull] ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken); ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the reference identifier associated with a token. /// Sets the reference identifier associated with a token.
@ -383,7 +382,7 @@ namespace OpenIddict.Abstractions
/// <param name="identifier">The reference identifier associated with the token.</param> /// <param name="identifier">The reference identifier associated with the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetReferenceIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken); ValueTask SetReferenceIdAsync(TToken token, string? identifier, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the status associated with a token. /// Sets the status associated with a token.
@ -392,7 +391,7 @@ namespace OpenIddict.Abstractions
/// <param name="status">The status associated with the authorization.</param> /// <param name="status">The status associated with the authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetStatusAsync([NotNull] TToken token, [CanBeNull] string status, CancellationToken cancellationToken); ValueTask SetStatusAsync(TToken token, string? status, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the subject associated with a token. /// Sets the subject associated with a token.
@ -401,7 +400,7 @@ namespace OpenIddict.Abstractions
/// <param name="subject">The subject associated with the token.</param> /// <param name="subject">The subject associated with the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetSubjectAsync([NotNull] TToken token, [CanBeNull] string subject, CancellationToken cancellationToken); ValueTask SetSubjectAsync(TToken token, string? subject, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Sets the token type associated with a token. /// Sets the token type associated with a token.
@ -410,7 +409,7 @@ namespace OpenIddict.Abstractions
/// <param name="type">The token type associated with the token.</param> /// <param name="type">The token type associated with the token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask SetTypeAsync([NotNull] TToken token, [CanBeNull] string type, CancellationToken cancellationToken); ValueTask SetTypeAsync(TToken token, string? type, CancellationToken cancellationToken);
/// <summary> /// <summary>
/// Updates an existing token. /// Updates an existing token.
@ -418,6 +417,6 @@ namespace OpenIddict.Abstractions
/// <param name="token">The token to update.</param> /// <param name="token">The token to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</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> /// <returns>A <see cref="ValueTask"/> that can be used to monitor the asynchronous operation.</returns>
ValueTask UpdateAsync([NotNull] TToken token, CancellationToken cancellationToken); ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken);
} }
} }

2
src/OpenIddict.Validation/OpenIddictValidationHandlers.Discovery.cs

@ -304,7 +304,7 @@ namespace OpenIddict.Validation
key.X5t = (string) keys[index][JsonWebKeyParameterNames.X5t]; key.X5t = (string) keys[index][JsonWebKeyParameterNames.X5t];
key.X5tS256 = (string) keys[index][JsonWebKeyParameterNames.X5tS256]; key.X5tS256 = (string) keys[index][JsonWebKeyParameterNames.X5tS256];
if (keys[index].TryGetParameter(JsonWebKeyParameterNames.X5c, out var chain)) if (keys[index].TryGetNamedParameter(JsonWebKeyParameterNames.X5c, out var chain))
{ {
foreach (var certificate in chain.GetNamedParameters()) foreach (var certificate in chain.GetNamedParameters())
{ {

147
test/OpenIddict.Abstractions.Tests/Primitives/OpenIddictParameterTests.cs

@ -351,7 +351,7 @@ namespace OpenIddict.Abstractions.Tests.Primitives
} }
[Fact] [Fact]
public void GetParameter_ReturnsNullForOutOfRangeArrayIndex() public void GetUnnamedParameter_ReturnsNullForOutOfRangeArrayIndex()
{ {
// Arrange // Arrange
var parameter = new OpenIddictParameter(new[] var parameter = new OpenIddictParameter(new[]
@ -689,40 +689,169 @@ namespace OpenIddict.Abstractions.Tests.Primitives
[Theory] [Theory]
[InlineData(null)] [InlineData(null)]
[InlineData("")] [InlineData("")]
public void TryGetParameter_ThrowsAnExceptionForNullOrEmptyName(string name) public void TryGetNamedParameter_ThrowsAnExceptionForNullOrEmptyName(string name)
{ {
// Arrange // Arrange
var parameter = new OpenIddictParameter(); var parameter = new OpenIddictParameter();
// Act // Act
var exception = Assert.Throws<ArgumentException>(() => parameter.TryGetParameter(name, out var value)); var exception = Assert.Throws<ArgumentException>(() => parameter.TryGetNamedParameter(name, out _));
// Assert // Assert
Assert.Equal("name", exception.ParamName); Assert.Equal("name", exception.ParamName);
Assert.StartsWith(SR.GetResourceString(SR.ID1189), exception.Message); Assert.StartsWith(SR.GetResourceString(SR.ID1191), exception.Message);
}
[Fact]
public void TryGetNamedParameter_ReturnsFalseForPrimitiveValues()
{
// Arrange
var parameter = new OpenIddictParameter(42);
// Act and assert
Assert.False(parameter.TryGetNamedParameter("parameter", out var value));
Assert.Equal(default, value);
}
[Fact]
public void TryGetNamedParameter_ReturnsFalseForArrays()
{
// Arrange
var parameter = new OpenIddictParameter(new[]
{
"Fabrikam",
"Contoso"
});
// Act and assert
Assert.False(parameter.TryGetNamedParameter("Fabrikam", out var value));
Assert.Equal(default, value);
} }
[Fact] [Fact]
public void TryGetParameter_ReturnsTrueAndExpectedParameter() public void TryGetNamedParameter_ReturnsFalseForNonexistentItem()
{
// Arrange
var parameter = new OpenIddictParameter(new JsonElement());
// Act and assert
Assert.False(parameter.TryGetNamedParameter("parameter", out var value));
Assert.Equal(default, value);
}
[Fact]
public void TryGetNamedParameter_ReturnsFalseForJsonArrays()
{
// Arrange
var parameter = new OpenIddictParameter(
JsonSerializer.Deserialize<JsonElement>(@"[""Fabrikam"",""Contoso""]"));
// Act and assert
Assert.False(parameter.TryGetNamedParameter("Fabrikam", out var value));
Assert.Equal(default, value);
}
[Fact]
public void TryGetNamedParameter_ReturnsExpectedParameterForJsonObject()
{ {
// Arrange // Arrange
var parameter = new OpenIddictParameter( var parameter = new OpenIddictParameter(
JsonSerializer.Deserialize<JsonElement>(@"{""parameter"":""value""}")); JsonSerializer.Deserialize<JsonElement>(@"{""parameter"":""value""}"));
// Act and assert // Act and assert
Assert.True(parameter.TryGetParameter("parameter", out var value)); Assert.True(parameter.TryGetNamedParameter("parameter", out var value));
Assert.Equal("value", (string) value); Assert.Equal("value", (string) value);
} }
[Fact] [Fact]
public void TryGetParameter_ReturnsFalse() public void TryGetUnnamedParameter_ThrowsAnExceptionForNegativeIndex()
{ {
// Arrange // Arrange
var parameter = new OpenIddictParameter(); var parameter = new OpenIddictParameter();
// Act
var exception = Assert.Throws<ArgumentOutOfRangeException>(() => parameter.TryGetUnnamedParameter(-1, out _));
// Assert
Assert.Equal("index", exception.ParamName);
Assert.StartsWith(SR.GetResourceString(SR.ID1192), exception.Message);
}
[Fact]
public void TryGetUnnamedParameter_ReturnsFalseForPrimitiveValues()
{
// Arrange
var parameter = new OpenIddictParameter(42);
// Act and assert
Assert.False(parameter.TryGetUnnamedParameter(0, out var value));
Assert.Equal(default, value);
}
[Fact]
public void GetParameter_ReturnsFalseForOutOfRangeArrayIndex()
{
// Arrange
var parameter = new OpenIddictParameter(new[]
{
"Fabrikam",
"Contoso"
});
// Act and assert
Assert.False(parameter.TryGetUnnamedParameter(2, out var value));
Assert.Equal(default, value);
}
[Fact]
public void TryGetUnnamedParameter_ReturnsExpectedNodeForArray()
{
// Arrange
var parameter = new OpenIddictParameter(new[]
{
"Fabrikam",
"Contoso"
});
// Act and assert
Assert.True(parameter.TryGetUnnamedParameter(0, out var value));
Assert.Equal("Fabrikam", (string) value);
}
[Fact]
public void TryGetUnnamedParameter_ReturnsFalseForOutOfRangeJsonArrayIndex()
{
// Arrange
var parameter = new OpenIddictParameter(
JsonSerializer.Deserialize<JsonElement>(@"[""Fabrikam"",""Contoso""]"));
// Act and assert
Assert.False(parameter.TryGetUnnamedParameter(2, out var value));
Assert.Equal(default, value);
}
[Fact]
public void TryGetUnnamedParameter_ReturnsFalseForJsonObjects()
{
// Arrange
var parameter = new OpenIddictParameter(
JsonSerializer.Deserialize<JsonElement>(@"{""parameter"":""value""}"));
// Act and assert
Assert.False(parameter.TryGetUnnamedParameter(0, out var value));
Assert.Equal(default, value);
}
[Fact]
public void TryGetUnnamedParameter_ReturnsExpectedNodeForJsonArray()
{
// Arrange
var parameter = new OpenIddictParameter(
JsonSerializer.Deserialize<JsonElement>(@"[""Fabrikam"",""Contoso""]"));
// Act and assert // Act and assert
Assert.False(parameter.TryGetParameter("parameter", out var value)); Assert.True(parameter.TryGetUnnamedParameter(0, out var value));
Assert.Null(value.Value); Assert.Equal("Fabrikam", (string) value);
} }
[Fact] [Fact]

Loading…
Cancel
Save