Browse Source

Make the CancellationToken parameters optional in the managers APIs

pull/545/head
Kévin Chalet 8 years ago
parent
commit
721646357d
  1. 13
      samples/Mvc.Server/Startup.cs
  2. 85
      src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
  3. 58
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  4. 35
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  5. 86
      src/OpenIddict.Core/Managers/OpenIddictTokenManager.cs
  6. 4
      src/OpenIddict/OpenIddictProvider.Exchange.cs
  7. 77
      src/OpenIddict/OpenIddictProvider.Helpers.cs
  8. 2
      src/OpenIddict/OpenIddictProvider.Revocation.cs
  9. 15
      src/OpenIddict/OpenIddictProvider.Serialization.cs
  10. 8
      src/OpenIddict/OpenIddictProvider.cs

13
samples/Mvc.Server/Startup.cs

@ -1,5 +1,4 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using AspNet.Security.OpenIdConnect.Primitives;
using Microsoft.AspNetCore.Builder;
@ -130,10 +129,10 @@ namespace Mvc.Server
// Seed the database with the sample applications.
// Note: in a real world application, this step should be part of a setup script.
InitializeAsync(app.ApplicationServices, CancellationToken.None).GetAwaiter().GetResult();
InitializeAsync(app.ApplicationServices).GetAwaiter().GetResult();
}
private async Task InitializeAsync(IServiceProvider services, CancellationToken cancellationToken)
private async Task InitializeAsync(IServiceProvider services)
{
// Create a new service scope to ensure the database context is correctly disposed when this methods returns.
using (var scope = services.GetRequiredService<IServiceScopeFactory>().CreateScope())
@ -143,7 +142,7 @@ namespace Mvc.Server
var manager = scope.ServiceProvider.GetRequiredService<OpenIddictApplicationManager<OpenIddictApplication>>();
if (await manager.FindByClientIdAsync("mvc", cancellationToken) == null)
if (await manager.FindByClientIdAsync("mvc") == null)
{
var descriptor = new OpenIddictApplicationDescriptor
{
@ -162,7 +161,7 @@ namespace Mvc.Server
}
};
await manager.CreateAsync(descriptor, cancellationToken);
await manager.CreateAsync(descriptor);
}
// To test this sample with Postman, use the following settings:
@ -174,7 +173,7 @@ namespace Mvc.Server
// * Scope: openid email profile roles
// * Grant type: authorization code
// * Request access token locally: yes
if (await manager.FindByClientIdAsync("postman", cancellationToken) == null)
if (await manager.FindByClientIdAsync("postman") == null)
{
var descriptor = new OpenIddictApplicationDescriptor
{
@ -189,7 +188,7 @@ namespace Mvc.Server
}
};
await manager.CreateAsync(descriptor, cancellationToken);
await manager.CreateAsync(descriptor);
}
}
}

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

@ -47,7 +47,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of applications in the database.
/// </returns>
public virtual Task<long> CountAsync(CancellationToken cancellationToken)
public virtual Task<long> CountAsync(CancellationToken cancellationToken = default)
{
return Store.CountAsync(cancellationToken);
}
@ -62,7 +62,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of applications that match the specified query.
/// </returns>
public virtual Task<long> CountAsync<TResult>([NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<long> CountAsync<TResult>(
[NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -81,7 +82,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application.
/// </returns>
public virtual Task<TApplication> CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual Task<TApplication> CreateAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
return CreateAsync(application, /* secret: */ null, cancellationToken);
}
@ -100,7 +101,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual async Task<TApplication> CreateAsync(
[NotNull] TApplication application,
[CanBeNull] string secret, CancellationToken cancellationToken)
[CanBeNull] string secret, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -162,7 +163,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application.
/// </returns>
public virtual async Task<TApplication> CreateAsync([NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken)
public virtual async Task<TApplication> CreateAsync(
[NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -195,7 +197,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task DeleteAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual async Task DeleteAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -224,7 +226,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier.
/// </returns>
public virtual Task<TApplication> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
public virtual Task<TApplication> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -243,7 +245,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client application corresponding to the identifier.
/// </returns>
public virtual Task<TApplication> FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
public virtual Task<TApplication> FindByClientIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -262,7 +264,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result
/// returns the client applications corresponding to the specified post_logout_redirect_uri.
/// </returns>
public virtual Task<ImmutableArray<TApplication>> FindByPostLogoutRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TApplication>> FindByPostLogoutRedirectUriAsync(
[NotNull] string address, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(address))
{
@ -281,7 +284,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result
/// returns the client applications corresponding to the specified redirect_uri.
/// </returns>
public virtual Task<ImmutableArray<TApplication>> FindByRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TApplication>> FindByRedirectUriAsync(
[NotNull] string address, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(address))
{
@ -301,7 +305,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual Task<TResult> GetAsync<TResult>([NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
return GetAsync((applications, state) => state(applications), query, cancellationToken);
}
@ -320,7 +325,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual Task<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken)
[CanBeNull] TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -339,7 +344,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client identifier associated with the application.
/// </returns>
public virtual Task<string> GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual Task<string> GetClientIdAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -358,7 +363,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the client type of the application (by default, "public").
/// </returns>
public virtual async Task<string> GetClientTypeAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual async Task<string> GetClientTypeAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -388,7 +394,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the display name associated with the application.
/// </returns>
public virtual Task<string> GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual Task<string> GetDisplayNameAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -407,7 +413,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the application.
/// </returns>
public virtual Task<string> GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual Task<string> GetIdAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -426,7 +432,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the permissions associated with the application.
/// </returns>
public virtual Task<ImmutableArray<string>> GetPermissionsAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<string>> GetPermissionsAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -445,7 +452,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose
/// result returns all the post_logout_redirect_uri associated with the application.
/// </returns>
public virtual Task<ImmutableArray<string>> GetPostLogoutRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<string>> GetPostLogoutRedirectUrisAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -464,7 +472,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the redirect_uri associated with the application.
/// </returns>
public virtual Task<ImmutableArray<string>> GetRedirectUrisAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<string>> GetRedirectUrisAsync(
[NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -481,7 +490,8 @@ namespace OpenIddict.Core
/// <param name="permission">The permission.</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>
public virtual async Task<bool> HasPermissionAsync([NotNull] TApplication application, [NotNull] string permission, CancellationToken cancellationToken)
public virtual async Task<bool> HasPermissionAsync(
[NotNull] TApplication application, [NotNull] string permission, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -497,7 +507,7 @@ namespace OpenIddict.Core
/// <param name="application">The application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the application is a confidential client, <c>false</c> otherwise.</returns>
public async Task<bool> IsConfidentialAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public async Task<bool> IsConfidentialAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -519,7 +529,7 @@ namespace OpenIddict.Core
/// <param name="application">The application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the application is a hybrid client, <c>false</c> otherwise.</returns>
public async Task<bool> IsHybridAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public async Task<bool> IsHybridAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -541,7 +551,7 @@ namespace OpenIddict.Core
/// <param name="application">The application.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the application is a public client, <c>false</c> otherwise.</returns>
public async Task<bool> IsPublicAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public async Task<bool> IsPublicAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -568,7 +578,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TApplication>> ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TApplication>> ListAsync(
[CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken = default)
{
return Store.ListAsync(count, offset, cancellationToken);
}
@ -583,7 +594,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TResult>> ListAsync<TResult>([NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TResult>> ListAsync<TResult>(
[NotNull] Func<IQueryable<TApplication>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
return ListAsync((applications, state) => state(applications), query, cancellationToken);
}
@ -602,7 +614,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual Task<ImmutableArray<TResult>> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TApplication>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken)
[CanBeNull] TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -620,7 +632,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task UpdateAsync([NotNull] TApplication application, CancellationToken cancellationToken)
public virtual async Task UpdateAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -654,7 +666,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task UpdateAsync([NotNull] TApplication application,
[CanBeNull] string secret, CancellationToken cancellationToken)
[CanBeNull] string secret, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -686,7 +698,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task UpdateAsync([NotNull] TApplication application,
[NotNull] Func<OpenIddictApplicationDescriptor, Task> operation, CancellationToken cancellationToken)
[NotNull] Func<OpenIddictApplicationDescriptor, Task> operation, CancellationToken cancellationToken = default)
{
if (operation == null)
{
@ -767,7 +779,7 @@ namespace OpenIddict.Core
/// whose result returns a boolean indicating whether the client secret was valid.
/// </returns>
public virtual async Task<bool> ValidateClientSecretAsync(
[NotNull] TApplication application, string secret, CancellationToken cancellationToken)
[NotNull] TApplication application, string secret, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -810,7 +822,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result
/// returns a boolean indicating whether the post_logout_redirect_uri was valid.
/// </returns>
public virtual async Task<bool> ValidatePostLogoutRedirectUriAsync([NotNull] string address, CancellationToken cancellationToken)
public virtual async Task<bool> ValidatePostLogoutRedirectUriAsync(
[NotNull] string address, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(address))
{
@ -854,7 +867,7 @@ namespace OpenIddict.Core
/// whose result returns a boolean indicating whether the redirect_uri was valid.
/// </returns>
public virtual async Task<bool> ValidateRedirectUriAsync(
[NotNull] TApplication application, [NotNull] string address, CancellationToken cancellationToken)
[NotNull] TApplication application, [NotNull] string address, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -892,7 +905,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual async Task PopulateAsync([NotNull] TApplication application,
[NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken)
[NotNull] OpenIddictApplicationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (application == null)
{
@ -923,7 +936,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual async Task ValidateAsync([NotNull] TApplication application, CancellationToken cancellationToken)
protected virtual async Task ValidateAsync([NotNull] TApplication application, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(await Store.GetClientIdAsync(application, cancellationToken)))
{
@ -995,7 +1008,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual Task<string> ObfuscateClientSecretAsync([NotNull] string secret, CancellationToken cancellationToken)
protected virtual Task<string> ObfuscateClientSecretAsync([NotNull] string secret, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(secret))
{
@ -1017,7 +1030,7 @@ namespace OpenIddict.Core
/// whose result returns a boolean indicating whether the specified value was valid.
/// </returns>
protected virtual Task<bool> ValidateClientSecretAsync(
[NotNull] string secret, [NotNull] string comparand, CancellationToken cancellationToken)
[NotNull] string secret, [NotNull] string comparand, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(secret))
{

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

@ -46,7 +46,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of authorizations in the database.
/// </returns>
public virtual Task<long> CountAsync(CancellationToken cancellationToken)
public virtual Task<long> CountAsync(CancellationToken cancellationToken = default)
{
return Store.CountAsync(cancellationToken);
}
@ -61,7 +61,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of authorizations that match the specified query.
/// </returns>
public virtual Task<long> CountAsync<TResult>([NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<long> CountAsync<TResult>(
[NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -79,7 +80,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result returns the authorization.
/// </returns>
public virtual async Task<TAuthorization> CreateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
public virtual async Task<TAuthorization> CreateAsync(
[NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -115,7 +117,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result returns the authorization.
/// </returns>
public virtual async Task<TAuthorization> CreateAsync([NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken)
public virtual async Task<TAuthorization> CreateAsync(
[NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -140,7 +143,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
public virtual async Task DeleteAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -171,7 +174,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorizations corresponding to the subject/client.
/// </returns>
public virtual Task<ImmutableArray<TAuthorization>> FindAsync([NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TAuthorization>> FindAsync(
[NotNull] string subject, [NotNull] string client, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -195,7 +199,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization corresponding to the identifier.
/// </returns>
public virtual Task<TAuthorization> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
public virtual Task<TAuthorization> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -214,7 +218,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the authorization.
/// </returns>
public virtual Task<string> GetApplicationIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
public virtual Task<string> GetApplicationIdAsync(
[NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -234,7 +239,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual Task<TResult> GetAsync<TResult>([NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
return GetAsync((authorizations, state) => state(authorizations), query, cancellationToken);
}
@ -253,7 +259,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual Task<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken)
[CanBeNull] TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -272,7 +278,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the authorization.
/// </returns>
public virtual Task<string> GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
public virtual Task<string> GetIdAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -291,7 +297,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified authorization.
/// </returns>
public virtual Task<string> GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
public virtual Task<string> GetStatusAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -307,7 +313,7 @@ namespace OpenIddict.Core
/// <param name="authorization">The authorization.</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 been revoked, <c>false</c> otherwise.</returns>
public virtual async Task<bool> IsRevokedAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
public virtual async Task<bool> IsRevokedAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -329,7 +335,7 @@ namespace OpenIddict.Core
/// <param name="authorization">The authorization.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the authorization is valid, <c>false</c> otherwise.</returns>
public virtual async Task<bool> IsValidAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
public virtual async Task<bool> IsValidAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -355,7 +361,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TAuthorization>> ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TAuthorization>> ListAsync(
[CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken = default)
{
return Store.ListAsync(count, offset, cancellationToken);
}
@ -370,7 +377,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TResult>> ListAsync<TResult>([NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TResult>> ListAsync<TResult>(
[NotNull] Func<IQueryable<TAuthorization>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
return ListAsync((authorizations, state) => state(authorizations), query, cancellationToken);
}
@ -389,7 +397,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual Task<ImmutableArray<TResult>> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TAuthorization>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken)
[CanBeNull] TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -410,7 +418,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TAuthorization>> ListInvalidAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TAuthorization>> ListInvalidAsync(
[CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken = default)
{
return Store.ListInvalidAsync(count, offset, cancellationToken);
}
@ -421,7 +430,7 @@ namespace OpenIddict.Core
/// <param name="authorization">The authorization to revoke.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
public virtual async Task RevokeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
public virtual async Task RevokeAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -446,7 +455,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task SetApplicationIdAsync([NotNull] TAuthorization authorization, [CanBeNull] string identifier, CancellationToken cancellationToken)
public virtual async Task SetApplicationIdAsync(
[NotNull] TAuthorization authorization, [CanBeNull] string identifier, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -465,7 +475,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task UpdateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
public virtual async Task UpdateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -497,7 +507,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task UpdateAsync([NotNull] TAuthorization authorization,
[NotNull] Func<OpenIddictAuthorizationDescriptor, Task> operation, CancellationToken cancellationToken)
[NotNull] Func<OpenIddictAuthorizationDescriptor, Task> operation, CancellationToken cancellationToken = default)
{
if (operation == null)
{
@ -532,7 +542,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual async Task PopulateAsync([NotNull] TAuthorization authorization,
[NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken)
[NotNull] OpenIddictAuthorizationDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (authorization == null)
{
@ -559,7 +569,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual async Task ValidateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken)
protected virtual async Task ValidateAsync([NotNull] TAuthorization authorization, CancellationToken cancellationToken = default)
{
if (authorization == null)
{

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

@ -46,7 +46,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of scopes in the database.
/// </returns>
public virtual Task<long> CountAsync(CancellationToken cancellationToken)
public virtual Task<long> CountAsync(CancellationToken cancellationToken = default)
{
return Store.CountAsync(cancellationToken);
}
@ -61,7 +61,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of scopes that match the specified query.
/// </returns>
public virtual Task<long> CountAsync<TResult>([NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<long> CountAsync<TResult>(
[NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -79,7 +80,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result returns the scope.
/// </returns>
public virtual async Task<TScope> CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken)
public virtual async Task<TScope> CreateAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -107,7 +108,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result returns the scope.
/// </returns>
public virtual async Task<TScope> CreateAsync([NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken)
public virtual async Task<TScope> CreateAsync(
[NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -132,7 +134,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task DeleteAsync([NotNull] TScope scope, CancellationToken cancellationToken)
public virtual async Task DeleteAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -161,7 +163,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the scope corresponding to the identifier.
/// </returns>
public virtual Task<TScope> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
public virtual Task<TScope> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -181,7 +183,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual Task<TResult> GetAsync<TResult>([NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
return GetAsync((scopes, state) => state(scopes), query, cancellationToken);
}
@ -200,7 +203,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual Task<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken)
[CanBeNull] TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -219,7 +222,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the scope.
/// </returns>
public virtual Task<string> GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken)
public virtual Task<string> GetIdAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -239,7 +242,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TScope>> ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TScope>> ListAsync(
[CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken = default)
{
return Store.ListAsync(count, offset, cancellationToken);
}
@ -254,7 +258,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TResult>> ListAsync<TResult>([NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TResult>> ListAsync<TResult>(
[NotNull] Func<IQueryable<TScope>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
return ListAsync((scopes, state) => state(scopes), query, cancellationToken);
}
@ -273,7 +278,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual Task<ImmutableArray<TResult>> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TScope>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken)
[CanBeNull] TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -291,7 +296,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task UpdateAsync([NotNull] TScope scope, CancellationToken cancellationToken)
public virtual async Task UpdateAsync([NotNull] TScope scope, CancellationToken cancellationToken = default)
{
if (scope == null)
{
@ -321,7 +326,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task UpdateAsync([NotNull] TScope scope,
[NotNull] Func<OpenIddictScopeDescriptor, Task> operation, CancellationToken cancellationToken)
[NotNull] Func<OpenIddictScopeDescriptor, Task> operation, CancellationToken cancellationToken = default)
{
if (operation == null)
{
@ -349,7 +354,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual async Task PopulateAsync([NotNull] TScope scope,
[NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken)
[NotNull] OpenIddictScopeDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (scope == null)
{

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

@ -48,7 +48,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of tokens in the database.
/// </returns>
public virtual Task<long> CountAsync(CancellationToken cancellationToken)
public virtual Task<long> CountAsync(CancellationToken cancellationToken = default)
{
return Store.CountAsync(cancellationToken);
}
@ -63,7 +63,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the number of tokens that match the specified query.
/// </returns>
public virtual Task<long> CountAsync<TResult>([NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<long> CountAsync<TResult>(
[NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -81,7 +82,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result returns the token.
/// </returns>
public virtual async Task<TToken> CreateAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual async Task<TToken> CreateAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -111,7 +112,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose result returns the token.
/// </returns>
public virtual async Task<TToken> CreateAsync([NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken)
public virtual async Task<TToken> CreateAsync(
[NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (descriptor == null)
{
@ -136,7 +138,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task DeleteAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual async Task DeleteAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -165,7 +167,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task ExtendAsync([NotNull] TToken token, [CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken)
public virtual async Task ExtendAsync([NotNull] TToken token,
[CanBeNull] DateTimeOffset? date, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -185,7 +188,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified application.
/// </returns>
public virtual Task<ImmutableArray<TToken>> FindByApplicationIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TToken>> FindByApplicationIdAsync(
[NotNull] string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -204,7 +208,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified authorization.
/// </returns>
public virtual Task<ImmutableArray<TToken>> FindByAuthorizationIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TToken>> FindByAuthorizationIdAsync(
[NotNull] string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -224,7 +229,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified reference identifier.
/// </returns>
public virtual async Task<TToken> FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
public virtual async Task<TToken> FindByReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -244,7 +249,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the token corresponding to the unique identifier.
/// </returns>
public virtual Task<TToken> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
public virtual Task<TToken> FindByIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -263,7 +268,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the tokens corresponding to the specified subject.
/// </returns>
public virtual Task<ImmutableArray<TToken>> FindBySubjectAsync([NotNull] string subject, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TToken>> FindBySubjectAsync(
[NotNull] string subject, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(subject))
{
@ -282,7 +288,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the application identifier associated with the token.
/// </returns>
public virtual Task<string> GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual Task<string> GetApplicationIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -302,7 +308,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the first element returned when executing the query.
/// </returns>
public virtual Task<TResult> GetAsync<TResult>([NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<TResult> GetAsync<TResult>(
[NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
return GetAsync((tokens, state) => state(tokens), query, cancellationToken);
}
@ -321,7 +328,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual Task<TResult> GetAsync<TState, TResult>(
[NotNull] Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken)
[CanBeNull] TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -340,7 +347,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the authorization identifier associated with the token.
/// </returns>
public virtual Task<string> GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual Task<string> GetAuthorizationIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -359,7 +366,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the creation date associated with the specified token.
/// </returns>
public virtual Task<DateTimeOffset?> GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual Task<DateTimeOffset?> GetCreationDateAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -378,7 +385,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the expiration date associated with the specified token.
/// </returns>
public virtual Task<DateTimeOffset?> GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual Task<DateTimeOffset?> GetExpirationDateAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -397,7 +404,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the unique identifier associated with the token.
/// </returns>
public virtual Task<string> GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual Task<string> GetIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -416,7 +423,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the payload associated with the specified token.
/// </returns>
public virtual Task<string> GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual Task<string> GetPayloadAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -437,7 +444,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the reference identifier associated with the specified token.
/// </returns>
public virtual Task<string> GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual Task<string> GetReferenceIdAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -456,7 +463,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns the status associated with the specified token.
/// </returns>
public virtual Task<string> GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual Task<string> GetStatusAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -472,7 +479,7 @@ namespace OpenIddict.Core
/// <param name="token">The token.</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 already been redemeed, <c>false</c> otherwise.</returns>
public virtual async Task<bool> IsRedeemedAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual async Task<bool> IsRedeemedAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -494,7 +501,7 @@ namespace OpenIddict.Core
/// <param name="token">The token.</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 been revoked, <c>false</c> otherwise.</returns>
public virtual async Task<bool> IsRevokedAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual async Task<bool> IsRevokedAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -516,7 +523,7 @@ namespace OpenIddict.Core
/// <param name="token">The token.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns><c>true</c> if the token is valid, <c>false</c> otherwise.</returns>
public virtual async Task<bool> IsValidAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual async Task<bool> IsValidAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -542,7 +549,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TToken>> ListAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TToken>> ListAsync(
[CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken = default)
{
return Store.ListAsync(count, offset, cancellationToken);
}
@ -557,7 +565,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TResult>> ListAsync<TResult>([NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TResult>> ListAsync<TResult>(
[NotNull] Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken = default)
{
return ListAsync((tokens, state) => state(tokens), query, cancellationToken);
}
@ -576,7 +585,7 @@ namespace OpenIddict.Core
/// </returns>
public virtual Task<ImmutableArray<TResult>> ListAsync<TState, TResult>(
[NotNull] Func<IQueryable<TToken>, TState, IQueryable<TResult>> query,
[CanBeNull] TState state, CancellationToken cancellationToken)
[CanBeNull] TState state, CancellationToken cancellationToken = default)
{
if (query == null)
{
@ -597,7 +606,8 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation,
/// whose result returns all the elements returned when executing the specified query.
/// </returns>
public virtual Task<ImmutableArray<TToken>> ListInvalidAsync([CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken)
public virtual Task<ImmutableArray<TToken>> ListInvalidAsync(
[CanBeNull] int? count, [CanBeNull] int? offset, CancellationToken cancellationToken = default)
{
return Store.ListInvalidAsync(count, offset, cancellationToken);
}
@ -611,7 +621,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual Task<string> ObfuscateReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken)
public virtual Task<string> ObfuscateReferenceIdAsync([NotNull] string identifier, CancellationToken cancellationToken = default)
{
if (string.IsNullOrEmpty(identifier))
{
@ -632,7 +642,7 @@ namespace OpenIddict.Core
/// <param name="token">The token to redeem.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
public virtual async Task RedeemAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual async Task RedeemAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -653,7 +663,7 @@ namespace OpenIddict.Core
/// <param name="token">The token to revoke.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param>
/// <returns>A <see cref="Task"/> that can be used to monitor the asynchronous operation.</returns>
public virtual async Task RevokeAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual async Task RevokeAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -677,7 +687,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task SetApplicationIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken)
public virtual async Task SetApplicationIdAsync([NotNull] TToken token,
[CanBeNull] string identifier, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -697,7 +708,8 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task SetAuthorizationIdAsync([NotNull] TToken token, [CanBeNull] string identifier, CancellationToken cancellationToken)
public virtual async Task SetAuthorizationIdAsync([NotNull] TToken token,
[CanBeNull] string identifier, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -716,7 +728,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task UpdateAsync([NotNull] TToken token, CancellationToken cancellationToken)
public virtual async Task UpdateAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -746,7 +758,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
public virtual async Task UpdateAsync([NotNull] TToken token,
[NotNull] Func<OpenIddictTokenDescriptor, Task> operation, CancellationToken cancellationToken)
[NotNull] Func<OpenIddictTokenDescriptor, Task> operation, CancellationToken cancellationToken = default)
{
if (operation == null)
{
@ -781,7 +793,7 @@ namespace OpenIddict.Core
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual async Task PopulateAsync([NotNull] TToken token,
[NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken)
[NotNull] OpenIddictTokenDescriptor descriptor, CancellationToken cancellationToken = default)
{
if (token == null)
{
@ -812,7 +824,7 @@ namespace OpenIddict.Core
/// <returns>
/// A <see cref="Task"/> that can be used to monitor the asynchronous operation.
/// </returns>
protected virtual async Task ValidateAsync([NotNull] TToken token, CancellationToken cancellationToken)
protected virtual async Task ValidateAsync([NotNull] TToken token, CancellationToken cancellationToken = default)
{
if (token == null)
{

4
src/OpenIddict/OpenIddictProvider.Exchange.cs

@ -269,8 +269,8 @@ namespace OpenIddict
// If the operation fails, the helpers will automatically log
// and swallow the exception to ensure that a valid error
// response will be returned to the client application.
await TryRevokeAuthorizationAsync(context.Ticket, context.HttpContext);
await TryRevokeTokensAsync(context.Ticket, context.HttpContext);
await TryRevokeAuthorizationAsync(context.Ticket);
await TryRevokeTokensAsync(context.Ticket);
Logger.LogError("The token request was rejected because the authorization code " +
"or refresh token '{Identifier}' has already been redeemed.", identifier);

77
src/OpenIddict/OpenIddictProvider.Helpers.cs

@ -25,9 +25,8 @@ namespace OpenIddict
public partial class OpenIddictProvider<TApplication, TAuthorization, TScope, TToken> : OpenIdConnectServerProvider
where TApplication : class where TAuthorization : class where TScope : class where TToken : class
{
private async Task CreateAuthorizationAsync(
[NotNull] AuthenticationTicket ticket, [NotNull] OpenIddictOptions options,
[NotNull] HttpContext context, [NotNull] OpenIdConnectRequest request)
private async Task CreateAuthorizationAsync([NotNull] AuthenticationTicket ticket,
[NotNull] OpenIddictOptions options, [NotNull] OpenIdConnectRequest request)
{
var descriptor = new OpenIddictAuthorizationDescriptor
{
@ -53,13 +52,13 @@ namespace OpenIddict
var application = request.GetProperty<TApplication>($"{OpenIddictConstants.Properties.Application}:{request.ClientId}");
Debug.Assert(application != null, "The client application shouldn't be null.");
descriptor.ApplicationId = await Applications.GetIdAsync(application, context.RequestAborted);
descriptor.ApplicationId = await Applications.GetIdAsync(application);
}
var authorization = await Authorizations.CreateAsync(descriptor, context.RequestAborted);
var authorization = await Authorizations.CreateAsync(descriptor);
if (authorization != null)
{
var identifier = await Authorizations.GetIdAsync(authorization, context.RequestAborted);
var identifier = await Authorizations.GetIdAsync(authorization);
if (string.IsNullOrEmpty(request.ClientId))
{
@ -82,7 +81,7 @@ namespace OpenIddict
private async Task<string> CreateTokenAsync(
[NotNull] string type, [NotNull] AuthenticationTicket ticket,
[NotNull] OpenIddictOptions options, [NotNull] HttpContext context,
[NotNull] OpenIddictOptions options,
[NotNull] OpenIdConnectRequest request,
[NotNull] ISecureDataFormat<AuthenticationTicket> format)
{
@ -156,7 +155,7 @@ namespace OpenIddict
result = Base64UrlEncoder.Encode(bytes);
// Obfuscate the reference identifier so it can be safely stored in the databse.
descriptor.ReferenceId = await Tokens.ObfuscateReferenceIdAsync(result, context.RequestAborted);
descriptor.ReferenceId = await Tokens.ObfuscateReferenceIdAsync(result);
}
// Otherwise, only create a token metadata entry for authorization codes and refresh tokens.
@ -172,18 +171,21 @@ namespace OpenIddict
var application = request.GetProperty<TApplication>($"{OpenIddictConstants.Properties.Application}:{request.ClientId}");
Debug.Assert(application != null, "The client application shouldn't be null.");
descriptor.ApplicationId = await Applications.GetIdAsync(application, context.RequestAborted);
descriptor.ApplicationId = await Applications.GetIdAsync(application);
}
// If a null value was returned by CreateAsync(), return immediately.
var token = await Tokens.CreateAsync(descriptor, context.RequestAborted);
// Note: the request cancellation token is deliberately not used here to ensure the caller
// cannot prevent this operation from being executed by resetting the TCP connection.
var token = await Tokens.CreateAsync(descriptor);
if (token == null)
{
return null;
}
// Throw an exception if the token identifier can't be resolved.
var identifier = await Tokens.GetIdAsync(token, context.RequestAborted);
var identifier = await Tokens.GetIdAsync(token);
if (string.IsNullOrEmpty(identifier))
{
throw new InvalidOperationException("The unique key associated with a refresh token cannot be null or empty.");
@ -212,7 +214,7 @@ namespace OpenIddict
private async Task<AuthenticationTicket> ReceiveTokenAsync(
[NotNull] string type, [NotNull] string value,
[NotNull] OpenIddictOptions options, [NotNull] HttpContext context,
[NotNull] OpenIddictOptions options,
[NotNull] OpenIdConnectRequest request,
[NotNull] ISecureDataFormat<AuthenticationTicket> format)
{
@ -244,7 +246,7 @@ namespace OpenIddict
{
// Retrieve the token entry from the database. If it
// cannot be found, assume the token is not valid.
token = await Tokens.FindByReferenceIdAsync(value, context.RequestAborted);
token = await Tokens.FindByReferenceIdAsync(value);
// Store the token as a request property so it can be retrieved if this method is called another time.
request.AddProperty($"{OpenIddictConstants.Properties.ReferenceToken}:{value}", token);
@ -258,7 +260,7 @@ namespace OpenIddict
return null;
}
identifier = await Tokens.GetIdAsync(token, context.RequestAborted);
identifier = await Tokens.GetIdAsync(token);
if (string.IsNullOrEmpty(identifier))
{
Logger.LogWarning("The identifier associated with the received token cannot be retrieved. " +
@ -269,7 +271,7 @@ namespace OpenIddict
// Extract the encrypted payload from the token. If it's null or empty,
// assume the token is not a reference token and consider it as invalid.
var payload = await Tokens.GetPayloadAsync(token, context.RequestAborted);
var payload = await Tokens.GetPayloadAsync(token);
if (string.IsNullOrEmpty(payload))
{
Logger.LogWarning("The ciphertext associated with the token '{Identifier}' cannot be retrieved. " +
@ -283,7 +285,7 @@ namespace OpenIddict
{
Logger.LogWarning("The ciphertext associated with the token '{Identifier}' cannot be decrypted. " +
"This may indicate that the token entry is corrupted or tampered.",
await Tokens.GetIdAsync(token, context.RequestAborted));
await Tokens.GetIdAsync(token));
return null;
}
@ -325,7 +327,7 @@ namespace OpenIddict
// If it cannot be found, assume the authorization code/refresh token is not valid.
else
{
token = await Tokens.FindByIdAsync(identifier, context.RequestAborted);
token = await Tokens.FindByIdAsync(identifier);
// Store the token as a request property so it can be retrieved if this method is called another time.
request.AddProperty($"{OpenIddictConstants.Properties.Token}:{identifier}", token);
@ -349,12 +351,12 @@ namespace OpenIddict
ticket.SetTokenId(identifier);
// Dynamically set the creation and expiration dates.
ticket.Properties.IssuedUtc = await Tokens.GetCreationDateAsync(token, context.RequestAborted);
ticket.Properties.ExpiresUtc = await Tokens.GetExpirationDateAsync(token, context.RequestAborted);
ticket.Properties.IssuedUtc = await Tokens.GetCreationDateAsync(token);
ticket.Properties.ExpiresUtc = await Tokens.GetExpirationDateAsync(token);
// Restore the authorization identifier using the identifier attached with the database entry.
ticket.SetProperty(OpenIddictConstants.Properties.AuthorizationId,
await Tokens.GetAuthorizationIdAsync(token, context.RequestAborted));
await Tokens.GetAuthorizationIdAsync(token));
Logger.LogTrace("The token '{Identifier}' was successfully decrypted and " +
"retrieved from the database: {Claims} ; {Properties}.",
@ -363,7 +365,7 @@ namespace OpenIddict
return ticket;
}
private async Task<bool> TryRevokeAuthorizationAsync([NotNull] AuthenticationTicket ticket, [NotNull] HttpContext context)
private async Task<bool> TryRevokeAuthorizationAsync([NotNull] AuthenticationTicket ticket)
{
// Note: if the authorization identifier or the authorization itself
// cannot be found, return true as the authorization doesn't need
@ -374,7 +376,7 @@ namespace OpenIddict
return true;
}
var authorization = await Authorizations.FindByIdAsync(identifier, context.RequestAborted);
var authorization = await Authorizations.FindByIdAsync(identifier);
if (authorization == null)
{
return true;
@ -382,7 +384,9 @@ namespace OpenIddict
try
{
await Authorizations.RevokeAsync(authorization, context.RequestAborted);
// Note: the request cancellation token is deliberately not used here to ensure the caller
// cannot prevent this operation from being executed by resetting the TCP connection.
await Authorizations.RevokeAsync(authorization);
Logger.LogInformation("The authorization '{Identifier}' was automatically revoked.", identifier);
@ -398,7 +402,7 @@ namespace OpenIddict
}
}
private async Task<bool> TryRevokeTokensAsync([NotNull] AuthenticationTicket ticket, [NotNull] HttpContext context)
private async Task<bool> TryRevokeTokensAsync([NotNull] AuthenticationTicket ticket)
{
// Note: if the authorization identifier is null, return true as no tokens need to be revoked.
var identifier = ticket.GetProperty(OpenIddictConstants.Properties.AuthorizationId);
@ -407,21 +411,23 @@ namespace OpenIddict
return true;
}
foreach (var token in await Tokens.FindByAuthorizationIdAsync(identifier, context.RequestAborted))
foreach (var token in await Tokens.FindByAuthorizationIdAsync(identifier))
{
try
{
await Tokens.RevokeAsync(token, context.RequestAborted);
// Note: the request cancellation token is deliberately not used here to ensure the caller
// cannot prevent this operation from being executed by resetting the TCP connection.
await Tokens.RevokeAsync(token);
Logger.LogInformation("The token '{Identifier}' was automatically revoked.",
await Tokens.GetIdAsync(token, context.RequestAborted));
await Tokens.GetIdAsync(token));
}
catch (Exception exception)
{
Logger.LogWarning(exception, "An exception occurred while trying to revoke the tokens " +
"associated with the token '{Identifier}'.",
await Tokens.GetIdAsync(token, context.RequestAborted));
await Tokens.GetIdAsync(token));
return false;
}
@ -430,14 +436,16 @@ namespace OpenIddict
return true;
}
private async Task<bool> TryRedeemTokenAsync([NotNull] TToken token, [NotNull] HttpContext context)
private async Task<bool> TryRedeemTokenAsync([NotNull] TToken token)
{
var identifier = await Tokens.GetIdAsync(token, context.RequestAborted);
var identifier = await Tokens.GetIdAsync(token);
Debug.Assert(!string.IsNullOrEmpty(identifier), "The token identifier shouldn't be null or empty.");
try
{
await Tokens.RedeemAsync(token, context.RequestAborted);
// Note: the request cancellation token is deliberately not used here to ensure the caller
// cannot prevent this operation from being executed by resetting the TCP connection.
await Tokens.RedeemAsync(token);
Logger.LogInformation("The token '{Identifier}' was automatically marked as redeemed.", identifier);
@ -454,8 +462,7 @@ namespace OpenIddict
}
private async Task<bool> TryExtendTokenAsync(
[NotNull] TToken token, [NotNull] AuthenticationTicket ticket,
[NotNull] HttpContext context, [NotNull] OpenIddictOptions options)
[NotNull] TToken token, [NotNull] AuthenticationTicket ticket, [NotNull] OpenIddictOptions options)
{
var identifier = ticket.GetTokenId();
Debug.Assert(!string.IsNullOrEmpty(identifier), "The token identifier shouldn't be null or empty.");
@ -466,7 +473,9 @@ namespace OpenIddict
var date = options.SystemClock.UtcNow;
date += ticket.GetRefreshTokenLifetime() ?? options.RefreshTokenLifetime;
await Tokens.ExtendAsync(token, date, context.RequestAborted);
// Note: the request cancellation token is deliberately not used here to ensure the caller
// cannot prevent this operation from being executed by resetting the TCP connection.
await Tokens.ExtendAsync(token, date);
Logger.LogInformation("The expiration date of the refresh token '{Identifier}' " +
"was automatically updated: {Date}.", identifier, date);

2
src/OpenIddict/OpenIddictProvider.Revocation.cs

@ -216,7 +216,7 @@ namespace OpenIddict
// will be returned to the client application.
try
{
await Tokens.RevokeAsync(token, context.HttpContext.RequestAborted);
await Tokens.RevokeAsync(token);
}
catch (Exception exception)

15
src/OpenIddict/OpenIddictProvider.Serialization.cs

@ -25,7 +25,7 @@ namespace OpenIddict
context.Ticket = await ReceiveTokenAsync(
OpenIdConnectConstants.TokenUsages.AccessToken,
context.AccessToken, options, context.HttpContext,
context.AccessToken, options,
context.Request, context.DataFormat);
// Prevent the OpenID Connect server middleware from using
@ -46,7 +46,7 @@ namespace OpenIddict
context.Ticket = await ReceiveTokenAsync(
OpenIdConnectConstants.TokenUsages.AuthorizationCode,
context.AuthorizationCode, options, context.HttpContext,
context.AuthorizationCode, options,
context.Request, context.DataFormat);
// Prevent the OpenID Connect server middleware from using its default logic.
@ -63,7 +63,7 @@ namespace OpenIddict
context.Ticket = await ReceiveTokenAsync(
OpenIdConnectConstants.TokenUsages.RefreshToken,
context.RefreshToken, options, context.HttpContext,
context.RefreshToken, options,
context.Request, context.DataFormat);
// Prevent the OpenID Connect server middleware from using its default logic.
@ -80,8 +80,7 @@ namespace OpenIddict
var token = await CreateTokenAsync(
OpenIdConnectConstants.TokenUsages.AccessToken,
context.Ticket, options, context.HttpContext,
context.Request, context.DataFormat);
context.Ticket, options, context.Request, context.DataFormat);
// If a reference token was returned by CreateTokenAsync(),
// force the OpenID Connect server middleware to use it.
@ -107,8 +106,7 @@ namespace OpenIddict
var token = await CreateTokenAsync(
OpenIdConnectConstants.TokenUsages.AuthorizationCode,
context.Ticket, options, context.HttpContext,
context.Request, context.DataFormat);
context.Ticket, options, context.Request, context.DataFormat);
// If a reference token was returned by CreateTokenAsync(),
// force the OpenID Connect server middleware to use it.
@ -134,8 +132,7 @@ namespace OpenIddict
var token = await CreateTokenAsync(
OpenIdConnectConstants.TokenUsages.RefreshToken,
context.Ticket, options, context.HttpContext,
context.Request, context.DataFormat);
context.Ticket, options, context.Request, context.DataFormat);
// If a reference token was returned by CreateTokenAsync(),
// force the OpenID Connect server middleware to use it.

8
src/OpenIddict/OpenIddictProvider.cs

@ -155,7 +155,7 @@ namespace OpenIddict
// See https://tools.ietf.org/html/rfc6749#section-6 for more information.
if (options.UseRollingTokens || context.Request.IsAuthorizationCodeGrantType())
{
if (!await TryRedeemTokenAsync(token, context.HttpContext))
if (!await TryRedeemTokenAsync(token))
{
context.Reject(
error: OpenIdConnectConstants.Errors.InvalidGrant,
@ -171,7 +171,7 @@ namespace OpenIddict
// with the authorization if the request is a grant_type=refresh_token request.
if (options.UseRollingTokens && context.Request.IsRefreshTokenGrantType())
{
if (!await TryRevokeTokensAsync(context.Ticket, context.HttpContext))
if (!await TryRevokeTokensAsync(context.Ticket))
{
context.Reject(
error: OpenIdConnectConstants.Errors.InvalidGrant,
@ -186,7 +186,7 @@ namespace OpenIddict
// with a new expiration date if sliding expiration was not disabled.
else if (options.UseSlidingExpiration && context.Request.IsRefreshTokenGrantType())
{
if (!await TryExtendTokenAsync(token, context.Ticket, context.HttpContext, options))
if (!await TryExtendTokenAsync(token, context.Ticket, options))
{
context.Reject(
error: OpenIdConnectConstants.Errors.InvalidGrant,
@ -206,7 +206,7 @@ namespace OpenIddict
if (!context.Ticket.HasProperty(OpenIddictConstants.Properties.AuthorizationId) &&
(context.IncludeAuthorizationCode || context.IncludeRefreshToken))
{
await CreateAuthorizationAsync(context.Ticket, options, context.HttpContext, context.Request);
await CreateAuthorizationAsync(context.Ticket, options, context.Request);
}
// Add the custom properties that are marked as public as authorization or

Loading…
Cancel
Save