diff --git a/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/DPoPProofValidator.cs b/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/DPoPProofValidator.cs
index 65e6485e2..d00a03f73 100644
--- a/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/DPoPProofValidator.cs
+++ b/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/DPoPProofValidator.cs
@@ -70,7 +70,7 @@ internal class DPoPProofValidator : IDPoPProofValidator
///
/// Validates the DPoP proof.
///
- public async Task Validate(DPoPProofValidationContext context, CT ct = default)
+ public async Task Validate(DPoPProofValidationContext context, Ct ct = default)
{
using var activity = Tracing.ActivitySource.StartActivity("DPoPProofValidator.Validate");
@@ -368,7 +368,7 @@ internal class DPoPProofValidator : IDPoPProofValidator
internal async Task ValidateReplay(
DPoPProofValidationContext context,
DPoPProofValidationResult result,
- CT ct = default)
+ Ct ct = default)
{
var dPoPOptions = OptionsMonitor.Get(context.Scheme);
diff --git a/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/IDPoPProofValidator.cs b/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/IDPoPProofValidator.cs
index a49515050..9520221f5 100644
--- a/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/IDPoPProofValidator.cs
+++ b/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/IDPoPProofValidator.cs
@@ -11,5 +11,5 @@ public interface IDPoPProofValidator
///
/// Validates the DPoP proof.
///
- Task Validate(DPoPProofValidationContext context, CT ct = default);
+ Task Validate(DPoPProofValidationContext context, Ct ct = default);
}
diff --git a/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/IReplayCache.cs b/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/IReplayCache.cs
index f8c076fd5..b774ca060 100644
--- a/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/IReplayCache.cs
+++ b/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/IReplayCache.cs
@@ -11,11 +11,11 @@ public interface IReplayCache
///
/// Adds a hashed jti to the cache.
///
- Task Add(string jtiHash, TimeSpan expiration, CT ct = default);
+ Task Add(string jtiHash, TimeSpan expiration, Ct ct = default);
///
/// Checks if a cached jti hash exists in the hash.
///
- Task Exists(string jtiHash, CT ct = default);
+ Task Exists(string jtiHash, Ct ct = default);
}
diff --git a/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/ReplayCache.cs b/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/ReplayCache.cs
index ca2518462..6d1ee8bcd 100644
--- a/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/ReplayCache.cs
+++ b/aspnetcore-authentication-jwtbearer/src/AspNetCore.Authentication.JwtBearer/DPoP/ReplayCache.cs
@@ -24,7 +24,7 @@ internal class ReplayCache(DPoPHybridCacheProvider cacheProvider) : IReplayCache
}
}
- public async Task Add(string handle, TimeSpan expiration, CT ct)
+ public async Task Add(string handle, TimeSpan expiration, Ct ct)
{
using var activity = Tracing.ActivitySource.StartActivity("ReplayCache.Add");
@@ -43,14 +43,14 @@ internal class ReplayCache(DPoPHybridCacheProvider cacheProvider) : IReplayCache
| HybridCacheEntryFlags.DisableUnderlyingData
};
- public async Task Exists(string handle, CT ct)
+ public async Task Exists(string handle, Ct ct)
{
using var activity = Tracing.ActivitySource.StartActivity("ReplayCache.Exists");
+ // The factory will never be invoked because the ReadOnlyEntryOptions set the DisableUnderlyingData flag
return await Cache.GetOrCreateAsync(
Prefix + handle,
- // The factory will never be invoked because the ReadOnlyEntryOptions set the DisableUnderlyingData flag
- cancel => throw new InvalidOperationException("Can't Happen"),
+ _ => throw new InvalidOperationException("Can't Happen"),
ReadOnlyEntryOptions,
cancellationToken: ct);
}
diff --git a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestBrowserClient.cs b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestBrowserClient.cs
index 8c2c3019c..b4a5b65c2 100644
--- a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestBrowserClient.cs
+++ b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestBrowserClient.cs
@@ -15,7 +15,7 @@ public class TestBrowserClient : HttpClient
public HttpResponseMessage LastResponse { get; private set; } = default!;
protected override async Task SendAsync(HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
CurrentUri = request.RequestUri!;
var cookieHeader = CookieContainer.GetCookieHeader(request.RequestUri!);
diff --git a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestHybridCache.cs b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestHybridCache.cs
index 4da5065c3..279a85dac 100644
--- a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestHybridCache.cs
+++ b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestHybridCache.cs
@@ -11,8 +11,8 @@ internal class TestHybridCache : HybridCache
private readonly List<(string key, object value, HybridCacheEntryOptions? options)> _setAsyncCalls = new();
private readonly List<(string key, HybridCacheEntryOptions? options)> _getOrCreateAsyncCalls = new();
- public override async ValueTask GetOrCreateAsync(string key, TState state, Func> factory, HybridCacheEntryOptions? options = null,
- IEnumerable? tags = null, CT ct = new())
+ public override async ValueTask GetOrCreateAsync(string key, TState state, Func> factory, HybridCacheEntryOptions? options = null,
+ IEnumerable? tags = null, Ct ct = new())
{
_getOrCreateAsyncCalls.Add((key, options));
@@ -25,16 +25,16 @@ internal class TestHybridCache : HybridCache
}
public override ValueTask SetAsync(string key, T value, HybridCacheEntryOptions? options = null, IEnumerable? tags = null,
- CT ct = new())
+ Ct ct = new())
{
_setAsyncCalls.Add((key, value!, options));
_cache[key] = value!;
return ValueTask.CompletedTask;
}
- public override ValueTask RemoveAsync(string key, CT ct = new()) => throw new NotImplementedException();
+ public override ValueTask RemoveAsync(string key, Ct ct = new()) => throw new NotImplementedException();
- public override ValueTask RemoveByTagAsync(string tag, CT ct = new()) => throw new NotImplementedException();
+ public override ValueTask RemoveByTagAsync(string tag, Ct ct = new()) => throw new NotImplementedException();
public IReadOnlyList<(string key, object value, HybridCacheEntryOptions? options)> SetAsyncCalls => _setAsyncCalls;
public IReadOnlyList<(string key, HybridCacheEntryOptions? options)> GetOrCreateAsyncCalls => _getOrCreateAsyncCalls;
diff --git a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestReplayCache.cs b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestReplayCache.cs
index 6e0c51784..79a7a0cfd 100644
--- a/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestReplayCache.cs
+++ b/aspnetcore-authentication-jwtbearer/test/AspNetCore.Authentication.JwtBearer.Tests/TestFramework/TestReplayCache.cs
@@ -14,14 +14,14 @@ public class TestReplayCache : IReplayCache
// Configuration for test behavior
public Func? ExistsFunc { get; set; }
- public Task Add(string jtiHash, TimeSpan expiration, CT ct = default)
+ public Task Add(string jtiHash, TimeSpan expiration, Ct ct = default)
{
_addCalls.Add((jtiHash, expiration));
_cache[jtiHash] = (expiration, DateTime.UtcNow);
return Task.CompletedTask;
}
- public Task Exists(string jtiHash, CT ct = default)
+ public Task Exists(string jtiHash, Ct ct = default)
{
_existsCalls.Add(jtiHash);
diff --git a/bff/hosts/Hosts.Bff.InMemory/ImpersonationAccessTokenRetriever.cs b/bff/hosts/Hosts.Bff.InMemory/ImpersonationAccessTokenRetriever.cs
index f1f18da42..bac852ad3 100644
--- a/bff/hosts/Hosts.Bff.InMemory/ImpersonationAccessTokenRetriever.cs
+++ b/bff/hosts/Hosts.Bff.InMemory/ImpersonationAccessTokenRetriever.cs
@@ -9,7 +9,7 @@ namespace Bff;
public class ImpersonationAccessTokenRetriever(IAccessTokenRetriever inner) : IAccessTokenRetriever
{
- public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, CT ct = default)
+ public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, Ct ct = default)
{
var result = await inner.GetAccessTokenAsync(context, ct);
diff --git a/bff/hosts/Hosts.Bff.MultiFrontend/ImpersonationAccessTokenRetriever.cs b/bff/hosts/Hosts.Bff.MultiFrontend/ImpersonationAccessTokenRetriever.cs
index f1f18da42..bac852ad3 100644
--- a/bff/hosts/Hosts.Bff.MultiFrontend/ImpersonationAccessTokenRetriever.cs
+++ b/bff/hosts/Hosts.Bff.MultiFrontend/ImpersonationAccessTokenRetriever.cs
@@ -9,7 +9,7 @@ namespace Bff;
public class ImpersonationAccessTokenRetriever(IAccessTokenRetriever inner) : IAccessTokenRetriever
{
- public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, CT ct = default)
+ public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, Ct ct = default)
{
var result = await inner.GetAccessTokenAsync(context, ct);
diff --git a/bff/hosts/Hosts.Bff.MultiFrontend/Program.cs b/bff/hosts/Hosts.Bff.MultiFrontend/Program.cs
index 3296ec36c..7aad37e6e 100644
--- a/bff/hosts/Hosts.Bff.MultiFrontend/Program.cs
+++ b/bff/hosts/Hosts.Bff.MultiFrontend/Program.cs
@@ -166,7 +166,7 @@ app.MapGet("/local/self-contained", (CurrentFrontendAccessor currentFrontendAcce
return data;
});
-app.MapGet("/local/invokes-external-api", async (CurrentFrontendAccessor currentFrontendAccessor, IHttpClientFactory httpClientFactory, HttpContext c, CT ct) =>
+app.MapGet("/local/invokes-external-api", async (CurrentFrontendAccessor currentFrontendAccessor, IHttpClientFactory httpClientFactory, HttpContext c, Ct ct) =>
{
var httpClient = httpClientFactory.CreateClient("api");
var apiResult = await httpClient.GetAsync("/user-token");
@@ -235,7 +235,7 @@ RouteConfig[] BuildYarpRoutes()
public class FrontendAwareIndexHtmlTransformer : IIndexHtmlTransformer
{
- public Task Transform(string indexHtml, BffFrontend frontend, CT ct = default)
+ public Task Transform(string indexHtml, BffFrontend frontend, Ct ct = default)
{
indexHtml = indexHtml.Replace("[FrontendName]", frontend.Name);
indexHtml = indexHtml.Replace("[Path]", frontend.MatchingCriteria.MatchingPath + "/"); // Note, the path must end with a slash
diff --git a/bff/hosts/Hosts.Bff.Performance/Services/ApiHostedService.cs b/bff/hosts/Hosts.Bff.Performance/Services/ApiHostedService.cs
index 7ee61e2b1..d3c31553c 100644
--- a/bff/hosts/Hosts.Bff.Performance/Services/ApiHostedService.cs
+++ b/bff/hosts/Hosts.Bff.Performance/Services/ApiHostedService.cs
@@ -9,7 +9,7 @@ public class ApiHostedService(IOptions apiSettings) : BackgroundSer
{
public ApiSettings Settings { get; } = apiSettings.Value;
- protected override Task ExecuteAsync(CT stoppingToken)
+ protected override Task ExecuteAsync(Ct stoppingToken)
{
var builder = WebApplication.CreateBuilder();
builder.AddServiceDefaults();
diff --git a/bff/hosts/Hosts.Bff.Performance/Services/BffService.cs b/bff/hosts/Hosts.Bff.Performance/Services/BffService.cs
index 6fcd0ed1c..730540d7c 100644
--- a/bff/hosts/Hosts.Bff.Performance/Services/BffService.cs
+++ b/bff/hosts/Hosts.Bff.Performance/Services/BffService.cs
@@ -15,7 +15,7 @@ public abstract class BffService(string[] urlConfigKeys, IConfiguration config,
public IConfiguration Config { get; } = config;
public BffSettings Settings { get; } = bffSettings.Value;
- protected override async Task ExecuteAsync(CT stoppingToken)
+ protected override async Task ExecuteAsync(Ct stoppingToken)
{
var urls = urlConfigKeys
.Select(x => Config[x])
diff --git a/bff/hosts/Hosts.Bff.Performance/Services/IdentityServerService.cs b/bff/hosts/Hosts.Bff.Performance/Services/IdentityServerService.cs
index 4d2534b2d..96be741ad 100644
--- a/bff/hosts/Hosts.Bff.Performance/Services/IdentityServerService.cs
+++ b/bff/hosts/Hosts.Bff.Performance/Services/IdentityServerService.cs
@@ -17,7 +17,7 @@ public class IdentityServerService(IOptions settings, IC
{
public IdentityServerSettings Settings { get; } = settings.Value;
- protected override Task ExecuteAsync(CT stoppingToken)
+ protected override Task ExecuteAsync(Ct stoppingToken)
{
var builder = WebApplication.CreateBuilder();
builder.AddServiceDefaults();
diff --git a/bff/performance/Bff.Benchmarks/Hosts/CookieHandler.cs b/bff/performance/Bff.Benchmarks/Hosts/CookieHandler.cs
index 00bf0059b..1f696bf13 100644
--- a/bff/performance/Bff.Benchmarks/Hosts/CookieHandler.cs
+++ b/bff/performance/Bff.Benchmarks/Hosts/CookieHandler.cs
@@ -9,7 +9,7 @@ namespace Bff.Benchmarks.Hosts;
internal class CookieHandler(HttpMessageHandler innerHandler, CookieContainer cookieContainer)
: DelegatingHandler(innerHandler)
{
- protected override async Task SendAsync(HttpRequestMessage request, CT ct)
+ protected override async Task SendAsync(HttpRequestMessage request, Ct ct)
{
var requestUri = request.RequestUri;
var header = cookieContainer.GetCookieHeader(requestUri!);
diff --git a/bff/performance/Bff.Benchmarks/Hosts/RedirectHandler.cs b/bff/performance/Bff.Benchmarks/Hosts/RedirectHandler.cs
index d410a2d5b..3488b4eb4 100644
--- a/bff/performance/Bff.Benchmarks/Hosts/RedirectHandler.cs
+++ b/bff/performance/Bff.Benchmarks/Hosts/RedirectHandler.cs
@@ -12,7 +12,7 @@ internal class RedirectHandler() : DelegatingHandler
public bool AutoFollowRedirects { get; set; } = true;
protected override async Task SendAsync(HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
var originalUri = request.RequestUri;
diff --git a/bff/performance/Bff.Benchmarks/Hosts/RoutingMessageHandler.cs b/bff/performance/Bff.Benchmarks/Hosts/RoutingMessageHandler.cs
index 8458d3628..c0222cf7c 100644
--- a/bff/performance/Bff.Benchmarks/Hosts/RoutingMessageHandler.cs
+++ b/bff/performance/Bff.Benchmarks/Hosts/RoutingMessageHandler.cs
@@ -27,7 +27,7 @@ internal class RoutingMessageHandler : HttpMessageHandler
protected override Task SendAsync(
HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
var host = $"{request.RequestUri?.Host}:{request.RequestUri?.Port}";
@@ -46,7 +46,7 @@ internal class RoutingMessageHandler : HttpMessageHandler
{
internal Task SuppressedSend(
HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
Task t;
if (ExecutionContext.IsFlowSuppressed())
diff --git a/bff/performance/Bff.Benchmarks/Hosts/SimulatedInternet.cs b/bff/performance/Bff.Benchmarks/Hosts/SimulatedInternet.cs
index 6e4cc2ee8..1cfaa63a0 100644
--- a/bff/performance/Bff.Benchmarks/Hosts/SimulatedInternet.cs
+++ b/bff/performance/Bff.Benchmarks/Hosts/SimulatedInternet.cs
@@ -64,7 +64,7 @@ internal class SimulatedInternet : DelegatingHandler
protected override async Task SendAsync(
HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
var httpResponseMessage = await base.SendAsync(request, ct);
return httpResponseMessage;
diff --git a/bff/performance/Bff.Performance/TestInfra/AutoFollowRedirectHandler.cs b/bff/performance/Bff.Performance/TestInfra/AutoFollowRedirectHandler.cs
index d33c82d40..56088f197 100644
--- a/bff/performance/Bff.Performance/TestInfra/AutoFollowRedirectHandler.cs
+++ b/bff/performance/Bff.Performance/TestInfra/AutoFollowRedirectHandler.cs
@@ -8,7 +8,7 @@ namespace Bff.Performance.TestInfra;
public class AutoFollowRedirectHandler(Action writeOutput) : DelegatingHandler
{
protected override async Task SendAsync(HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
var previousUri = request.RequestUri;
for (var i = 0; i < 20; i++)
diff --git a/bff/performance/Bff.Performance/TestInfra/CloningHttpMessageHandler.cs b/bff/performance/Bff.Performance/TestInfra/CloningHttpMessageHandler.cs
index bdfb56601..91998edba 100644
--- a/bff/performance/Bff.Performance/TestInfra/CloningHttpMessageHandler.cs
+++ b/bff/performance/Bff.Performance/TestInfra/CloningHttpMessageHandler.cs
@@ -9,7 +9,7 @@ public class CloningHttpMessageHandler(HttpClient innerHttpClient) : HttpMessage
innerHttpClient ?? throw new ArgumentNullException(nameof(innerHttpClient));
protected override async Task SendAsync(HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
// Clone the incoming request
var clonedRequest = await CloneHttpRequestMessageAsync(request);
diff --git a/bff/performance/Bff.Performance/TestInfra/RequestLoggingHandler.cs b/bff/performance/Bff.Performance/TestInfra/RequestLoggingHandler.cs
index fc3abae9e..81d9102ae 100644
--- a/bff/performance/Bff.Performance/TestInfra/RequestLoggingHandler.cs
+++ b/bff/performance/Bff.Performance/TestInfra/RequestLoggingHandler.cs
@@ -12,7 +12,7 @@ public class RequestLoggingHandler(
: DelegatingHandler
{
protected override async Task SendAsync(HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
if (!shouldLog(request))
{
diff --git a/bff/src/Bff.Blazor.Client/Internals/AntiforgeryHandler.cs b/bff/src/Bff.Blazor.Client/Internals/AntiforgeryHandler.cs
index 6d6d05b9d..98ef58f0c 100644
--- a/bff/src/Bff.Blazor.Client/Internals/AntiforgeryHandler.cs
+++ b/bff/src/Bff.Blazor.Client/Internals/AntiforgeryHandler.cs
@@ -6,7 +6,7 @@ namespace Duende.Bff.Blazor.Client.Internals;
internal class AntiForgeryHandler : DelegatingHandler
{
protected override Task SendAsync(HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
request.Headers.Add("X-CSRF", "1");
return base.SendAsync(request, ct);
diff --git a/bff/src/Bff.Blazor/BffServerAuthenticationStateProvider.cs b/bff/src/Bff.Blazor/BffServerAuthenticationStateProvider.cs
index a3084be75..c5a22d567 100644
--- a/bff/src/Bff.Blazor/BffServerAuthenticationStateProvider.cs
+++ b/bff/src/Bff.Blazor/BffServerAuthenticationStateProvider.cs
@@ -126,7 +126,7 @@ internal sealed class BffServerAuthenticationStateProvider : RevalidatingServerA
/// The current authentication state.
/// A token that can be used to request cancellation of the asynchronous operation.
/// A boolean indicating whether the authentication state is valid.
- protected override async Task ValidateAuthenticationStateAsync(AuthenticationState authenticationState, CT ct)
+ protected override async Task ValidateAuthenticationStateAsync(AuthenticationState authenticationState, Ct ct)
{
using var scope = _serviceScopeFactory.CreateScope();
var sessionStore = scope.ServiceProvider.GetRequiredService();
diff --git a/bff/src/Bff.Blazor/ServerSideTokenStore.cs b/bff/src/Bff.Blazor/ServerSideTokenStore.cs
index 34cf00413..172331fbc 100644
--- a/bff/src/Bff.Blazor/ServerSideTokenStore.cs
+++ b/bff/src/Bff.Blazor/ServerSideTokenStore.cs
@@ -32,7 +32,7 @@ internal class ServerSideTokenStore(
?? throw new ArgumentException("AuthenticationStateProvider must implement IHostEnvironmentAuthenticationStateProvider");
public async Task> GetTokenAsync(ClaimsPrincipal user, UserTokenRequestParameters? parameters = null,
- CT ct = default)
+ Ct ct = default)
{
logger.RetrievingTokenForUser(LogLevel.Debug, user.Identity?.Name);
var session = await GetSession(user);
@@ -83,7 +83,7 @@ internal class ServerSideTokenStore(
}
public async Task StoreTokenAsync(ClaimsPrincipal user, UserToken token,
- UserTokenRequestParameters? parameters = null, CT ct = default)
+ UserTokenRequestParameters? parameters = null, Ct ct = default)
{
logger.StoringTokenForUser(LogLevel.Debug, user.Identity?.Name);
await UpdateTicket(user,
@@ -91,7 +91,7 @@ internal class ServerSideTokenStore(
}
- public async Task ClearTokenAsync(ClaimsPrincipal user, UserTokenRequestParameters? parameters = null, CT ct = default)
+ public async Task ClearTokenAsync(ClaimsPrincipal user, UserTokenRequestParameters? parameters = null, Ct ct = default)
{
logger.RemovingTokenForUser(LogLevel.Debug, user.Identity?.Name);
await UpdateTicket(user, ticket =>
diff --git a/bff/src/Bff.EntityFramework/ISessionDbContext.cs b/bff/src/Bff.EntityFramework/ISessionDbContext.cs
index 8adf7956d..75c552952 100644
--- a/bff/src/Bff.EntityFramework/ISessionDbContext.cs
+++ b/bff/src/Bff.EntityFramework/ISessionDbContext.cs
@@ -23,5 +23,5 @@ public interface ISessionDbContext
/// Saves the changes.
///
///
- Task SaveChangesAsync(CT ct = default);
+ Task SaveChangesAsync(Ct ct = default);
}
diff --git a/bff/src/Bff.EntityFramework/Internal/UserSessionStore.cs b/bff/src/Bff.EntityFramework/Internal/UserSessionStore.cs
index 5bdcda9ff..831e00983 100644
--- a/bff/src/Bff.EntityFramework/Internal/UserSessionStore.cs
+++ b/bff/src/Bff.EntityFramework/Internal/UserSessionStore.cs
@@ -18,7 +18,7 @@ internal sealed class UserSessionStore(
: IUserSessionStore, IUserSessionStoreCleanup
{
///
- public async Task CreateUserSessionAsync(UserSession session, CT ct)
+ public async Task CreateUserSessionAsync(UserSession session, Ct ct)
{
if (!session.PartitionKey.HasValue)
{
@@ -67,7 +67,7 @@ internal sealed class UserSessionStore(
}
///
- public async Task DeleteUserSessionAsync(UserSessionKey key, CT ct)
+ public async Task DeleteUserSessionAsync(UserSessionKey key, Ct ct)
{
var userKey = key.UserKey;
var partitionKey = key.PartitionKey;
@@ -104,7 +104,7 @@ internal sealed class UserSessionStore(
}
///
- public async Task DeleteUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, CT ct)
+ public async Task DeleteUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, Ct ct)
{
filter.Validate();
var query = sessionDbContext.UserSessions.Where(x => x.PartitionKey == partitionKey).AsQueryable();
@@ -152,7 +152,7 @@ internal sealed class UserSessionStore(
}
///
- public async Task GetUserSessionAsync(UserSessionKey key, CT ct)
+ public async Task GetUserSessionAsync(UserSessionKey key, Ct ct)
{
var userKey = key.UserKey;
var partitionKey = key.PartitionKey;
@@ -175,7 +175,7 @@ internal sealed class UserSessionStore(
}
///
- public async Task> GetUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, CT ct)
+ public async Task> GetUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, Ct ct)
{
filter.Validate();
var query = sessionDbContext.UserSessions.Where(x => x.PartitionKey == partitionKey).AsQueryable();
@@ -213,7 +213,7 @@ internal sealed class UserSessionStore(
}
///
- public async Task UpdateUserSessionAsync(UserSessionKey key, UserSessionUpdate session, CT ct)
+ public async Task UpdateUserSessionAsync(UserSessionKey key, UserSessionUpdate session, Ct ct)
{
var userKey = key.UserKey;
var partitionKey = key.PartitionKey;
@@ -235,7 +235,7 @@ internal sealed class UserSessionStore(
}
///
- public async Task DeleteExpiredSessionsAsync(CT ct = default)
+ public async Task DeleteExpiredSessionsAsync(Ct ct = default)
{
var removed = 0;
diff --git a/bff/src/Bff.Yarp/GlobalAliasses.cs b/bff/src/Bff.Yarp/GlobalAliases.cs
similarity index 100%
rename from bff/src/Bff.Yarp/GlobalAliasses.cs
rename to bff/src/Bff.Yarp/GlobalAliases.cs
diff --git a/bff/src/Bff.Yarp/Internal/RemoteRouteHandler.cs b/bff/src/Bff.Yarp/Internal/RemoteRouteHandler.cs
index 492ccd4c1..d8f6ab937 100644
--- a/bff/src/Bff.Yarp/Internal/RemoteRouteHandler.cs
+++ b/bff/src/Bff.Yarp/Internal/RemoteRouteHandler.cs
@@ -68,7 +68,7 @@ internal class RemoteRouteHandler : IDisposable
public void ClearTransformerCacheFor(BffFrontend frontend) => _cache.TryRemove(frontend.Name, out _);
- public async Task HandleAsync(HttpContext context, CT ct)
+ public async Task HandleAsync(HttpContext context, Ct ct)
{
if (!_currentFrontendAccessor.TryGet(out var frontend))
{
diff --git a/bff/src/Bff/AccessTokenManagement/IAccessTokenRetriever.cs b/bff/src/Bff/AccessTokenManagement/IAccessTokenRetriever.cs
index 9127a0d56..f70128fea 100644
--- a/bff/src/Bff/AccessTokenManagement/IAccessTokenRetriever.cs
+++ b/bff/src/Bff/AccessTokenManagement/IAccessTokenRetriever.cs
@@ -15,5 +15,5 @@ public interface IAccessTokenRetriever
/// A task that contains the access token result, which is an
/// object model that can represent various types of tokens (bearer, dpop),
/// the absence of an optional token, or an error.
- public Task GetAccessTokenAsync(AccessTokenRetrievalContext context, CT ct = default);
+ public Task GetAccessTokenAsync(AccessTokenRetrievalContext context, Ct ct = default);
}
diff --git a/bff/src/Bff/Diagnostics/DiagnosticDataService.cs b/bff/src/Bff/Diagnostics/DiagnosticDataService.cs
index bb804ac37..e67237821 100644
--- a/bff/src/Bff/Diagnostics/DiagnosticDataService.cs
+++ b/bff/src/Bff/Diagnostics/DiagnosticDataService.cs
@@ -8,7 +8,7 @@ namespace Duende.Bff.Diagnostics;
internal class DiagnosticDataService(DateTime serverStartTime, IEnumerable entries)
{
- public async Task> GetJsonBytesAsync(CT ct = default)
+ public async Task> GetJsonBytesAsync(Ct ct = default)
{
var bufferWriter = new ArrayBufferWriter();
await using var writer = new Utf8JsonWriter(bufferWriter, new JsonWriterOptions { Indented = false });
diff --git a/bff/src/Bff/Diagnostics/DiagnosticHostedService.cs b/bff/src/Bff/Diagnostics/DiagnosticHostedService.cs
index f6fa0775d..d2be6eb35 100644
--- a/bff/src/Bff/Diagnostics/DiagnosticHostedService.cs
+++ b/bff/src/Bff/Diagnostics/DiagnosticHostedService.cs
@@ -14,7 +14,7 @@ internal class DiagnosticHostedService(
ILogger logger,
TimeProvider timeProvider) : BackgroundService
{
- protected override async Task ExecuteAsync(CT stoppingToken)
+ protected override async Task ExecuteAsync(Ct stoppingToken)
{
using var timer = new PeriodicTimer(options.Value.Diagnostics.LogFrequency, timeProvider);
try
@@ -40,7 +40,7 @@ internal class DiagnosticHostedService(
}
}
- public override async Task StopAsync(CT ct)
+ public override async Task StopAsync(Ct ct)
{
await diagnosticsSummary.PrintSummaryAsync(ct);
diff --git a/bff/src/Bff/Diagnostics/DiagnosticSummary.cs b/bff/src/Bff/Diagnostics/DiagnosticSummary.cs
index a93dce9bb..a320f0d56 100644
--- a/bff/src/Bff/Diagnostics/DiagnosticSummary.cs
+++ b/bff/src/Bff/Diagnostics/DiagnosticSummary.cs
@@ -15,7 +15,7 @@ internal class DiagnosticSummary(
{
private readonly ILogger _logger = loggerFactory.CreateLogger("Duende.BFF.Diagnostics.Summary");
- public async Task PrintSummaryAsync(CT ct = default)
+ public async Task PrintSummaryAsync(Ct ct = default)
{
var bffOptions = options.Value;
var jsonMemory = await diagnosticDataService.GetJsonBytesAsync(ct);
diff --git a/bff/src/Bff/DynamicFrontends/IIndexHtmlTransformer.cs b/bff/src/Bff/DynamicFrontends/IIndexHtmlTransformer.cs
index bae1cb126..67ab4fd12 100644
--- a/bff/src/Bff/DynamicFrontends/IIndexHtmlTransformer.cs
+++ b/bff/src/Bff/DynamicFrontends/IIndexHtmlTransformer.cs
@@ -10,5 +10,5 @@ namespace Duende.Bff.DynamicFrontends;
///
public interface IIndexHtmlTransformer
{
- Task Transform(string indexHtml, BffFrontend frontend, CT ct = default);
+ Task Transform(string indexHtml, BffFrontend frontend, Ct ct = default);
}
diff --git a/bff/src/Bff/DynamicFrontends/IStaticFilesClient.cs b/bff/src/Bff/DynamicFrontends/IStaticFilesClient.cs
index 3a4dedc36..d9b1bb102 100644
--- a/bff/src/Bff/DynamicFrontends/IStaticFilesClient.cs
+++ b/bff/src/Bff/DynamicFrontends/IStaticFilesClient.cs
@@ -20,7 +20,7 @@ public interface IStaticFilesClient
///
/// CancellationToken
/// Index HTML
- Task GetIndexHtmlAsync(CT ct = default);
+ Task GetIndexHtmlAsync(Ct ct = default);
///
/// This method proxies all static asset requests to the configured CDN URL for the current frontend.
@@ -34,5 +34,5 @@ public interface IStaticFilesClient
/// HttpContext
/// CancellationToken
///
- Task ProxyStaticAssetsAsync(HttpContext context, CT ct = default);
+ Task ProxyStaticAssetsAsync(HttpContext context, Ct ct = default);
}
diff --git a/bff/src/Bff/DynamicFrontends/Internal/BffCacheClearingHostedService.cs b/bff/src/Bff/DynamicFrontends/Internal/BffCacheClearingHostedService.cs
index a6e4d3cc1..bac8ecae1 100644
--- a/bff/src/Bff/DynamicFrontends/Internal/BffCacheClearingHostedService.cs
+++ b/bff/src/Bff/DynamicFrontends/Internal/BffCacheClearingHostedService.cs
@@ -30,7 +30,7 @@ internal class BffCacheClearingHostedService(
private ChannelWriter Writer => _channel.Writer;
private ChannelReader Reader => _channel.Reader;
- protected override async Task ExecuteAsync(CT ct)
+ protected override async Task ExecuteAsync(Ct ct)
{
// Subscribe to frontend changes and publish messages to the channel
frontendCollection.OnFrontendChanged += changedFrontend =>
@@ -55,7 +55,7 @@ internal class BffCacheClearingHostedService(
await ProcessFrontendChangesAsync(ct);
}
- private async Task ProcessFrontendChangesAsync(CT ct)
+ private async Task ProcessFrontendChangesAsync(Ct ct)
{
try
{
@@ -77,7 +77,7 @@ internal class BffCacheClearingHostedService(
}
}
- private async Task ProcessFrontendChangeAsync(BffFrontend changedFrontend, CT ct)
+ private async Task ProcessFrontendChangeAsync(BffFrontend changedFrontend, Ct ct)
{
try
{
diff --git a/bff/src/Bff/DynamicFrontends/Internal/StaticFilesHttpClient.cs b/bff/src/Bff/DynamicFrontends/Internal/StaticFilesHttpClient.cs
index 79f5b6c5f..0f27230c2 100644
--- a/bff/src/Bff/DynamicFrontends/Internal/StaticFilesHttpClient.cs
+++ b/bff/src/Bff/DynamicFrontends/Internal/StaticFilesHttpClient.cs
@@ -23,7 +23,7 @@ internal class StaticFilesHttpClient(
{
private readonly CancellationTokenSource _stopping = new();
- public async Task GetIndexHtmlAsync(CT ct = default)
+ public async Task GetIndexHtmlAsync(Ct ct = default)
{
var frontend = currentFrontendAccessor.Get();
@@ -67,7 +67,7 @@ internal class StaticFilesHttpClient(
}
}
- public async Task ProxyStaticAssetsAsync(HttpContext context, CT ct = default)
+ public async Task ProxyStaticAssetsAsync(HttpContext context, Ct ct = default)
{
var frontend = currentFrontendAccessor.Get();
diff --git a/bff/src/Bff/Endpoints/IBffEndpoint.cs b/bff/src/Bff/Endpoints/IBffEndpoint.cs
index 5a0cdf4b2..4b42bfaa8 100644
--- a/bff/src/Bff/Endpoints/IBffEndpoint.cs
+++ b/bff/src/Bff/Endpoints/IBffEndpoint.cs
@@ -14,5 +14,5 @@ public interface IBffEndpoint
/// Process a request
///
///
- Task ProcessRequestAsync(HttpContext context, CT ct = default);
+ Task ProcessRequestAsync(HttpContext context, Ct ct = default);
}
diff --git a/bff/src/Bff/Endpoints/IUserEndpointClaimsEnricher.cs b/bff/src/Bff/Endpoints/IUserEndpointClaimsEnricher.cs
index 8c5681980..7f81dc4e7 100644
--- a/bff/src/Bff/Endpoints/IUserEndpointClaimsEnricher.cs
+++ b/bff/src/Bff/Endpoints/IUserEndpointClaimsEnricher.cs
@@ -26,5 +26,5 @@ public interface IUserEndpointClaimsEnricher
/// The current set of claims to be returned.
/// Cancellation token
/// The updated list of claims.
- Task> EnrichClaimsAsync(AuthenticateResult authenticateResult, IReadOnlyList claims, CT ct = default);
+ Task> EnrichClaimsAsync(AuthenticateResult authenticateResult, IReadOnlyList claims, Ct ct = default);
}
diff --git a/bff/src/Bff/Endpoints/Internal/DefaultBackchannelLogoutEndpoint.cs b/bff/src/Bff/Endpoints/Internal/DefaultBackchannelLogoutEndpoint.cs
index 56447292b..f53a7441a 100644
--- a/bff/src/Bff/Endpoints/Internal/DefaultBackchannelLogoutEndpoint.cs
+++ b/bff/src/Bff/Endpoints/Internal/DefaultBackchannelLogoutEndpoint.cs
@@ -27,7 +27,7 @@ internal class DefaultBackchannelLogoutEndpoint(
ILogger logger) : IBackchannelLogoutEndpoint
{
///
- public async Task ProcessRequestAsync(HttpContext context, CT ct = default)
+ public async Task ProcessRequestAsync(HttpContext context, Ct ct = default)
{
logger.ProcessingBackChannelLogoutRequest(LogLevel.Debug);
@@ -167,7 +167,7 @@ internal class DefaultBackchannelLogoutEndpoint(
var config = options.Configuration;
if (config == null)
{
- config = await options.ConfigurationManager?.GetConfigurationAsync(CT.None)!;
+ config = await options.ConfigurationManager?.GetConfigurationAsync(Ct.None)!;
}
if (config == null)
diff --git a/bff/src/Bff/Endpoints/Internal/DefaultDiagnosticsEndpoint.cs b/bff/src/Bff/Endpoints/Internal/DefaultDiagnosticsEndpoint.cs
index 04c8e7402..513a78b07 100644
--- a/bff/src/Bff/Endpoints/Internal/DefaultDiagnosticsEndpoint.cs
+++ b/bff/src/Bff/Endpoints/Internal/DefaultDiagnosticsEndpoint.cs
@@ -24,7 +24,7 @@ internal class DefaultDiagnosticsEndpoint(IWebHostEnvironment environment, IOpti
};
///
- public async Task ProcessRequestAsync(HttpContext context, CT ct = default)
+ public async Task ProcessRequestAsync(HttpContext context, Ct ct = default)
{
if (options.Value.DiagnosticsEnvironments?.Contains(environment.EnvironmentName) is null or false)
{
diff --git a/bff/src/Bff/Endpoints/Internal/DefaultLoginEndpoint.cs b/bff/src/Bff/Endpoints/Internal/DefaultLoginEndpoint.cs
index 07b6794b5..3d5b5d5db 100644
--- a/bff/src/Bff/Endpoints/Internal/DefaultLoginEndpoint.cs
+++ b/bff/src/Bff/Endpoints/Internal/DefaultLoginEndpoint.cs
@@ -27,7 +27,7 @@ internal class DefaultLoginEndpoint(
: ILoginEndpoint
{
///
- public async Task ProcessRequestAsync(HttpContext context, CT ct = default)
+ public async Task ProcessRequestAsync(HttpContext context, Ct ct = default)
{
logger.ProcessingLoginRequest(LogLevel.Debug);
@@ -85,7 +85,7 @@ internal class DefaultLoginEndpoint(
await context.ChallengeAsync(props);
}
- private async Task?> GetPromptValuesAsync(CT ct = default)
+ private async Task?> GetPromptValuesAsync(Ct ct = default)
{
Scheme scheme;
diff --git a/bff/src/Bff/Endpoints/Internal/DefaultLogoutEndpoint.cs b/bff/src/Bff/Endpoints/Internal/DefaultLogoutEndpoint.cs
index 05a2496af..2991909a4 100644
--- a/bff/src/Bff/Endpoints/Internal/DefaultLogoutEndpoint.cs
+++ b/bff/src/Bff/Endpoints/Internal/DefaultLogoutEndpoint.cs
@@ -22,7 +22,7 @@ internal class DefaultLogoutEndpoint(IOptions options,
: ILogoutEndpoint
{
///
- public async Task ProcessRequestAsync(HttpContext context, CT ct = default)
+ public async Task ProcessRequestAsync(HttpContext context, Ct ct = default)
{
logger.ProcessingLogoutRequest(LogLevel.Debug);
diff --git a/bff/src/Bff/Endpoints/Internal/DefaultSilentLoginCallbackEndpoint.cs b/bff/src/Bff/Endpoints/Internal/DefaultSilentLoginCallbackEndpoint.cs
index c9cee60d6..9779d72ff 100644
--- a/bff/src/Bff/Endpoints/Internal/DefaultSilentLoginCallbackEndpoint.cs
+++ b/bff/src/Bff/Endpoints/Internal/DefaultSilentLoginCallbackEndpoint.cs
@@ -21,7 +21,7 @@ internal class DefaultSilentLoginCallbackEndpoint(
{
///
- public async Task ProcessRequestAsync(HttpContext context, CT ct = default)
+ public async Task ProcessRequestAsync(HttpContext context, Ct ct = default)
{
logger.ProcessingSilentLoginCallbackRequest(LogLevel.Debug);
diff --git a/bff/src/Bff/Endpoints/Internal/DefaultSilentLoginEndpoint.cs b/bff/src/Bff/Endpoints/Internal/DefaultSilentLoginEndpoint.cs
index e231b690d..57b44a75a 100644
--- a/bff/src/Bff/Endpoints/Internal/DefaultSilentLoginEndpoint.cs
+++ b/bff/src/Bff/Endpoints/Internal/DefaultSilentLoginEndpoint.cs
@@ -23,7 +23,7 @@ internal class DefaultSilentLoginEndpoint(IOptions options, ILogger<
private readonly BffOptions _options = options.Value;
///
- public async Task ProcessRequestAsync(HttpContext context, CT ct = default)
+ public async Task ProcessRequestAsync(HttpContext context, Ct ct = default)
{
logger.ProcessingSilentLoginRequest(LogLevel.Debug);
diff --git a/bff/src/Bff/Endpoints/Internal/DefaultUserEndpoint.cs b/bff/src/Bff/Endpoints/Internal/DefaultUserEndpoint.cs
index 27c934bbf..3f8387995 100644
--- a/bff/src/Bff/Endpoints/Internal/DefaultUserEndpoint.cs
+++ b/bff/src/Bff/Endpoints/Internal/DefaultUserEndpoint.cs
@@ -26,7 +26,7 @@ internal class DefaultUserEndpoint(IOptions options, ILogger
- public async Task ProcessRequestAsync(HttpContext context, CT ct = default)
+ public async Task ProcessRequestAsync(HttpContext context, Ct ct = default)
{
logger.ProcessingUserRequest(LogLevel.Debug);
@@ -76,7 +76,7 @@ internal class DefaultUserEndpoint(IOptions options, ILogger
///
- private static Task> GetUserClaimsAsync(AuthenticateResult authenticateResult, CT ct = default) =>
+ private static Task> GetUserClaimsAsync(AuthenticateResult authenticateResult, Ct ct = default) =>
Task.FromResult(authenticateResult.Principal?.Claims.Select(x => new ClaimRecord(x.Type, x.Value)) ?? Enumerable.Empty());
///
@@ -86,7 +86,7 @@ internal class DefaultUserEndpoint(IOptions options, ILogger> GetManagementClaimsAsync(
HttpContext context,
AuthenticateResult authenticateResult,
- CT ct = default)
+ Ct ct = default)
{
var claims = new List();
diff --git a/bff/src/Bff/HttpContextExtensions.cs b/bff/src/Bff/HttpContextExtensions.cs
index f2254abac..f995a975c 100644
--- a/bff/src/Bff/HttpContextExtensions.cs
+++ b/bff/src/Bff/HttpContextExtensions.cs
@@ -51,7 +51,7 @@ internal static class HttpContextExtensions
this HttpContext context,
RequiredTokenType requiredTokenType,
BffUserAccessTokenParameters? userAccessTokenParameters = null,
- CT ct = default)
+ Ct ct = default)
{
if (requiredTokenType == RequiredTokenType.None)
{
diff --git a/bff/src/Bff/Internal/DefaultAccessTokenRetriever.cs b/bff/src/Bff/Internal/DefaultAccessTokenRetriever.cs
index 8da2852b5..db4c900d3 100644
--- a/bff/src/Bff/Internal/DefaultAccessTokenRetriever.cs
+++ b/bff/src/Bff/Internal/DefaultAccessTokenRetriever.cs
@@ -12,7 +12,7 @@ namespace Duende.Bff.Internal;
internal class DefaultAccessTokenRetriever() : IAccessTokenRetriever
{
///
- public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, CT ct = default)
+ public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, Ct ct = default)
{
if (context.Metadata.TokenType.HasValue)
{
diff --git a/bff/src/Bff/SessionManagement/Revocation/ISessionRevocationService.cs b/bff/src/Bff/SessionManagement/Revocation/ISessionRevocationService.cs
index d8506663c..2c9a4b917 100644
--- a/bff/src/Bff/SessionManagement/Revocation/ISessionRevocationService.cs
+++ b/bff/src/Bff/SessionManagement/Revocation/ISessionRevocationService.cs
@@ -17,5 +17,5 @@ public interface ISessionRevocationService
///
/// A token that can be used to request cancellation of the asynchronous operation.
///
- Task RevokeSessionsAsync(UserSessionsFilter filter, CT ct = default);
+ Task RevokeSessionsAsync(UserSessionsFilter filter, Ct ct = default);
}
diff --git a/bff/src/Bff/SessionManagement/Revocation/NopSessionRevocationService.cs b/bff/src/Bff/SessionManagement/Revocation/NopSessionRevocationService.cs
index 87a632758..53d5d094c 100644
--- a/bff/src/Bff/SessionManagement/Revocation/NopSessionRevocationService.cs
+++ b/bff/src/Bff/SessionManagement/Revocation/NopSessionRevocationService.cs
@@ -13,7 +13,7 @@ namespace Duende.Bff.SessionManagement.Revocation;
internal class NopSessionRevocationService(ILogger logger) : ISessionRevocationService
{
///
- public Task RevokeSessionsAsync(UserSessionsFilter filter, CT ct = default)
+ public Task RevokeSessionsAsync(UserSessionsFilter filter, Ct ct = default)
{
logger.NopSessionRevocation(LogLevel.Debug, filter.SubjectId, filter.SessionId);
return Task.CompletedTask;
diff --git a/bff/src/Bff/SessionManagement/Revocation/SessionRevocationService.cs b/bff/src/Bff/SessionManagement/Revocation/SessionRevocationService.cs
index 2ba398864..ddca3b7e3 100644
--- a/bff/src/Bff/SessionManagement/Revocation/SessionRevocationService.cs
+++ b/bff/src/Bff/SessionManagement/Revocation/SessionRevocationService.cs
@@ -27,7 +27,7 @@ internal class SessionRevocationService(
private readonly BffOptions _options = options.Value;
///
- public async Task RevokeSessionsAsync(UserSessionsFilter filter, CT ct = default)
+ public async Task RevokeSessionsAsync(UserSessionsFilter filter, Ct ct = default)
{
if (_options.BackchannelLogoutAllUserSessions)
{
diff --git a/bff/src/Bff/SessionManagement/SessionStore/IUserSessionStore.cs b/bff/src/Bff/SessionManagement/SessionStore/IUserSessionStore.cs
index 115f5806e..5436894d8 100644
--- a/bff/src/Bff/SessionManagement/SessionStore/IUserSessionStore.cs
+++ b/bff/src/Bff/SessionManagement/SessionStore/IUserSessionStore.cs
@@ -15,7 +15,7 @@ public interface IUserSessionStore
///
/// A token that can be used to request cancellation of the asynchronous operation.
///
- Task GetUserSessionAsync(UserSessionKey key, CT ct = default);
+ Task GetUserSessionAsync(UserSessionKey key, Ct ct = default);
///
/// Creates a user session
@@ -23,7 +23,7 @@ public interface IUserSessionStore
///
/// A token that can be used to request cancellation of the asynchronous operation.
///
- Task CreateUserSessionAsync(UserSession session, CT ct = default);
+ Task CreateUserSessionAsync(UserSession session, Ct ct = default);
///
/// Updates a user session
@@ -32,7 +32,7 @@ public interface IUserSessionStore
///
/// A token that can be used to request cancellation of the asynchronous operation.
///
- Task UpdateUserSessionAsync(UserSessionKey key, UserSessionUpdate session, CT ct = default);
+ Task UpdateUserSessionAsync(UserSessionKey key, UserSessionUpdate session, Ct ct = default);
///
/// Deletes a user session
@@ -40,7 +40,7 @@ public interface IUserSessionStore
///
/// A token that can be used to request cancellation of the asynchronous operation.
///
- Task DeleteUserSessionAsync(UserSessionKey key, CT ct = default);
+ Task DeleteUserSessionAsync(UserSessionKey key, Ct ct = default);
///
/// Queries user sessions based on the filter.
@@ -49,7 +49,7 @@ public interface IUserSessionStore
///
/// A token that can be used to request cancellation of the asynchronous operation.
///
- Task> GetUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, CT ct = default);
+ Task> GetUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, Ct ct = default);
///
/// Deletes user sessions based on the filter.
@@ -58,5 +58,5 @@ public interface IUserSessionStore
///
/// A token that can be used to request cancellation of the asynchronous operation.
///
- Task DeleteUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, CT ct = default);
+ Task DeleteUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, Ct ct = default);
}
diff --git a/bff/src/Bff/SessionManagement/SessionStore/IUserSessionStoreCleanup.cs b/bff/src/Bff/SessionManagement/SessionStore/IUserSessionStoreCleanup.cs
index 1a3968292..c802f8436 100644
--- a/bff/src/Bff/SessionManagement/SessionStore/IUserSessionStoreCleanup.cs
+++ b/bff/src/Bff/SessionManagement/SessionStore/IUserSessionStoreCleanup.cs
@@ -12,5 +12,5 @@ public interface IUserSessionStoreCleanup
///
/// Deletes expired sessions
///
- Task DeleteExpiredSessionsAsync(CT ct = default);
+ Task DeleteExpiredSessionsAsync(Ct ct = default);
}
diff --git a/bff/src/Bff/SessionManagement/SessionStore/InMemoryUserSessionStore.cs b/bff/src/Bff/SessionManagement/SessionStore/InMemoryUserSessionStore.cs
index 995f95ac0..f02d0f91b 100644
--- a/bff/src/Bff/SessionManagement/SessionStore/InMemoryUserSessionStore.cs
+++ b/bff/src/Bff/SessionManagement/SessionStore/InMemoryUserSessionStore.cs
@@ -19,7 +19,7 @@ internal class InMemoryUserSessionStore(
// A dictionary of dictionaries, where the outer dictionary is keyed by partition key
private readonly ConcurrentDictionary _store = new();
- public Task CreateUserSessionAsync(UserSession session, CT ct = default)
+ public Task CreateUserSessionAsync(UserSession session, Ct ct = default)
{
if (!session.PartitionKey.HasValue)
{
@@ -47,7 +47,7 @@ internal class InMemoryUserSessionStore(
return partition;
}
- public Task GetUserSessionAsync(UserSessionKey key, CT ct = default)
+ public Task GetUserSessionAsync(UserSessionKey key, Ct ct = default)
{
var partition = GetPartition(key.PartitionKey);
partition.TryGetValue(key.UserKey, out var item);
@@ -55,7 +55,7 @@ internal class InMemoryUserSessionStore(
return Task.FromResult(item?.Clone());
}
- public Task UpdateUserSessionAsync(UserSessionKey key, UserSessionUpdate session, CT ct = default)
+ public Task UpdateUserSessionAsync(UserSessionKey key, UserSessionUpdate session, Ct ct = default)
{
var partition = GetPartition(key.PartitionKey);
if (!partition.TryGetValue(key.UserKey, out var existing))
@@ -70,14 +70,14 @@ internal class InMemoryUserSessionStore(
return Task.CompletedTask;
}
- public Task DeleteUserSessionAsync(UserSessionKey key, CT ct = default)
+ public Task DeleteUserSessionAsync(UserSessionKey key, Ct ct = default)
{
var partition = GetPartition(key.PartitionKey);
partition.TryRemove(key.UserKey, out _);
return Task.CompletedTask;
}
- public Task> GetUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, CT ct = default)
+ public Task> GetUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, Ct ct = default)
{
filter.Validate();
var partition = GetPartition(partitionKey);
@@ -97,7 +97,7 @@ internal class InMemoryUserSessionStore(
return Task.FromResult((IReadOnlyCollection)results);
}
- public Task DeleteUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, CT ct = default)
+ public Task DeleteUserSessionsAsync(PartitionKey partitionKey, UserSessionsFilter filter, Ct ct = default)
{
filter.Validate();
var partition = GetPartition(partitionKey);
diff --git a/bff/src/Bff/SessionManagement/SessionStore/SessionCleanupHost.cs b/bff/src/Bff/SessionManagement/SessionStore/SessionCleanupHost.cs
index ff113b321..abacbd09c 100644
--- a/bff/src/Bff/SessionManagement/SessionStore/SessionCleanupHost.cs
+++ b/bff/src/Bff/SessionManagement/SessionStore/SessionCleanupHost.cs
@@ -23,7 +23,7 @@ internal class SessionCleanupHost(
private TimeSpan CleanupInterval => _options.SessionCleanupInterval;
- public override Task StartAsync(CT ct)
+ public override Task StartAsync(Ct ct)
{
if (!IsIUserSessionStoreCleanupRegistered())
{
@@ -34,7 +34,7 @@ internal class SessionCleanupHost(
return base.StartAsync(ct);
}
- protected override async Task ExecuteAsync(CT ct)
+ protected override async Task ExecuteAsync(Ct ct)
{
while (true)
{
@@ -70,7 +70,7 @@ internal class SessionCleanupHost(
}
}
- internal async Task RunAsync(CT ct = default)
+ internal async Task RunAsync(Ct ct = default)
{
try
{
diff --git a/bff/src/Bff/SessionManagement/TicketStore/IServerTicketStore.cs b/bff/src/Bff/SessionManagement/TicketStore/IServerTicketStore.cs
index ee4e1e3c3..a1dc53f1d 100644
--- a/bff/src/Bff/SessionManagement/TicketStore/IServerTicketStore.cs
+++ b/bff/src/Bff/SessionManagement/TicketStore/IServerTicketStore.cs
@@ -18,5 +18,5 @@ public interface IServerTicketStore : ITicketStore
///
/// A token that can be used to request cancellation of the asynchronous operation.
///
- Task> GetUserTicketsAsync(UserSessionsFilter filter, CT ct = default);
+ Task> GetUserTicketsAsync(UserSessionsFilter filter, Ct ct = default);
}
diff --git a/bff/src/Bff/SessionManagement/TicketStore/ServerSideTicketStore.cs b/bff/src/Bff/SessionManagement/TicketStore/ServerSideTicketStore.cs
index 51435b27a..e49fa97ca 100644
--- a/bff/src/Bff/SessionManagement/TicketStore/ServerSideTicketStore.cs
+++ b/bff/src/Bff/SessionManagement/TicketStore/ServerSideTicketStore.cs
@@ -31,7 +31,7 @@ internal class ServerSideTicketStore(
private readonly IDataProtector _protector = dataProtectionProvider.CreateProtector(DataProtectorPurpose);
- private CT ct => accessor.HttpContext?.RequestAborted ?? CT.None;
+ private Ct _ct => accessor.HttpContext?.RequestAborted ?? Ct.None;
///
public async Task StoreAsync(AuthenticationTicket ticket)
@@ -43,7 +43,7 @@ internal class ServerSideTicketStore(
{
SubjectId = ticket.GetSubjectId(),
SessionId = ticket.GetSessionId()
- }, ct);
+ }, _ct);
var key = CryptoRandom.CreateUniqueId(format: CryptoRandom.OutputFormat.Hex);
@@ -68,7 +68,7 @@ internal class ServerSideTicketStore(
Ticket = ticket.Serialize(_protector)
};
- await store.CreateUserSessionAsync(session, ct);
+ await store.CreateUserSessionAsync(session, _ct);
metrics.SessionStarted();
}
@@ -78,7 +78,7 @@ internal class ServerSideTicketStore(
logger.RetrieveAuthenticationTicket(LogLevel.Debug, key);
var userSessionKey = BuildUserSessionKey(key);
- var session = await store.GetUserSessionAsync(userSessionKey, ct);
+ var session = await store.GetUserSessionAsync(userSessionKey, _ct);
if (session == null)
{
logger.NoAuthenticationTicketFoundForKey(LogLevel.Debug, key);
@@ -111,7 +111,7 @@ internal class ServerSideTicketStore(
public async Task RenewAsync(string key, AuthenticationTicket ticket)
{
var userSessionKey = BuildUserSessionKey(key);
- var session = await store.GetUserSessionAsync(userSessionKey, ct);
+ var session = await store.GetUserSessionAsync(userSessionKey, _ct);
if (session == null)
{
// https://github.com/dotnet/aspnetcore/issues/41516#issuecomment-1178076544
@@ -134,7 +134,7 @@ internal class ServerSideTicketStore(
Renewed = ticket.GetIssued(timeProvider.GetUtcNow()),
Expires = ticket.GetExpiration(),
Ticket = ticket.Serialize(_protector)
- }, ct);
+ }, _ct);
}
///
@@ -150,11 +150,11 @@ internal class ServerSideTicketStore(
logger.RemovingAuthenticationTicket(LogLevel.Debug, userSessionKey.ToString());
metrics.SessionEnded();
- return store.DeleteUserSessionAsync(userSessionKey, ct);
+ return store.DeleteUserSessionAsync(userSessionKey, _ct);
}
///
- public async Task> GetUserTicketsAsync(UserSessionsFilter filter, CT ct)
+ public async Task> GetUserTicketsAsync(UserSessionsFilter filter, Ct ct)
{
logger.GettingAuthenticationTickets(LogLevel.Debug, filter.SubjectId, filter.SessionId);
diff --git a/bff/test/Bff.Tests/BffFrontendIndexTests.cs b/bff/test/Bff.Tests/BffFrontendIndexTests.cs
index 63b122525..b90097a52 100644
--- a/bff/test/Bff.Tests/BffFrontendIndexTests.cs
+++ b/bff/test/Bff.Tests/BffFrontendIndexTests.cs
@@ -171,7 +171,7 @@ public class BffFrontendIndexTests : BffTestBase
{
private int count = 1;
- public Task Transform(string html, BffFrontend frontend, CT ct = default) => Task.FromResult($"{html} - transformed {count++}");
+ public Task Transform(string html, BffFrontend frontend, Ct ct = default) => Task.FromResult($"{html} - transformed {count++}");
}
[Fact]
diff --git a/bff/test/Bff.Tests/BffFrontendSigninTests.cs b/bff/test/Bff.Tests/BffFrontendSigninTests.cs
index 918be7852..50c99a202 100644
--- a/bff/test/Bff.Tests/BffFrontendSigninTests.cs
+++ b/bff/test/Bff.Tests/BffFrontendSigninTests.cs
@@ -60,7 +60,7 @@ public class BffFrontendSigninTests : BffTestBase
Bff.OnConfigureApp += app =>
{
- app.MapGet(pathString, (HttpContext c, CT ct) => "ok");
+ app.MapGet(pathString, (HttpContext c, Ct ct) => "ok");
};
await InitializeAsync();
diff --git a/bff/test/Bff.Tests/BffRemoteApiTests.cs b/bff/test/Bff.Tests/BffRemoteApiTests.cs
index f0182ab81..d5b7ee867 100644
--- a/bff/test/Bff.Tests/BffRemoteApiTests.cs
+++ b/bff/test/Bff.Tests/BffRemoteApiTests.cs
@@ -143,7 +143,7 @@ public class BffRemoteApiTests : BffTestBase
public bool WasCalled = false;
public Task> GetAccessTokenAsync(ClaimsPrincipal user, UserTokenRequestParameters? parameters = null,
- CT ct = new CT())
+ Ct ct = new Ct())
{
WasCalled = true;
// We don't care actually about the result token. Just if it was called or not.
@@ -151,7 +151,7 @@ public class BffRemoteApiTests : BffTestBase
}
public Task RevokeRefreshTokenAsync(ClaimsPrincipal user, UserTokenRequestParameters? parameters = null,
- CT ct = new CT()) => throw new NotImplementedException();
+ Ct ct = new Ct()) => throw new NotImplementedException();
}
[Fact]
diff --git a/bff/test/Bff.Tests/BffScenarioTests.cs b/bff/test/Bff.Tests/BffScenarioTests.cs
index 1fdbb346d..c5764b9b7 100644
--- a/bff/test/Bff.Tests/BffScenarioTests.cs
+++ b/bff/test/Bff.Tests/BffScenarioTests.cs
@@ -47,7 +47,7 @@ public class BffScenarioTests : BffTestBase
TaskCompletionSource contentReceived,
TaskCompletionSource workerIsAllowedToStart) : BackgroundService
{
- protected override async Task ExecuteAsync(CT stoppingToken)
+ protected override async Task ExecuteAsync(Ct stoppingToken)
{
await workerIsAllowedToStart.Task;
diff --git a/bff/test/Bff.Tests/BffWithoutExplicitFrontendTests.cs b/bff/test/Bff.Tests/BffWithoutExplicitFrontendTests.cs
index 40f11c29b..18059beaf 100644
--- a/bff/test/Bff.Tests/BffWithoutExplicitFrontendTests.cs
+++ b/bff/test/Bff.Tests/BffWithoutExplicitFrontendTests.cs
@@ -11,7 +11,7 @@ public class BffWithoutExplicitFrontendTests : BffTestBase
{
Bff.OnConfigureApp += app =>
{
- app.MapGet("/secret", (HttpContext c, CT ct) =>
+ app.MapGet("/secret", (HttpContext c, Ct ct) =>
{
if (!c.User.IsAuthenticated())
{
diff --git a/bff/test/Bff.Tests/Blazor/Client/AntiforgeryHandlerTests.cs b/bff/test/Bff.Tests/Blazor/Client/AntiforgeryHandlerTests.cs
index 30a7b2949..1510efc29 100644
--- a/bff/test/Bff.Tests/Blazor/Client/AntiforgeryHandlerTests.cs
+++ b/bff/test/Bff.Tests/Blazor/Client/AntiforgeryHandlerTests.cs
@@ -23,7 +23,7 @@ public class AntiForgeryHandlerTests
var client = new HttpClient(sut);
- await client.SendAsync(request, CT.None);
+ await client.SendAsync(request, Ct.None);
request.Headers.ShouldContain(h => h.Key == "X-CSRF" && h.Value.Contains("1"));
}
@@ -31,5 +31,5 @@ public class AntiForgeryHandlerTests
public class NoOpHttpMessageHandler : HttpMessageHandler
{
- protected override Task SendAsync(HttpRequestMessage request, CT ct) => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK));
+ protected override Task SendAsync(HttpRequestMessage request, Ct ct) => Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK));
}
diff --git a/bff/test/Bff.Tests/Blazor/Client/FetchUserServiceTests.cs b/bff/test/Bff.Tests/Blazor/Client/FetchUserServiceTests.cs
index 8b0b24987..3f31bf19d 100644
--- a/bff/test/Bff.Tests/Blazor/Client/FetchUserServiceTests.cs
+++ b/bff/test/Bff.Tests/Blazor/Client/FetchUserServiceTests.cs
@@ -60,7 +60,7 @@ public class MockHttpMessageHandler : HttpMessageHandler
}
protected override async Task SendAsync(HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
if (request.Content != null) // Could be a GET-request without a body
{
diff --git a/bff/test/Bff.Tests/ConventionTests.cs b/bff/test/Bff.Tests/ConventionTests.cs
index 315bddc53..99488431e 100644
--- a/bff/test/Bff.Tests/ConventionTests.cs
+++ b/bff/test/Bff.Tests/ConventionTests.cs
@@ -211,12 +211,12 @@ public class ConventionTests
failures.Add($"{type.FullName}.{method.Name}: Async method should be suffixed with 'Async'.");
}
- // 2. Last parameter should be a CT (if there are any parameters)
+ // 2. Last parameter should be a Ct (if there are any parameters)
var parameters = method.GetParameters();
- if (parameters.Length == 0 || parameters.Last().ParameterType != typeof(CT))
+ if (parameters.Length == 0 || parameters.Last().ParameterType != typeof(Ct))
{
failures.Add(
- $"{type.FullName}.{method.Name}: Async method should have a CT as the last parameter.");
+ $"{type.FullName}.{method.Name}: Async method should have a Ct as the last parameter.");
}
}
}
@@ -273,7 +273,7 @@ public class ConventionTests
}
var ctParam = parameters.Last();
- if (ctParam.ParameterType != typeof(CT))
+ if (ctParam.ParameterType != typeof(Ct))
{
failures.Add($"{type.FullName}.{method.Name}: Last parameter should be CancellationToken.");
continue;
diff --git a/bff/test/Bff.Tests/Endpoints/Management/UserEndpointTests.cs b/bff/test/Bff.Tests/Endpoints/Management/UserEndpointTests.cs
index 684510229..0aa7b554f 100644
--- a/bff/test/Bff.Tests/Endpoints/Management/UserEndpointTests.cs
+++ b/bff/test/Bff.Tests/Endpoints/Management/UserEndpointTests.cs
@@ -33,7 +33,7 @@ public class UserEndpointTests : BffTestBase
private class TestClaimsEnricher(IHttpClientFactory factory) : IUserEndpointClaimsEnricher
{
- public async Task> EnrichClaimsAsync(AuthenticateResult authenticateResult, IReadOnlyList claims, CT ct = default)
+ public async Task> EnrichClaimsAsync(AuthenticateResult authenticateResult, IReadOnlyList claims, Ct ct = default)
{
var client = factory.CreateClient("c1");
diff --git a/bff/test/Bff.Tests/IAccessTokenRetriever_Extensibility_tests.cs b/bff/test/Bff.Tests/IAccessTokenRetriever_Extensibility_tests.cs
index cb381ed83..d351ec1c4 100644
--- a/bff/test/Bff.Tests/IAccessTokenRetriever_Extensibility_tests.cs
+++ b/bff/test/Bff.Tests/IAccessTokenRetriever_Extensibility_tests.cs
@@ -92,7 +92,7 @@ public class IAccessTokenRetriever_Extensibility_tests : BffTestBase
{
}
- public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, CT ct = default)
+ public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, Ct ct = default)
{
UsedContext = context;
if (context.Metadata.TokenType.HasValue)
diff --git a/bff/test/Bff.Tests/SessionManagement/ServerSideTokenStoreTests.cs b/bff/test/Bff.Tests/SessionManagement/ServerSideTokenStoreTests.cs
index fd3517d53..23ffff2e4 100644
--- a/bff/test/Bff.Tests/SessionManagement/ServerSideTokenStoreTests.cs
+++ b/bff/test/Bff.Tests/SessionManagement/ServerSideTokenStoreTests.cs
@@ -117,7 +117,7 @@ public class ServerSideTokenStoreTests
public Task SetUserTokenAsync(UserToken token, AuthenticationProperties authenticationProperties,
- UserTokenRequestParameters? parameters = null, CT ct = new CT())
+ UserTokenRequestParameters? parameters = null, Ct ct = new Ct())
{
Stored = token;
return Task.CompletedTask;
@@ -127,7 +127,7 @@ public class ServerSideTokenStoreTests
UserTokenRequestParameters? parameters = null) => Stored = null;
public Task GetSchemeAsync(UserTokenRequestParameters? parameters = null,
- CT ct = new CT()) =>
+ Ct ct = new Ct()) =>
Task.FromResult(Scheme.Bearer);
}
diff --git a/bff/test/Bff.Tests/TestFramework/FailureAccessTokenRetriever.cs b/bff/test/Bff.Tests/TestFramework/FailureAccessTokenRetriever.cs
index e4db35e36..11eb626f5 100644
--- a/bff/test/Bff.Tests/TestFramework/FailureAccessTokenRetriever.cs
+++ b/bff/test/Bff.Tests/TestFramework/FailureAccessTokenRetriever.cs
@@ -7,7 +7,7 @@ namespace Duende.Bff.Tests.TestFramework;
public class FailureAccessTokenRetriever : IAccessTokenRetriever
{
- public Task GetAccessTokenAsync(AccessTokenRetrievalContext context, CT ct = default) =>
+ public Task GetAccessTokenAsync(AccessTokenRetrievalContext context, Ct ct = default) =>
Task.FromResult(new AccessTokenRetrievalError
{
Error = "no access token"
diff --git a/bff/test/Bff.Tests/TestFramework/MockSessionRevocationService.cs b/bff/test/Bff.Tests/TestFramework/MockSessionRevocationService.cs
index 163aa365d..441ded8bc 100644
--- a/bff/test/Bff.Tests/TestFramework/MockSessionRevocationService.cs
+++ b/bff/test/Bff.Tests/TestFramework/MockSessionRevocationService.cs
@@ -10,7 +10,7 @@ public class MockSessionRevocationService : ISessionRevocationService
{
public bool DeleteUserSessionsWasCalled { get; set; }
public UserSessionsFilter? DeleteUserSessionsFilter { get; set; }
- public Task RevokeSessionsAsync(UserSessionsFilter filter, CT ct)
+ public Task RevokeSessionsAsync(UserSessionsFilter filter, Ct ct)
{
DeleteUserSessionsWasCalled = true;
DeleteUserSessionsFilter = filter;
diff --git a/bff/test/Bff.Tests/TestFramework/TestAccessTokenRetriever.cs b/bff/test/Bff.Tests/TestFramework/TestAccessTokenRetriever.cs
index 04b4e7cb4..905a57ac5 100644
--- a/bff/test/Bff.Tests/TestFramework/TestAccessTokenRetriever.cs
+++ b/bff/test/Bff.Tests/TestFramework/TestAccessTokenRetriever.cs
@@ -7,5 +7,5 @@ namespace Duende.Bff.Tests.TestFramework;
public class TestAccessTokenRetriever(Func> accessTokenGetter) : IAccessTokenRetriever
{
- public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, CT ct = default) => await accessTokenGetter();
+ public async Task GetAccessTokenAsync(AccessTokenRetrievalContext context, Ct ct = default) => await accessTokenGetter();
}
diff --git a/bff/test/Bff.Tests/TestFramework/TestBrowserClient.cs b/bff/test/Bff.Tests/TestFramework/TestBrowserClient.cs
index 115d232f5..f4398d6ad 100644
--- a/bff/test/Bff.Tests/TestFramework/TestBrowserClient.cs
+++ b/bff/test/Bff.Tests/TestFramework/TestBrowserClient.cs
@@ -15,7 +15,7 @@ public class TestBrowserClient : HttpClient
public HttpResponseMessage? LastResponse { get; private set; }
protected override async Task SendAsync(HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
CurrentUri = request.RequestUri ?? throw new NullReferenceException("RequestUri is not set");
var cookieHeader = CookieContainer.GetCookieHeader(request.RequestUri);
@@ -83,7 +83,7 @@ public class TestBrowserClient : HttpClient
internal async Task CallBffHostApi(
string url,
HttpStatusCode? expectedStatusCode = null,
- CT ct = default)
+ Ct ct = default)
{
var req = new HttpRequestMessage(HttpMethod.Get, url);
req.Headers.Add("x-csrf", "1");
@@ -112,7 +112,7 @@ public class TestBrowserClient : HttpClient
HttpMethod method,
HttpContent? content = null,
HttpStatusCode? expectedStatusCode = null,
- CT ct = default)
+ Ct ct = default)
{
var req = new HttpRequestMessage(method, url);
if (req.Content == null)
diff --git a/bff/test/Bff.Tests/TestInfra/BffHttpClient.cs b/bff/test/Bff.Tests/TestInfra/BffHttpClient.cs
index 6483082d4..eaa33a0c6 100644
--- a/bff/test/Bff.Tests/TestInfra/BffHttpClient.cs
+++ b/bff/test/Bff.Tests/TestInfra/BffHttpClient.cs
@@ -51,7 +51,7 @@ public class BffHttpClient(RedirectHandler handler, CookieContainer cookies, Ide
HttpContent? content = null,
HttpStatusCode? expectedStatusCode = null,
Dictionary? headers = null,
- CT ct = default) => CallBffHostApi(
+ Ct ct = default) => CallBffHostApi(
url: new Uri(path, UriKind.Relative),
method: method,
content: content,
@@ -65,7 +65,7 @@ public class BffHttpClient(RedirectHandler handler, CookieContainer cookies, Ide
HttpContent? content = null,
HttpStatusCode? expectedStatusCode = null,
Dictionary? headers = null,
- CT ct = default)
+ Ct ct = default)
{
method ??= HttpMethod.Get;
var req = new HttpRequestMessage(method, url);
diff --git a/bff/test/Bff.Tests/TestInfra/CookieHandler.cs b/bff/test/Bff.Tests/TestInfra/CookieHandler.cs
index 94fe8901f..391a9d4b2 100644
--- a/bff/test/Bff.Tests/TestInfra/CookieHandler.cs
+++ b/bff/test/Bff.Tests/TestInfra/CookieHandler.cs
@@ -9,7 +9,7 @@ namespace Duende.Bff.Tests.TestInfra;
public class CookieHandler(HttpMessageHandler innerHandler, CookieContainer cookieContainer)
: DelegatingHandler(innerHandler)
{
- protected override async Task SendAsync(HttpRequestMessage request, CT ct)
+ protected override async Task SendAsync(HttpRequestMessage request, Ct ct)
{
var requestUri = request.RequestUri;
var header = cookieContainer.GetCookieHeader(requestUri!);
diff --git a/bff/test/Bff.Tests/TestInfra/RedirectHandler.cs b/bff/test/Bff.Tests/TestInfra/RedirectHandler.cs
index feb390c3e..81207d738 100644
--- a/bff/test/Bff.Tests/TestInfra/RedirectHandler.cs
+++ b/bff/test/Bff.Tests/TestInfra/RedirectHandler.cs
@@ -12,7 +12,7 @@ public class RedirectHandler(WriteTestOutput output) : DelegatingHandler
public bool AutoFollowRedirects { get; set; } = true;
protected override async Task SendAsync(HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
var originalUri = request.RequestUri;
diff --git a/bff/test/Bff.Tests/TestInfra/RoutingMessageHandler.cs b/bff/test/Bff.Tests/TestInfra/RoutingMessageHandler.cs
index 708ba204a..9d1502f14 100644
--- a/bff/test/Bff.Tests/TestInfra/RoutingMessageHandler.cs
+++ b/bff/test/Bff.Tests/TestInfra/RoutingMessageHandler.cs
@@ -27,7 +27,7 @@ public class RoutingMessageHandler : HttpMessageHandler
protected override Task SendAsync(
HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
var host = $"{request.RequestUri?.Host}:{request.RequestUri?.Port}";
@@ -46,7 +46,7 @@ public class RoutingMessageHandler : HttpMessageHandler
{
internal Task SuppressedSend(
HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
Task t;
if (ExecutionContext.IsFlowSuppressed())
diff --git a/bff/test/Bff.Tests/TestInfra/SimulatedInternet.cs b/bff/test/Bff.Tests/TestInfra/SimulatedInternet.cs
index d7aa10cdb..316ba1999 100644
--- a/bff/test/Bff.Tests/TestInfra/SimulatedInternet.cs
+++ b/bff/test/Bff.Tests/TestInfra/SimulatedInternet.cs
@@ -59,7 +59,7 @@ public class SimulatedInternet : DelegatingHandler
protected override async Task SendAsync(
HttpRequestMessage request,
- CT ct)
+ Ct ct)
{
var requestId = Interlocked.Increment(ref _requestIdSeed);
diff --git a/bff/test/Bff.Tests/TestInfra/TestHybridCache.cs b/bff/test/Bff.Tests/TestInfra/TestHybridCache.cs
index 08a21cfbf..24ec0cd22 100644
--- a/bff/test/Bff.Tests/TestInfra/TestHybridCache.cs
+++ b/bff/test/Bff.Tests/TestInfra/TestHybridCache.cs
@@ -10,19 +10,19 @@ internal class TestHybridCache : HybridCache
{
private ConcurrentDictionary> _cache = new();
public override async ValueTask GetOrCreateAsync(string key, TState state,
- Func> factory, HybridCacheEntryOptions? options = null,
- IEnumerable? tags = null, CT ct = new CT()) => (T)await _cache.GetOrAdd(key, async _ => (await factory(state, ct))!);
+ Func> factory, HybridCacheEntryOptions? options = null,
+ IEnumerable? tags = null, Ct ct = new Ct()) => (T)await _cache.GetOrAdd(key, async _ => (await factory(state, ct))!);
public override ValueTask SetAsync(string key, T value, HybridCacheEntryOptions? options = null,
IEnumerable? tags = null,
- CT ct = new CT())
+ Ct ct = new Ct())
{
_cache[key] = new ValueTask
/// The cancellation token.
/// A conformance report containing the assessment results.
- public async Task GenerateReportAsync(CT ct = default)
+ public async Task GenerateReportAsync(Ct ct)
{
var clients = await _clientStore.GetAllClientsAsync(ct);
var clientList = clients.ToList();
@@ -91,7 +91,7 @@ internal class ConformanceReportAssessmentService
/// A profile result containing the assessment findings.
public async Task AssessProfileAsync(
ConformanceReportProfile profile,
- CT ct = default)
+ Ct ct)
{
var clients = await _clientStore.GetAllClientsAsync(ct);
var clientList = clients.ToList();
diff --git a/conformance-report/test/ConformanceReport.Tests/Endpoints/ConformanceEndpointTests.cs b/conformance-report/test/ConformanceReport.Tests/Endpoints/ConformanceEndpointTests.cs
index 1b6aaf762..50c8363c9 100644
--- a/conformance-report/test/ConformanceReport.Tests/Endpoints/ConformanceEndpointTests.cs
+++ b/conformance-report/test/ConformanceReport.Tests/Endpoints/ConformanceEndpointTests.cs
@@ -99,7 +99,7 @@ public class ConformanceReportEndpointTests
private sealed class InMemoryClientStore(IEnumerable clients) : IConformanceReportClientStore
{
- public Task> GetAllClientsAsync(CancellationToken ct = default)
+ public Task> GetAllClientsAsync(CancellationToken ct)
=> Task.FromResult(clients);
}
@@ -124,13 +124,14 @@ public class ConformanceReportEndpointTests
public class HtmlEndpointTests
{
+ private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
[Fact]
public async Task GetHtmlReportWhenEnabledReturnsHtmlContent()
{
var endpoint = CreateEndpoint();
var context = CreateHttpContext();
- var result = await endpoint.GetHtmlReportAsync(context);
+ var result = await endpoint.GetHtmlReportAsync(context, _ct);
_ = result.ShouldNotBeNull();
_ = result.ShouldBeOfType();
@@ -145,7 +146,7 @@ public class ConformanceReportEndpointTests
var endpoint = CreateEndpoint(options: options);
var context = CreateHttpContext();
- var result = await endpoint.GetHtmlReportAsync(context);
+ var result = await endpoint.GetHtmlReportAsync(context, _ct);
_ = result.ShouldBeOfType();
}
@@ -163,7 +164,7 @@ public class ConformanceReportEndpointTests
var endpoint = CreateEndpoint(licenseInfo: licenseInfo);
var context = CreateHttpContext();
- var result = await endpoint.GetHtmlReportAsync(context);
+ var result = await endpoint.GetHtmlReportAsync(context, _ct);
var contentResult = (Microsoft.AspNetCore.Http.HttpResults.ContentHttpResult)result;
var html = contentResult.ResponseContent!;
diff --git a/conformance-report/test/ConformanceReport.Tests/Services/ConformanceAssessmentServiceTests.cs b/conformance-report/test/ConformanceReport.Tests/Services/ConformanceAssessmentServiceTests.cs
index be744dd56..f0e34198d 100644
--- a/conformance-report/test/ConformanceReport.Tests/Services/ConformanceAssessmentServiceTests.cs
+++ b/conformance-report/test/ConformanceReport.Tests/Services/ConformanceAssessmentServiceTests.cs
@@ -104,7 +104,7 @@ public class ConformanceAssessmentServiceTests
private sealed class InMemoryClientStore(IEnumerable clients) : IConformanceReportClientStore
{
- public Task> GetAllClientsAsync(CancellationToken ct = default) => Task.FromResult(clients);
+ public Task> GetAllClientsAsync(CancellationToken ct) => Task.FromResult(clients);
}
private sealed class TestHttpContextAccessor : IHttpContextAccessor
@@ -123,12 +123,13 @@ public class ConformanceAssessmentServiceTests
public class ReportGenerationTests
{
+ private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
[Fact]
public async Task GenerateReportWithBothProfilesEnabledReturnsCompleteReport()
{
var service = CreateService();
- var report = await service.GenerateReportAsync();
+ var report = await service.GenerateReportAsync(_ct);
_ = report.ShouldNotBeNull();
_ = report.Profiles.ShouldNotBeNull();
@@ -142,7 +143,7 @@ public class ConformanceAssessmentServiceTests
var options = CreateDefaultOptions(enableOAuth21: true, enableFapi2: false);
var service = CreateService(options: options);
- var report = await service.GenerateReportAsync();
+ var report = await service.GenerateReportAsync(_ct);
_ = report.Profiles.OAuth21.ShouldNotBeNull();
report.Profiles.Fapi2Security.ShouldBeNull();
@@ -154,7 +155,7 @@ public class ConformanceAssessmentServiceTests
var options = CreateDefaultOptions(enableOAuth21: false, enableFapi2: true);
var service = CreateService(options: options);
- var report = await service.GenerateReportAsync();
+ var report = await service.GenerateReportAsync(_ct);
report.Profiles.OAuth21.ShouldBeNull();
_ = report.Profiles.Fapi2Security.ShouldNotBeNull();
@@ -166,7 +167,7 @@ public class ConformanceAssessmentServiceTests
var service = CreateService();
var beforeTime = DateTimeOffset.UtcNow;
- var report = await service.GenerateReportAsync();
+ var report = await service.GenerateReportAsync(_ct);
var afterTime = DateTimeOffset.UtcNow;
report.AssessedAt.ShouldBeGreaterThanOrEqualTo(beforeTime);
@@ -184,7 +185,7 @@ public class ConformanceAssessmentServiceTests
};
var service = CreateService(clients: clients);
- var report = await service.GenerateReportAsync();
+ var report = await service.GenerateReportAsync(_ct);
// Overall summary
report.OverallSummary.TotalClients.ShouldBe(3);
diff --git a/hosts_and_clients.props b/hosts_and_clients.props
index 65eaec4fc..12ee61826 100644
--- a/hosts_and_clients.props
+++ b/hosts_and_clients.props
@@ -21,7 +21,7 @@
true
-
+
diff --git a/identity-server/clients/src/ConsoleCode/SystemBrowser.cs b/identity-server/clients/src/ConsoleCode/SystemBrowser.cs
index 3e041c3b2..f636ccbf7 100644
--- a/identity-server/clients/src/ConsoleCode/SystemBrowser.cs
+++ b/identity-server/clients/src/ConsoleCode/SystemBrowser.cs
@@ -45,7 +45,7 @@ public class SystemBrowser : IBrowser
return port;
}
- public async Task InvokeAsync(BrowserOptions options, CT ct = default)
+ public async Task InvokeAsync(BrowserOptions options, Ct ct = default)
{
using (var listener = new LoopbackHttpListener(Port, _path))
{
diff --git a/identity-server/clients/src/ConsoleResourceIndicators/SystemBrowser.cs b/identity-server/clients/src/ConsoleResourceIndicators/SystemBrowser.cs
index 1effbbfc4..32c0af430 100644
--- a/identity-server/clients/src/ConsoleResourceIndicators/SystemBrowser.cs
+++ b/identity-server/clients/src/ConsoleResourceIndicators/SystemBrowser.cs
@@ -37,7 +37,7 @@ public class SystemBrowser : IBrowser
return port;
}
- public async Task InvokeAsync(BrowserOptions options, CT ct = default)
+ public async Task InvokeAsync(BrowserOptions options, Ct ct = default)
{
using (var listener = new LoopbackHttpListener(Port, _path))
{
diff --git a/identity-server/clients/src/MvcDPoP/TestHandler.cs b/identity-server/clients/src/MvcDPoP/TestHandler.cs
index cef0d4180..3f10942a9 100644
--- a/identity-server/clients/src/MvcDPoP/TestHandler.cs
+++ b/identity-server/clients/src/MvcDPoP/TestHandler.cs
@@ -8,7 +8,7 @@ public class TestHandler : DelegatingHandler
private readonly ILogger _logger;
public TestHandler(ILogger logger) => _logger = logger;
- protected override async Task SendAsync(HttpRequestMessage request, CT ct)
+ protected override async Task SendAsync(HttpRequestMessage request, Ct ct)
{
var response = await base.SendAsync(request, ct);
if (response.Headers.Contains("WWW-Authenticate"))
diff --git a/identity-server/clients/src/MvcJarJwt/ClientAssertionService.cs b/identity-server/clients/src/MvcJarJwt/ClientAssertionService.cs
index 05bd8331a..273ea9912 100644
--- a/identity-server/clients/src/MvcJarJwt/ClientAssertionService.cs
+++ b/identity-server/clients/src/MvcJarJwt/ClientAssertionService.cs
@@ -10,7 +10,7 @@ namespace MvcJarJwt;
public class ClientAssertionService(AssertionService assertionService) : IClientAssertionService
{
public Task GetClientAssertionAsync(ClientCredentialsClientName? clientName = null, TokenRequestParameters parameters = null,
- CT ct = new())
+ Ct ct = new())
{
var assertion = new ClientAssertion
{
diff --git a/identity-server/clients/src/MvcJarUriJwt/ClientAssertionService.cs b/identity-server/clients/src/MvcJarUriJwt/ClientAssertionService.cs
index 6ed71961c..587ddc2ef 100644
--- a/identity-server/clients/src/MvcJarUriJwt/ClientAssertionService.cs
+++ b/identity-server/clients/src/MvcJarUriJwt/ClientAssertionService.cs
@@ -11,7 +11,7 @@ public class ClientAssertionService(AssertionService assertionService) : IClient
{
public Task GetClientAssertionAsync(ClientCredentialsClientName? clientName = null,
TokenRequestParameters parameters = null,
- CT ct = new())
+ Ct ct = new())
{
var assertion = new ClientAssertion
{
diff --git a/identity-server/clients/src/Web/ClientAssertionService.cs b/identity-server/clients/src/Web/ClientAssertionService.cs
index 9338732ed..7efcbfe07 100644
--- a/identity-server/clients/src/Web/ClientAssertionService.cs
+++ b/identity-server/clients/src/Web/ClientAssertionService.cs
@@ -10,7 +10,7 @@ namespace Web;
public class ClientAssertionService(AssertionService assertionService) : IClientAssertionService
{
public Task GetClientAssertionAsync(ClientCredentialsClientName? clientName = null, TokenRequestParameters? parameters = null,
- CT ct = new CT())
+ Ct ct = new Ct())
{
var assertion = new ClientAssertion
{
diff --git a/identity-server/clients/src/WindowsConsoleSystemBrowser/CallbackManager.cs b/identity-server/clients/src/WindowsConsoleSystemBrowser/CallbackManager.cs
index 244ffd45d..df11bf1f1 100644
--- a/identity-server/clients/src/WindowsConsoleSystemBrowser/CallbackManager.cs
+++ b/identity-server/clients/src/WindowsConsoleSystemBrowser/CallbackManager.cs
@@ -26,9 +26,9 @@ internal class CallbackManager
}
}
- public async Task RunServer(CT? token = null)
+ public async Task RunServer(Ct? token = null)
{
- token = CT.None;
+ token = Ct.None;
await using var server = new NamedPipeServerStream(_name, PipeDirection.In);
await server.WaitForConnectionAsync(token.Value);
diff --git a/identity-server/hosts/EntityFramework10/TestOperationalStoreNotification.cs b/identity-server/hosts/EntityFramework10/TestOperationalStoreNotification.cs
index 36e79cdd5..11662adde 100644
--- a/identity-server/hosts/EntityFramework10/TestOperationalStoreNotification.cs
+++ b/identity-server/hosts/EntityFramework10/TestOperationalStoreNotification.cs
@@ -12,7 +12,7 @@ public class TestOperationalStoreNotification : IOperationalStoreNotification
{
public TestOperationalStoreNotification() => Console.WriteLine("ctor");
- public Task PersistedGrantsRemovedAsync(IEnumerable persistedGrants, CT ct = default)
+ public Task PersistedGrantsRemovedAsync(IEnumerable persistedGrants, Ct ct)
{
ArgumentNullException.ThrowIfNull(persistedGrants);
foreach (var grant in persistedGrants)
@@ -22,7 +22,7 @@ public class TestOperationalStoreNotification : IOperationalStoreNotification
return Task.CompletedTask;
}
- public Task DeviceCodesRemovedAsync(IEnumerable deviceCodes, CT ct = default)
+ public Task DeviceCodesRemovedAsync(IEnumerable deviceCodes, Ct ct)
{
ArgumentNullException.ThrowIfNull(deviceCodes);
foreach (var deviceCode in deviceCodes)
@@ -32,7 +32,7 @@ public class TestOperationalStoreNotification : IOperationalStoreNotification
return Task.CompletedTask;
}
- public Task ServerSideSessionsRemovedAsync(IEnumerable userSessions, CT ct = default)
+ public Task ServerSideSessionsRemovedAsync(IEnumerable userSessions, Ct ct)
{
ArgumentNullException.ThrowIfNull(userSessions);
foreach (var session in userSessions)
diff --git a/identity-server/hosts/Shared/Customization/CustomClientRegistrationProcessor.cs b/identity-server/hosts/Shared/Customization/CustomClientRegistrationProcessor.cs
index 91de8bacc..633170673 100644
--- a/identity-server/hosts/Shared/Customization/CustomClientRegistrationProcessor.cs
+++ b/identity-server/hosts/Shared/Customization/CustomClientRegistrationProcessor.cs
@@ -18,14 +18,14 @@ public sealed class CustomClientRegistrationProcessor(
IClientStore clientStore) : DynamicClientRegistrationRequestProcessor(options, dcrStore)
{
- protected override async Task AddClientId(DynamicClientRegistrationContext context)
+ protected override async Task AddClientId(DynamicClientRegistrationContext context, Ct ct)
{
if (context.Request.Extensions.TryGetValue("client_id", out var clientIdParameter))
{
var clientId = clientIdParameter.ToString();
if (clientId != null)
{
- var existingClient = await clientStore.FindClientByIdAsync(clientId);
+ var existingClient = await clientStore.FindClientByIdAsync(clientId, ct);
if (existingClient is not null)
{
return new DynamicClientRegistrationError(
@@ -40,7 +40,7 @@ public sealed class CustomClientRegistrationProcessor(
}
}
}
- return await base.AddClientId(context);
+ return await base.AddClientId(context, ct);
}
protected override async Task<(Secret, string)> GenerateSecret(DynamicClientRegistrationContext context)
diff --git a/identity-server/hosts/Shared/Customization/DiscoveryHealthCheck.cs b/identity-server/hosts/Shared/Customization/DiscoveryHealthCheck.cs
index f3acc850b..ea973bb8d 100644
--- a/identity-server/hosts/Shared/Customization/DiscoveryHealthCheck.cs
+++ b/identity-server/hosts/Shared/Customization/DiscoveryHealthCheck.cs
@@ -18,7 +18,7 @@ public class DiscoveryHealthCheck : IHealthCheck
_httpContextAccessor = httpContextAccessor;
}
- public async Task CheckHealthAsync(HealthCheckContext context, CT ct = default)
+ public async Task CheckHealthAsync(HealthCheckContext context, Ct ct = default)
{
ArgumentNullException.ThrowIfNull(context);
try
@@ -55,7 +55,7 @@ public class DiscoveryKeysHealthCheck : IHealthCheck
_httpContextAccessor = httpContextAccessor;
}
- public async Task CheckHealthAsync(HealthCheckContext context, CT ct = default)
+ public async Task CheckHealthAsync(HealthCheckContext context, Ct ct = default)
{
ArgumentNullException.ThrowIfNull(context);
try
diff --git a/identity-server/hosts/Shared/Customization/ExtensionGrantValidator.cs b/identity-server/hosts/Shared/Customization/ExtensionGrantValidator.cs
index 6a5b40c98..b3f818737 100644
--- a/identity-server/hosts/Shared/Customization/ExtensionGrantValidator.cs
+++ b/identity-server/hosts/Shared/Customization/ExtensionGrantValidator.cs
@@ -8,7 +8,7 @@ namespace Duende.IdentityServer.Hosts.Shared.Customization;
public class ExtensionGrantValidator : IExtensionGrantValidator
{
- public Task ValidateAsync(ExtensionGrantValidationContext context)
+ public Task ValidateAsync(ExtensionGrantValidationContext context, Ct ct)
{
ArgumentNullException.ThrowIfNull(context);
var credential = context.Request.Raw.Get("custom_credential");
diff --git a/identity-server/hosts/Shared/Customization/HostProfileService.cs b/identity-server/hosts/Shared/Customization/HostProfileService.cs
index ddc29152a..1508e0761 100644
--- a/identity-server/hosts/Shared/Customization/HostProfileService.cs
+++ b/identity-server/hosts/Shared/Customization/HostProfileService.cs
@@ -9,10 +9,10 @@ namespace Duende.IdentityServer.Hosts.Shared.Customization;
public class HostProfileService(TestUserStore users, ILogger logger) : TestUserProfileService(users, logger)
{
- public override async Task GetProfileDataAsync(ProfileDataRequestContext context)
+ public override async Task GetProfileDataAsync(ProfileDataRequestContext context, Ct ct)
{
ArgumentNullException.ThrowIfNull(context);
- await base.GetProfileDataAsync(context);
+ await base.GetProfileDataAsync(context, ct);
var transaction = context.RequestedResources.ParsedScopes.FirstOrDefault(x => x.ParsedName == "transaction");
if (transaction?.ParsedParameter != null)
diff --git a/identity-server/hosts/Shared/Customization/NoSubjectExtensionGrantValidator.cs b/identity-server/hosts/Shared/Customization/NoSubjectExtensionGrantValidator.cs
index 73ab53229..5261a641d 100644
--- a/identity-server/hosts/Shared/Customization/NoSubjectExtensionGrantValidator.cs
+++ b/identity-server/hosts/Shared/Customization/NoSubjectExtensionGrantValidator.cs
@@ -8,7 +8,7 @@ namespace Duende.IdentityServer.Hosts.Shared.Customization;
public class NoSubjectExtensionGrantValidator : IExtensionGrantValidator
{
- public Task ValidateAsync(ExtensionGrantValidationContext context)
+ public Task ValidateAsync(ExtensionGrantValidationContext context, Ct ct)
{
ArgumentNullException.ThrowIfNull(context);
var credential = context.Request.Raw.Get("custom_credential");
diff --git a/identity-server/hosts/Shared/Customization/ParameterizedScopeTokenRequestValidator.cs b/identity-server/hosts/Shared/Customization/ParameterizedScopeTokenRequestValidator.cs
index 695c56a72..d10677291 100644
--- a/identity-server/hosts/Shared/Customization/ParameterizedScopeTokenRequestValidator.cs
+++ b/identity-server/hosts/Shared/Customization/ParameterizedScopeTokenRequestValidator.cs
@@ -8,7 +8,7 @@ namespace Duende.IdentityServer.Hosts.Shared.Customization;
public class ParameterizedScopeTokenRequestValidator : ICustomTokenRequestValidator
{
- public Task ValidateAsync(CustomTokenRequestValidationContext context)
+ public Task ValidateAsync(CustomTokenRequestValidationContext context, Ct ct)
{
ArgumentNullException.ThrowIfNull(context);
var transaction = context.Result?.ValidatedRequest.ValidatedResources.ParsedScopes.FirstOrDefault(x => x.ParsedName == "transaction");
diff --git a/identity-server/hosts/UI/AspNetIdentity/Pages/Account/Login/Index.cshtml.cs b/identity-server/hosts/UI/AspNetIdentity/Pages/Account/Login/Index.cshtml.cs
index f8a42123a..7db379d98 100644
--- a/identity-server/hosts/UI/AspNetIdentity/Pages/Account/Login/Index.cshtml.cs
+++ b/identity-server/hosts/UI/AspNetIdentity/Pages/Account/Login/Index.cshtml.cs
@@ -50,7 +50,7 @@ public class Index : PageModel
public async Task OnGet(string? returnUrl)
{
- await BuildModelAsync(returnUrl);
+ await BuildModelAsync(returnUrl, HttpContext.RequestAborted);
if (View.IsExternalLoginOnly)
{
@@ -64,7 +64,7 @@ public class Index : PageModel
public async Task OnPost()
{
// check if we are in the context of an authorization request
- var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl);
+ var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl, HttpContext.RequestAborted);
// the user clicked the "cancel" button
if (Input.Button != "login")
@@ -77,7 +77,7 @@ public class Index : PageModel
// if the user cancels, send a result back into IdentityServer as if they
// denied the consent (even if this client does not require consent).
// this will send back an access denied OIDC error response to the client.
- await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
+ await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied, HttpContext.RequestAborted);
// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
if (context.IsNativeClient())
@@ -105,7 +105,7 @@ public class Index : PageModel
if (result.Succeeded)
{
var user = await _userManager.FindByNameAsync(Input.Username!);
- await _events.RaiseAsync(new UserLoginSuccessEvent(user!.UserName, user.Id, user.UserName, clientId: context?.Client.ClientId));
+ await _events.RaiseAsync(new UserLoginSuccessEvent(user!.UserName, user.Id, user.UserName, clientId: context?.Client.ClientId), HttpContext.RequestAborted);
Duende.IdentityServer.UI.Pages.Telemetry.Metrics.UserLogin(context?.Client.ClientId, IdentityServerConstants.LocalIdentityProvider);
if (context != null)
@@ -141,24 +141,24 @@ public class Index : PageModel
}
const string error = "invalid credentials";
- await _events.RaiseAsync(new UserLoginFailureEvent(Input.Username, error, clientId: context?.Client.ClientId));
+ await _events.RaiseAsync(new UserLoginFailureEvent(Input.Username, error, clientId: context?.Client.ClientId), HttpContext.RequestAborted);
Duende.IdentityServer.UI.Pages.Telemetry.Metrics.UserLoginFailure(context?.Client.ClientId, IdentityServerConstants.LocalIdentityProvider, error);
ModelState.AddModelError(string.Empty, LoginOptions.InvalidCredentialsErrorMessage);
}
// something went wrong, show form with error
- await BuildModelAsync(Input.ReturnUrl);
+ await BuildModelAsync(Input.ReturnUrl, HttpContext.RequestAborted);
return Page();
}
- private async Task BuildModelAsync(string? returnUrl)
+ private async Task BuildModelAsync(string? returnUrl, Ct ct)
{
Input = new InputModel
{
ReturnUrl = returnUrl
};
- var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
+ var context = await _interaction.GetAuthorizationContextAsync(returnUrl, HttpContext.RequestAborted);
if (context?.IdP != null)
{
var scheme = await _schemeProvider.GetSchemeAsync(context.IdP);
@@ -193,7 +193,7 @@ public class Index : PageModel
displayName: x.DisplayName ?? x.Name
)).ToList();
- var dynamicSchemes = (await _identityProviderStore.GetAllSchemeNamesAsync())
+ var dynamicSchemes = (await _identityProviderStore.GetAllSchemeNamesAsync(ct))
.Where(x => x.Enabled)
.Select(x => new ViewModel.ExternalProvider
(
diff --git a/identity-server/hosts/UI/AspNetIdentity/Pages/Account/Logout/Index.cshtml.cs b/identity-server/hosts/UI/AspNetIdentity/Pages/Account/Logout/Index.cshtml.cs
index e1da4efda..01f147b4b 100644
--- a/identity-server/hosts/UI/AspNetIdentity/Pages/Account/Logout/Index.cshtml.cs
+++ b/identity-server/hosts/UI/AspNetIdentity/Pages/Account/Logout/Index.cshtml.cs
@@ -47,7 +47,7 @@ public class Index : PageModel
}
else
{
- var context = await _interaction.GetLogoutContextAsync(LogoutId);
+ var context = await _interaction.GetLogoutContextAsync(LogoutId, HttpContext.RequestAborted);
if (context?.ShowSignoutPrompt == false)
{
// it's safe to automatically sign-out
@@ -72,7 +72,7 @@ public class Index : PageModel
// if there's no current logout context, we need to create one
// this captures necessary info from the current logged in user
// this can still return null if there is no context needed
- LogoutId ??= await _interaction.CreateLogoutContextAsync();
+ LogoutId ??= await _interaction.CreateLogoutContextAsync(HttpContext.RequestAborted);
// delete local authentication cookie
await _signInManager.SignOutAsync();
@@ -81,7 +81,7 @@ public class Index : PageModel
var idp = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;
// raise the logout event
- await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
+ await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()), HttpContext.RequestAborted);
Duende.IdentityServer.UI.Pages.Telemetry.Metrics.UserLogout(idp);
// if it's a local login we can ignore this workflow
diff --git a/identity-server/hosts/UI/AspNetIdentity/Pages/ExternalLogin/Callback.cshtml.cs b/identity-server/hosts/UI/AspNetIdentity/Pages/ExternalLogin/Callback.cshtml.cs
index fc5fda88b..532bbe71c 100644
--- a/identity-server/hosts/UI/AspNetIdentity/Pages/ExternalLogin/Callback.cshtml.cs
+++ b/identity-server/hosts/UI/AspNetIdentity/Pages/ExternalLogin/Callback.cshtml.cs
@@ -100,8 +100,8 @@ public class Callback : PageModel
var returnUrl = result.Properties.Items["returnUrl"] ?? "~/";
// check if external login is in the context of an OIDC request
- var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
- await _events.RaiseAsync(new UserLoginSuccessEvent(provider, providerUserId, user.Id, user.UserName, true, context?.Client.ClientId));
+ var context = await _interaction.GetAuthorizationContextAsync(returnUrl, HttpContext.RequestAborted);
+ await _events.RaiseAsync(new UserLoginSuccessEvent(provider, providerUserId, user.Id, user.UserName, true, context?.Client.ClientId), HttpContext.RequestAborted);
Duende.IdentityServer.UI.Pages.Telemetry.Metrics.UserLogin(context?.Client.ClientId, provider!);
if (context != null)
diff --git a/identity-server/hosts/UI/Main/Pages/Account/Create/Index.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Account/Create/Index.cshtml.cs
index bb3def5cf..02dfebe02 100644
--- a/identity-server/hosts/UI/Main/Pages/Account/Create/Index.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Account/Create/Index.cshtml.cs
@@ -39,7 +39,7 @@ public class Index : PageModel
public async Task OnPost()
{
// check if we are in the context of an authorization request
- var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl);
+ var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl, HttpContext.RequestAborted);
// the user clicked the "cancel" button
if (Input.Button != "create")
@@ -49,7 +49,7 @@ public class Index : PageModel
// if the user cancels, send a result back into IdentityServer as if they
// denied the consent (even if this client does not require consent).
// this will send back an access denied OIDC error response to the client.
- await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
+ await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied, HttpContext.RequestAborted);
// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
if (context.IsNativeClient())
diff --git a/identity-server/hosts/UI/Main/Pages/Account/Login/Index.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Account/Login/Index.cshtml.cs
index c0359e32e..e104d71a6 100644
--- a/identity-server/hosts/UI/Main/Pages/Account/Login/Index.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Account/Login/Index.cshtml.cs
@@ -46,7 +46,7 @@ public class Index : PageModel
public async Task OnGet(string? returnUrl)
{
- await BuildModelAsync(returnUrl);
+ await BuildModelAsync(returnUrl, HttpContext.RequestAborted);
if (View.IsExternalLoginOnly)
{
@@ -60,7 +60,7 @@ public class Index : PageModel
public async Task OnPost()
{
// check if we are in the context of an authorization request
- var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl);
+ var context = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl, HttpContext.RequestAborted);
// the user clicked the "cancel" button
if (Input.Button != "login")
@@ -73,7 +73,7 @@ public class Index : PageModel
// if the user cancels, send a result back into IdentityServer as if they
// denied the consent (even if this client does not require consent).
// this will send back an access denied OIDC error response to the client.
- await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied);
+ await _interaction.DenyAuthorizationAsync(context, AuthorizationError.AccessDenied, HttpContext.RequestAborted);
// we can trust model.ReturnUrl since GetAuthorizationContextAsync returned non-null
if (context.IsNativeClient())
@@ -98,7 +98,7 @@ public class Index : PageModel
if (_users.ValidateCredentials(Input.Username, Input.Password))
{
var user = _users.FindByUsername(Input.Username);
- await _events.RaiseAsync(new UserLoginSuccessEvent(user.Username, user.SubjectId, user.Username, clientId: context?.Client.ClientId));
+ await _events.RaiseAsync(new UserLoginSuccessEvent(user.Username, user.SubjectId, user.Username, clientId: context?.Client.ClientId), HttpContext.RequestAborted);
Telemetry.Metrics.UserLogin(context?.Client.ClientId, IdentityServerConstants.LocalIdentityProvider);
// only set explicit expiration here if user chooses "remember me".
@@ -151,24 +151,24 @@ public class Index : PageModel
}
const string error = "invalid credentials";
- await _events.RaiseAsync(new UserLoginFailureEvent(Input.Username, error, clientId: context?.Client.ClientId));
+ await _events.RaiseAsync(new UserLoginFailureEvent(Input.Username, error, clientId: context?.Client.ClientId), HttpContext.RequestAborted);
Telemetry.Metrics.UserLoginFailure(context?.Client.ClientId, IdentityServerConstants.LocalIdentityProvider, error);
ModelState.AddModelError(string.Empty, LoginOptions.InvalidCredentialsErrorMessage);
}
// something went wrong, show form with error
- await BuildModelAsync(Input.ReturnUrl);
+ await BuildModelAsync(Input.ReturnUrl, HttpContext.RequestAborted);
return Page();
}
- private async Task BuildModelAsync(string? returnUrl)
+ private async Task BuildModelAsync(string? returnUrl, Ct ct)
{
Input = new InputModel
{
ReturnUrl = returnUrl
};
- var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
+ var context = await _interaction.GetAuthorizationContextAsync(returnUrl, HttpContext.RequestAborted);
if (context?.IdP != null)
{
var scheme = await _schemeProvider.GetSchemeAsync(context.IdP);
@@ -203,7 +203,7 @@ public class Index : PageModel
displayName: x.DisplayName ?? x.Name
)).ToList();
- var dynamicSchemes = (await _identityProviderStore.GetAllSchemeNamesAsync())
+ var dynamicSchemes = (await _identityProviderStore.GetAllSchemeNamesAsync(ct))
.Where(x => x.Enabled)
.Select(x => new ViewModel.ExternalProvider
(
diff --git a/identity-server/hosts/UI/Main/Pages/Account/Logout/Index.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Account/Logout/Index.cshtml.cs
index c4c228f90..69ffbb118 100644
--- a/identity-server/hosts/UI/Main/Pages/Account/Logout/Index.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Account/Logout/Index.cshtml.cs
@@ -41,7 +41,7 @@ public class Index : PageModel
}
else
{
- var context = await _interaction.GetLogoutContextAsync(LogoutId);
+ var context = await _interaction.GetLogoutContextAsync(LogoutId, HttpContext.RequestAborted);
if (context?.ShowSignoutPrompt == false)
{
// it's safe to automatically sign-out
@@ -66,7 +66,7 @@ public class Index : PageModel
// if there's no current logout context, we need to create one
// this captures necessary info from the current logged in user
// this can still return null if there is no context needed
- LogoutId ??= await _interaction.CreateLogoutContextAsync();
+ LogoutId ??= await _interaction.CreateLogoutContextAsync(HttpContext.RequestAborted);
// delete local authentication cookie
await HttpContext.SignOutAsync();
@@ -75,7 +75,7 @@ public class Index : PageModel
var idp = User.FindFirst(JwtClaimTypes.IdentityProvider)?.Value;
// raise the logout event
- await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
+ await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()), HttpContext.RequestAborted);
Telemetry.Metrics.UserLogout(idp);
// if it's a local login we can ignore this workflow
diff --git a/identity-server/hosts/UI/Main/Pages/Account/Logout/LoggedOut.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Account/Logout/LoggedOut.cshtml.cs
index 8b88394d8..deee46f99 100644
--- a/identity-server/hosts/UI/Main/Pages/Account/Logout/LoggedOut.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Account/Logout/LoggedOut.cshtml.cs
@@ -20,7 +20,7 @@ public class LoggedOut : PageModel
public async Task OnGet(string? logoutId)
{
// get context information (client name, post logout redirect URI and iframe for federated signout)
- var logout = await _interactionService.GetLogoutContextAsync(logoutId);
+ var logout = await _interactionService.GetLogoutContextAsync(logoutId, HttpContext.RequestAborted);
View = new LoggedOutViewModel
{
diff --git a/identity-server/hosts/UI/Main/Pages/Ciba/All.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Ciba/All.cshtml.cs
index bda76398a..f9a31d189 100644
--- a/identity-server/hosts/UI/Main/Pages/Ciba/All.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Ciba/All.cshtml.cs
@@ -18,5 +18,5 @@ public class AllModel : PageModel
public AllModel(IBackchannelAuthenticationInteractionService backchannelAuthenticationInteractionService) => _backchannelAuthenticationInteraction = backchannelAuthenticationInteractionService;
- public async Task OnGet() => Logins = await _backchannelAuthenticationInteraction.GetPendingLoginRequestsForCurrentUserAsync();
+ public async Task OnGet() => Logins = await _backchannelAuthenticationInteraction.GetPendingLoginRequestsForCurrentUserAsync(HttpContext.RequestAborted);
}
diff --git a/identity-server/hosts/UI/Main/Pages/Ciba/Consent.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Ciba/Consent.cshtml.cs
index 04978b327..a065336ac 100644
--- a/identity-server/hosts/UI/Main/Pages/Ciba/Consent.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Ciba/Consent.cshtml.cs
@@ -53,7 +53,7 @@ public class Consent : PageModel
public async Task OnPost()
{
// validate return url is still valid
- var request = await _interaction.GetLoginRequestByInternalIdAsync(Input.Id ?? throw new ArgumentNullException(nameof(Input.Id)));
+ var request = await _interaction.GetLoginRequestByInternalIdAsync(Input.Id ?? throw new ArgumentNullException(nameof(Input.Id)), HttpContext.RequestAborted);
if (request == null || request.Subject.GetSubjectId() != User.GetSubjectId())
{
_logger.InvalidId(Input.Id);
@@ -68,7 +68,7 @@ public class Consent : PageModel
result = new CompleteBackchannelLoginRequest(Input.Id);
// emit event
- await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues));
+ await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues), HttpContext.RequestAborted);
Telemetry.Metrics.ConsentDenied(request.Client.ClientId, request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName));
}
// user clicked 'yes' - validate the data
@@ -90,7 +90,7 @@ public class Consent : PageModel
};
// emit event
- await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, result.ScopesValuesConsented, false));
+ await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, result.ScopesValuesConsented, false), HttpContext.RequestAborted);
Telemetry.Metrics.ConsentGranted(request.Client.ClientId, result.ScopesValuesConsented, false);
var denied = request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName).Except(result.ScopesValuesConsented);
Telemetry.Metrics.ConsentDenied(request.Client.ClientId, denied);
@@ -108,7 +108,7 @@ public class Consent : PageModel
if (result != null)
{
// communicate outcome of consent back to identityserver
- await _interaction.CompleteLoginRequestAsync(result);
+ await _interaction.CompleteLoginRequestAsync(result, HttpContext.RequestAborted);
return RedirectToPage("/Ciba/All");
}
@@ -125,7 +125,7 @@ public class Consent : PageModel
{
ArgumentNullException.ThrowIfNull(id);
- var request = await _interaction.GetLoginRequestByInternalIdAsync(id);
+ var request = await _interaction.GetLoginRequestByInternalIdAsync(id, HttpContext.RequestAborted);
if (request != null && request.Subject.GetSubjectId() == User.GetSubjectId())
{
View = CreateConsentViewModel(request);
diff --git a/identity-server/hosts/UI/Main/Pages/Ciba/Index.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Ciba/Index.cshtml.cs
index c178dbf1d..91d3bde03 100644
--- a/identity-server/hosts/UI/Main/Pages/Ciba/Index.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Ciba/Index.cshtml.cs
@@ -26,7 +26,7 @@ public class IndexModel : PageModel
public async Task OnGet(string id)
{
- var result = await _backchannelAuthenticationInteraction.GetLoginRequestByInternalIdAsync(id);
+ var result = await _backchannelAuthenticationInteraction.GetLoginRequestByInternalIdAsync(id, HttpContext.RequestAborted);
if (result == null)
{
_logger.InvalidBackchannelLoginId(id);
diff --git a/identity-server/hosts/UI/Main/Pages/Consent/Index.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Consent/Index.cshtml.cs
index f18aee4f1..9691ca3d9 100644
--- a/identity-server/hosts/UI/Main/Pages/Consent/Index.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Consent/Index.cshtml.cs
@@ -54,7 +54,7 @@ public class Index : PageModel
public async Task OnPost()
{
// validate return url is still valid
- var request = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl);
+ var request = await _interaction.GetAuthorizationContextAsync(Input.ReturnUrl, HttpContext.RequestAborted);
if (request == null)
{
return RedirectToPage("/Home/Error/Index");
@@ -68,7 +68,7 @@ public class Index : PageModel
grantedConsent = new ConsentResponse { Error = AuthorizationError.AccessDenied };
// emit event
- await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues));
+ await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues), HttpContext.RequestAborted);
Telemetry.Metrics.ConsentDenied(request.Client.ClientId, request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName));
}
// user clicked 'yes' - validate the data
@@ -91,7 +91,7 @@ public class Index : PageModel
};
// emit event
- await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent));
+ await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent), HttpContext.RequestAborted);
Telemetry.Metrics.ConsentGranted(request.Client.ClientId, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent);
var denied = request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName).Except(grantedConsent.ScopesValuesConsented);
Telemetry.Metrics.ConsentDenied(request.Client.ClientId, denied);
@@ -111,7 +111,7 @@ public class Index : PageModel
ArgumentNullException.ThrowIfNull(Input.ReturnUrl, nameof(Input.ReturnUrl));
// communicate outcome of consent back to identityserver
- await _interaction.GrantConsentAsync(request, grantedConsent);
+ await _interaction.GrantConsentAsync(request, grantedConsent, HttpContext.RequestAborted);
// redirect back to authorization endpoint
if (request.IsNativeClient() == true)
@@ -136,7 +136,7 @@ public class Index : PageModel
{
ArgumentNullException.ThrowIfNull(returnUrl);
- var request = await _interaction.GetAuthorizationContextAsync(returnUrl);
+ var request = await _interaction.GetAuthorizationContextAsync(returnUrl, HttpContext.RequestAborted);
if (request != null)
{
View = CreateConsentViewModel(request);
diff --git a/identity-server/hosts/UI/Main/Pages/Device/Index.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Device/Index.cshtml.cs
index c87c5713d..1ba384965 100644
--- a/identity-server/hosts/UI/Main/Pages/Device/Index.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Device/Index.cshtml.cs
@@ -61,7 +61,7 @@ public class Index : PageModel
public async Task OnPost()
{
- var request = await _interaction.GetAuthorizationContextAsync(Input.UserCode ?? throw new ArgumentNullException(nameof(Input.UserCode)));
+ var request = await _interaction.GetAuthorizationContextAsync(Input.UserCode ?? throw new ArgumentNullException(nameof(Input.UserCode)), HttpContext.RequestAborted);
if (request == null)
{
return RedirectToPage("/Home/Error/Index");
@@ -78,7 +78,7 @@ public class Index : PageModel
};
// emit event
- await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues));
+ await _events.RaiseAsync(new ConsentDeniedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues), HttpContext.RequestAborted);
Telemetry.Metrics.ConsentDenied(request.Client.ClientId, request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName));
}
// user clicked 'yes' - validate the data
@@ -101,7 +101,7 @@ public class Index : PageModel
};
// emit event
- await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent));
+ await _events.RaiseAsync(new ConsentGrantedEvent(User.GetSubjectId(), request.Client.ClientId, request.ValidatedResources.RawScopeValues, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent), HttpContext.RequestAborted);
Telemetry.Metrics.ConsentGranted(request.Client.ClientId, grantedConsent.ScopesValuesConsented, grantedConsent.RememberConsent);
var denied = request.ValidatedResources.ParsedScopes.Select(s => s.ParsedName).Except(grantedConsent.ScopesValuesConsented);
Telemetry.Metrics.ConsentDenied(request.Client.ClientId, denied);
@@ -119,7 +119,7 @@ public class Index : PageModel
if (grantedConsent != null)
{
// communicate outcome of consent back to identityserver
- await _interaction.HandleRequestAsync(Input.UserCode, grantedConsent);
+ await _interaction.HandleRequestAsync(Input.UserCode, grantedConsent, HttpContext.RequestAborted);
// indicate that's it ok to redirect back to authorization endpoint
return RedirectToPage("/Device/Success");
@@ -136,7 +136,7 @@ public class Index : PageModel
private async Task SetViewModelAsync(string userCode)
{
- var request = await _interaction.GetAuthorizationContextAsync(userCode);
+ var request = await _interaction.GetAuthorizationContextAsync(userCode, HttpContext.RequestAborted);
if (request != null)
{
View = CreateConsentViewModel(request);
diff --git a/identity-server/hosts/UI/Main/Pages/ExternalLogin/Callback.cshtml.cs b/identity-server/hosts/UI/Main/Pages/ExternalLogin/Callback.cshtml.cs
index 11120fe19..1495be559 100644
--- a/identity-server/hosts/UI/Main/Pages/ExternalLogin/Callback.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/ExternalLogin/Callback.cshtml.cs
@@ -103,8 +103,8 @@ public class Callback : PageModel
var returnUrl = result.Properties.Items["returnUrl"] ?? "~/";
// check if external login is in the context of an OIDC request
- var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
- await _events.RaiseAsync(new UserLoginSuccessEvent(provider, providerUserId, user.SubjectId, user.Username, true, context?.Client.ClientId));
+ var context = await _interaction.GetAuthorizationContextAsync(returnUrl, HttpContext.RequestAborted);
+ await _events.RaiseAsync(new UserLoginSuccessEvent(provider, providerUserId, user.SubjectId, user.Username, true, context?.Client.ClientId), HttpContext.RequestAborted);
Telemetry.Metrics.UserLogin(context?.Client.ClientId, provider!);
if (context != null)
diff --git a/identity-server/hosts/UI/Main/Pages/Grants/Index.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Grants/Index.cshtml.cs
index 58e782144..ddc704220 100644
--- a/identity-server/hosts/UI/Main/Pages/Grants/Index.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Grants/Index.cshtml.cs
@@ -35,15 +35,15 @@ public class Index : PageModel
public async Task OnGet()
{
- var grants = await _interaction.GetAllUserGrantsAsync();
+ var grants = await _interaction.GetAllUserGrantsAsync(HttpContext.RequestAborted);
var list = new List();
foreach (var grant in grants)
{
- var client = await _clients.FindClientByIdAsync(grant.ClientId);
+ var client = await _clients.FindClientByIdAsync(grant.ClientId, HttpContext.RequestAborted);
if (client != null)
{
- var resources = await _resources.FindResourcesByScopeAsync(grant.Scopes);
+ var resources = await _resources.FindResourcesByScopeAsync(grant.Scopes, HttpContext.RequestAborted);
var item = new GrantViewModel()
{
@@ -73,8 +73,8 @@ public class Index : PageModel
public async Task OnPost()
{
- await _interaction.RevokeUserConsentAsync(ClientId);
- await _events.RaiseAsync(new GrantsRevokedEvent(User.GetSubjectId(), ClientId));
+ await _interaction.RevokeUserConsentAsync(ClientId, HttpContext.RequestAborted);
+ await _events.RaiseAsync(new GrantsRevokedEvent(User.GetSubjectId(), ClientId), HttpContext.RequestAborted);
Telemetry.Metrics.GrantsRevoked(ClientId);
return RedirectToPage("/Grants/Index");
diff --git a/identity-server/hosts/UI/Main/Pages/Home/Error/Index.cshtml.cs b/identity-server/hosts/UI/Main/Pages/Home/Error/Index.cshtml.cs
index 592ab5216..21324614f 100644
--- a/identity-server/hosts/UI/Main/Pages/Home/Error/Index.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/Home/Error/Index.cshtml.cs
@@ -25,7 +25,7 @@ public class Index : PageModel
public async Task OnGet(string? errorId)
{
// retrieve error details from identityserver
- var message = await _interaction.GetErrorContextAsync(errorId);
+ var message = await _interaction.GetErrorContextAsync(errorId, HttpContext.RequestAborted);
if (message != null)
{
View.Error = message;
diff --git a/identity-server/hosts/UI/Main/Pages/ServerSideSessions/Index.cshtml.cs b/identity-server/hosts/UI/Main/Pages/ServerSideSessions/Index.cshtml.cs
index 54793b242..ef0025370 100644
--- a/identity-server/hosts/UI/Main/Pages/ServerSideSessions/Index.cshtml.cs
+++ b/identity-server/hosts/UI/Main/Pages/ServerSideSessions/Index.cshtml.cs
@@ -49,7 +49,7 @@ public class IndexModel : PageModel
DisplayName = DisplayNameFilter,
SessionId = SessionIdFilter,
SubjectId = SubjectIdFilter
- });
+ }, HttpContext.RequestAborted);
}
return Page();
@@ -71,7 +71,7 @@ public class IndexModel : PageModel
await _sessionManagementService.RemoveSessionsAsync(new RemoveSessionsContext
{
SessionId = SessionId,
- });
+ }, HttpContext.RequestAborted);
return RedirectToPage("/ServerSideSessions/Index", new { Token, DisplayNameFilter, SessionIdFilter, SubjectIdFilter, Prev });
}
diff --git a/identity-server/perf/IdentityServer.PerfTests/Services/DefaultTokenServiceTest.cs b/identity-server/perf/IdentityServer.PerfTests/Services/DefaultTokenServiceTest.cs
index ceda0f167..dfaad3882 100644
--- a/identity-server/perf/IdentityServer.PerfTests/Services/DefaultTokenServiceTest.cs
+++ b/identity-server/perf/IdentityServer.PerfTests/Services/DefaultTokenServiceTest.cs
@@ -60,8 +60,8 @@ public class DefaultTokenServiceTest : TestBase
Client = _client,
},
ValidatedResources = new ResourceValidationResult(new Resources() { ApiScopes = new[] { _scope } }),
- });
- var jwt = await _subject.CreateSecurityTokenAsync(token);
+ }, default);
+ var jwt = await _subject.CreateSecurityTokenAsync(token, default);
//System.Console.WriteLine(jwt);
}
}
diff --git a/identity-server/src/AspNetIdentity/ConfigureSecurityStampValidatorOptions.cs b/identity-server/src/AspNetIdentity/ConfigureSecurityStampValidatorOptions.cs
index a400ca7f6..1051855f4 100644
--- a/identity-server/src/AspNetIdentity/ConfigureSecurityStampValidatorOptions.cs
+++ b/identity-server/src/AspNetIdentity/ConfigureSecurityStampValidatorOptions.cs
@@ -1,12 +1,14 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Options;
namespace Duende.IdentityServer.AspNetIdentity;
-public class ConfigureSecurityStampValidatorOptions(ISessionClaimsFilter sessionClaimsFilter) : IConfigureOptions
+public class ConfigureSecurityStampValidatorOptions(ISessionClaimsFilter sessionClaimsFilter, IHttpContextAccessor httpContextAccessor) : IConfigureOptions
{
- public void Configure(SecurityStampValidatorOptions options) => options.OnRefreshingPrincipal = async context => await SecurityStampValidatorCallback.UpdatePrincipal(context, sessionClaimsFilter);
+ public void Configure(SecurityStampValidatorOptions options) => options.OnRefreshingPrincipal = async context =>
+ await SecurityStampValidatorCallback.UpdatePrincipal(context, sessionClaimsFilter, httpContextAccessor.HttpContext?.RequestAborted ?? default);
}
diff --git a/identity-server/src/AspNetIdentity/DefaultSessionClaimsFilter.cs b/identity-server/src/AspNetIdentity/DefaultSessionClaimsFilter.cs
index 0845f2e23..43a0d3424 100644
--- a/identity-server/src/AspNetIdentity/DefaultSessionClaimsFilter.cs
+++ b/identity-server/src/AspNetIdentity/DefaultSessionClaimsFilter.cs
@@ -9,7 +9,7 @@ namespace Duende.IdentityServer.AspNetIdentity;
public class DefaultSessionClaimsFilter : ISessionClaimsFilter
{
///
- public Task> FilterToSessionClaimsAsync(SecurityStampRefreshingPrincipalContext context)
+ public Task> FilterToSessionClaimsAsync(SecurityStampRefreshingPrincipalContext context, Ct _)
{
var newClaimTypes = context.NewPrincipal.Claims.Select(x => x.Type).ToArray();
var currentClaimsToKeep = context.CurrentPrincipal.Claims.Where(x => !newClaimTypes.Contains(x.Type)).ToArray();
diff --git a/identity-server/src/AspNetIdentity/ISessionClaimsFilter.cs b/identity-server/src/AspNetIdentity/ISessionClaimsFilter.cs
index 898871a0a..b2fa59acf 100644
--- a/identity-server/src/AspNetIdentity/ISessionClaimsFilter.cs
+++ b/identity-server/src/AspNetIdentity/ISessionClaimsFilter.cs
@@ -16,6 +16,7 @@ public interface ISessionClaimsFilter
///
/// The SecurityStampRefreshingPrincipalContext
/// in the call to .
+ /// The cancellation token.
/// The claims of the ClaimsPrincipal which should be persisted for the session.
- public Task> FilterToSessionClaimsAsync(SecurityStampRefreshingPrincipalContext context);
+ public Task> FilterToSessionClaimsAsync(SecurityStampRefreshingPrincipalContext context, Ct ct);
}
diff --git a/identity-server/src/AspNetIdentity/ProfileService.cs b/identity-server/src/AspNetIdentity/ProfileService.cs
index b8dc6638a..834f28650 100644
--- a/identity-server/src/AspNetIdentity/ProfileService.cs
+++ b/identity-server/src/AspNetIdentity/ProfileService.cs
@@ -65,8 +65,9 @@ public class ProfileService : IProfileService
/// This method is called whenever claims about the user are requested (e.g. during token creation or via the userinfo endpoint)
///
/// The context.
+ /// The cancellation token.
///
- public virtual async Task GetProfileDataAsync(ProfileDataRequestContext context)
+ public virtual async Task GetProfileDataAsync(ProfileDataRequestContext context, Ct ct)
{
var sub = context.Subject?.GetSubjectId();
if (sub == null)
@@ -125,8 +126,9 @@ public class ProfileService : IProfileService
/// (e.g. during token issuance or validation).
///
/// The context.
+ /// The cancellation token.
///
- public virtual async Task IsActiveAsync(IsActiveContext context)
+ public virtual async Task IsActiveAsync(IsActiveContext context, Ct ct)
{
var sub = context.Subject?.GetSubjectId();
if (sub == null)
diff --git a/identity-server/src/AspNetIdentity/ResourceOwnerPasswordValidator.cs b/identity-server/src/AspNetIdentity/ResourceOwnerPasswordValidator.cs
index e79c01f96..6d686f11d 100644
--- a/identity-server/src/AspNetIdentity/ResourceOwnerPasswordValidator.cs
+++ b/identity-server/src/AspNetIdentity/ResourceOwnerPasswordValidator.cs
@@ -38,12 +38,8 @@ public class ResourceOwnerPasswordValidator : IResourceOwnerPasswordValid
_logger = logger;
}
- ///
- /// Validates the resource owner password credential
- ///
- /// The context.
- ///
- public virtual async Task ValidateAsync(ResourceOwnerPasswordValidationContext context)
+ ///
+ public virtual async Task ValidateAsync(ResourceOwnerPasswordValidationContext context, Ct ct)
{
var user = await _userManager.FindByNameAsync(context.UserName);
if (user != null)
diff --git a/identity-server/src/AspNetIdentity/SecurityStampValidatorCallback.cs b/identity-server/src/AspNetIdentity/SecurityStampValidatorCallback.cs
index aeb823bc3..be581ce78 100644
--- a/identity-server/src/AspNetIdentity/SecurityStampValidatorCallback.cs
+++ b/identity-server/src/AspNetIdentity/SecurityStampValidatorCallback.cs
@@ -18,15 +18,16 @@ public static class SecurityStampValidatorCallback
/// Instance of session claims filter used to filter the claims from the ClaimsPrincipal to
/// those that are session claims which are not persisted by ASP.NET Identity and would otherwise bee lost when the principal
/// is updated.
+ /// The cancellation token.
///
- public static async Task UpdatePrincipal(SecurityStampRefreshingPrincipalContext context, ISessionClaimsFilter sessionClaimsFilter)
+ public static async Task UpdatePrincipal(SecurityStampRefreshingPrincipalContext context, ISessionClaimsFilter sessionClaimsFilter, Ct ct)
{
if (context.NewPrincipal == null || !context.NewPrincipal.Identities.Any())
{
return;
}
- var currentClaimsToKeep = await sessionClaimsFilter.FilterToSessionClaimsAsync(context);
+ var currentClaimsToKeep = await sessionClaimsFilter.FilterToSessionClaimsAsync(context, ct);
var id = context.NewPrincipal.Identities.First();
id.AddClaims(currentClaimsToKeep);
diff --git a/identity-server/src/Configuration.EntityFramework/ClientConfigurationStore.cs b/identity-server/src/Configuration.EntityFramework/ClientConfigurationStore.cs
index fd733c96d..0319cdd61 100644
--- a/identity-server/src/Configuration.EntityFramework/ClientConfigurationStore.cs
+++ b/identity-server/src/Configuration.EntityFramework/ClientConfigurationStore.cs
@@ -5,7 +5,6 @@
using Duende.IdentityServer.EntityFramework.Interfaces;
using Duende.IdentityServer.EntityFramework.Mappers;
using Duende.IdentityServer.Models;
-using Duende.IdentityServer.Services;
using Microsoft.Extensions.Logging;
namespace Duende.IdentityServer.Configuration;
@@ -21,11 +20,6 @@ public class ClientConfigurationStore : IClientConfigurationStore
///
protected readonly IConfigurationDbContext DbContext;
- ///
- /// The CancellationToken provider.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -37,19 +31,17 @@ public class ClientConfigurationStore : IClientConfigurationStore
///
public ClientConfigurationStore(
IConfigurationDbContext dbContext,
- ICancellationTokenProvider cancellationTokenProvider,
ILogger logger)
{
DbContext = dbContext;
- CancellationTokenProvider = cancellationTokenProvider;
Logger = logger;
}
///
- public async Task AddAsync(Client client)
+ public async Task AddAsync(Client client, Ct ct)
{
Logger.LogDebug("Adding client {ClientId} to configuration store", client.ClientId);
DbContext.Clients.Add(client.ToEntity());
- await DbContext.SaveChangesAsync(CancellationTokenProvider.CancellationToken);
+ await DbContext.SaveChangesAsync(ct);
}
}
diff --git a/identity-server/src/Configuration.EntityFramework/DefaultCancellationTokenProvider.cs b/identity-server/src/Configuration.EntityFramework/DefaultCancellationTokenProvider.cs
deleted file mode 100644
index 582bf8c3a..000000000
--- a/identity-server/src/Configuration.EntityFramework/DefaultCancellationTokenProvider.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) Duende Software. All rights reserved.
-// See LICENSE in the project root for license information.
-
-
-using Duende.IdentityServer.Services;
-using Microsoft.AspNetCore.Http;
-
-namespace Duende.IdentityServer.Configuration.EntityFramework;
-
-///
-/// Provides cancellation tokens based on the incoming http request
-///
-#pragma warning disable CA1812 // This class is not instantiated directly, but rather used by the DI container
-internal sealed class DefaultCancellationTokenProvider : ICancellationTokenProvider
-#pragma warning restore CA1812
-{
- private readonly IHttpContextAccessor _httpContextAccessor;
-
- ///
- /// Constructor
- ///
- ///
- public DefaultCancellationTokenProvider(IHttpContextAccessor httpContextAccessor) => _httpContextAccessor = httpContextAccessor;
-
- ///
- /// Provides access to the cancellation token from the http context
- ///
- public CancellationToken CancellationToken => _httpContextAccessor.HttpContext?.RequestAborted ?? CancellationToken.None;
-}
diff --git a/identity-server/src/Configuration.EntityFramework/ServiceCollectionExtensions.cs b/identity-server/src/Configuration.EntityFramework/ServiceCollectionExtensions.cs
index 61c9089a4..36d826fb0 100644
--- a/identity-server/src/Configuration.EntityFramework/ServiceCollectionExtensions.cs
+++ b/identity-server/src/Configuration.EntityFramework/ServiceCollectionExtensions.cs
@@ -2,7 +2,6 @@
// See LICENSE in the project root for license information.
-using Duende.IdentityServer.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -22,7 +21,6 @@ public static class ServiceCollectionExtensions
///
public static IServiceCollection AddClientConfigurationStore(this IdentityServerConfigurationBuilder builder)
{
- builder.Services.TryAddTransient();
builder.Services.TryAddSingleton();
return builder.Services.AddTransient();
}
diff --git a/identity-server/src/Configuration/Endpoints/DynamicClientRegistrationEndpoint.cs b/identity-server/src/Configuration/Endpoints/DynamicClientRegistrationEndpoint.cs
index fb22c894f..1da4ab7b2 100644
--- a/identity-server/src/Configuration/Endpoints/DynamicClientRegistrationEndpoint.cs
+++ b/identity-server/src/Configuration/Endpoints/DynamicClientRegistrationEndpoint.cs
@@ -47,7 +47,7 @@ public class DynamicClientRegistrationEndpoint
// Check content type
if (!HasCorrectContentType(httpContext.Request))
{
- await _responseGenerator.WriteContentTypeError(httpContext);
+ await _responseGenerator.WriteContentTypeError(httpContext, httpContext.RequestAborted);
return;
}
@@ -55,29 +55,29 @@ public class DynamicClientRegistrationEndpoint
var request = await TryParseAsync(httpContext.Request);
if (request == null)
{
- await _responseGenerator.WriteBadRequestError(httpContext);
+ await _responseGenerator.WriteBadRequestError(httpContext, httpContext.RequestAborted);
return;
}
var dcrContext = new DynamicClientRegistrationContext(request, httpContext.User);
// Validate request values
- var validationResult = await _validator.ValidateAsync(dcrContext);
+ var validationResult = await _validator.ValidateAsync(dcrContext, httpContext.RequestAborted);
if (validationResult is DynamicClientRegistrationError validationError)
{
- await _responseGenerator.WriteError(httpContext, validationError);
+ await _responseGenerator.WriteError(httpContext, validationError, httpContext.RequestAborted);
}
else
{
- var processingResult = await _processor.ProcessAsync(dcrContext);
+ var processingResult = await _processor.ProcessAsync(dcrContext, httpContext.RequestAborted);
if (processingResult is DynamicClientRegistrationError processingFailure)
{
- await _responseGenerator.WriteError(httpContext, processingFailure);
+ await _responseGenerator.WriteError(httpContext, processingFailure, httpContext.RequestAborted);
}
else if (processingResult is DynamicClientRegistrationResponse success)
{
- await _responseGenerator.WriteSuccessResponse(httpContext, success);
+ await _responseGenerator.WriteSuccessResponse(httpContext, success, httpContext.RequestAborted);
}
else
{
diff --git a/identity-server/src/Configuration/RequestProcessing/DynamicClientRegistrationRequestProcessor.cs b/identity-server/src/Configuration/RequestProcessing/DynamicClientRegistrationRequestProcessor.cs
index 55c41b4db..2371eff43 100644
--- a/identity-server/src/Configuration/RequestProcessing/DynamicClientRegistrationRequestProcessor.cs
+++ b/identity-server/src/Configuration/RequestProcessing/DynamicClientRegistrationRequestProcessor.cs
@@ -39,9 +39,9 @@ public class DynamicClientRegistrationRequestProcessor : IDynamicClientRegistrat
///
public virtual async Task ProcessAsync(
- DynamicClientRegistrationContext context)
+ DynamicClientRegistrationContext context, Ct ct)
{
- var clientIdResult = await AddClientId(context);
+ var clientIdResult = await AddClientId(context, ct);
if (clientIdResult is DynamicClientRegistrationError clientIdFailure)
{
return clientIdFailure;
@@ -64,7 +64,7 @@ public class DynamicClientRegistrationRequestProcessor : IDynamicClientRegistrat
}
}
- await Store.AddAsync(context.Client);
+ await Store.AddAsync(context.Client, ct);
return new DynamicClientRegistrationResponse(context.Request, context.Client)
{
@@ -133,9 +133,10 @@ public class DynamicClientRegistrationRequestProcessor : IDynamicClientRegistrat
/// The dynamic client registration context, which
/// includes the client model, the DCR request, and other contextual
/// information.
+ /// The cancellation token.
///
protected virtual Task AddClientId(
- DynamicClientRegistrationContext context)
+ DynamicClientRegistrationContext context, Ct ct)
{
context.Client.ClientId = CryptoRandom.CreateUniqueId();
return StepResult.Success();
diff --git a/identity-server/src/Configuration/RequestProcessing/IDynamicClientRegistrationRequestProcessor.cs b/identity-server/src/Configuration/RequestProcessing/IDynamicClientRegistrationRequestProcessor.cs
index c05bd12be..ed92d50d4 100644
--- a/identity-server/src/Configuration/RequestProcessing/IDynamicClientRegistrationRequestProcessor.cs
+++ b/identity-server/src/Configuration/RequestProcessing/IDynamicClientRegistrationRequestProcessor.cs
@@ -22,5 +22,5 @@ public interface IDynamicClientRegistrationRequestProcessor
/// properties of the client that are not specified in the request, and
/// storing the new client in the .
///
- Task ProcessAsync(DynamicClientRegistrationContext validatedRequest);
+ Task ProcessAsync(DynamicClientRegistrationContext validatedRequest, Ct ct);
}
diff --git a/identity-server/src/Configuration/ResponseGeneration/DynamicClientRegistrationResponseGenerator.cs b/identity-server/src/Configuration/ResponseGeneration/DynamicClientRegistrationResponseGenerator.cs
index 96840b064..dfe62d035 100644
--- a/identity-server/src/Configuration/ResponseGeneration/DynamicClientRegistrationResponseGenerator.cs
+++ b/identity-server/src/Configuration/ResponseGeneration/DynamicClientRegistrationResponseGenerator.cs
@@ -31,15 +31,15 @@ public class DynamicClientRegistrationResponseGenerator : IDynamicClientRegistra
public DynamicClientRegistrationResponseGenerator(ILogger logger) => Logger = logger;
///
- public virtual async Task WriteResponse(HttpContext context, int statusCode, T response)
+ public virtual async Task WriteResponse(HttpContext context, int statusCode, T response, Ct ct)
where T : IDynamicClientRegistrationResponse
{
context.Response.StatusCode = statusCode;
- await context.Response.WriteAsJsonAsync(response, SerializerOptions);
+ await context.Response.WriteAsJsonAsync(response, SerializerOptions, ct);
}
///
- public virtual Task WriteContentTypeError(HttpContext context)
+ public virtual Task WriteContentTypeError(HttpContext context, Ct ct)
{
Logger.LogDebug("Invalid content type in dynamic client registration request");
context.Response.StatusCode = StatusCodes.Status415UnsupportedMediaType;
@@ -47,19 +47,20 @@ public class DynamicClientRegistrationResponseGenerator : IDynamicClientRegistra
}
///
- public virtual async Task WriteBadRequestError(HttpContext context) =>
+ public virtual async Task WriteBadRequestError(HttpContext context, Ct ct) =>
await WriteResponse(context, StatusCodes.Status400BadRequest,
new DynamicClientRegistrationError(
DynamicClientRegistrationErrors.InvalidClientMetadata,
- "malformed metadata document")
+ "malformed metadata document"),
+ ct
);
///
- public virtual async Task WriteError(HttpContext context, DynamicClientRegistrationError error) =>
- await WriteResponse(context, StatusCodes.Status400BadRequest, error);
+ public virtual async Task WriteError(HttpContext context, DynamicClientRegistrationError error, Ct ct) =>
+ await WriteResponse(context, StatusCodes.Status400BadRequest, error, ct);
///
- public virtual async Task WriteSuccessResponse(HttpContext context, DynamicClientRegistrationResponse response) =>
- await WriteResponse(context, StatusCodes.Status201Created, response);
+ public virtual async Task WriteSuccessResponse(HttpContext context, DynamicClientRegistrationResponse response, Ct ct) =>
+ await WriteResponse(context, StatusCodes.Status201Created, response, ct);
}
diff --git a/identity-server/src/Configuration/ResponseGeneration/IDynamicClientRegistrationResponseGenerator.cs b/identity-server/src/Configuration/ResponseGeneration/IDynamicClientRegistrationResponseGenerator.cs
index 9ff850264..5b1e6b3b9 100644
--- a/identity-server/src/Configuration/ResponseGeneration/IDynamicClientRegistrationResponseGenerator.cs
+++ b/identity-server/src/Configuration/ResponseGeneration/IDynamicClientRegistrationResponseGenerator.cs
@@ -20,32 +20,37 @@ public interface IDynamicClientRegistrationResponseGenerator
/// The HTTP context to write the response to.
/// The status code to set in the response.
/// The response object to write to the response.
- Task WriteResponse(HttpContext context, int statusCode, T response)
+ /// The cancellation token.
+ Task WriteResponse(HttpContext context, int statusCode, T response, Ct ct)
where T : IDynamicClientRegistrationResponse;
///
/// Writes a content type error to the HTTP response.
///
/// The HTTP context to write the error to.
- Task WriteContentTypeError(HttpContext response);
+ /// The cancellation token.
+ Task WriteContentTypeError(HttpContext response, Ct ct);
///
/// Writes a bad request error to the HTTP context.
///
/// The HTTP context to write the error to.
- Task WriteBadRequestError(HttpContext context);
+ /// The cancellation token.
+ Task WriteBadRequestError(HttpContext context, Ct ct);
///
/// Writes a success response to the HTTP context.
///
/// The HTTP context to write the response to.
/// The dynamic client registration response.
- Task WriteSuccessResponse(HttpContext context, DynamicClientRegistrationResponse response);
+ /// The cancellation token.
+ Task WriteSuccessResponse(HttpContext context, DynamicClientRegistrationResponse response, Ct ct);
///
/// Writes a validation or processing step's error to the HTTP context.
///
/// The HTTP context to write the error to.
/// The dynamic client registration validation error.
- Task WriteError(HttpContext context, DynamicClientRegistrationError error);
+ /// The cancellation token.
+ Task WriteError(HttpContext context, DynamicClientRegistrationError error, Ct ct);
}
diff --git a/identity-server/src/Configuration/Stores/IClientConfigurationStore.cs b/identity-server/src/Configuration/Stores/IClientConfigurationStore.cs
index 38eb66768..5d8bc9839 100644
--- a/identity-server/src/Configuration/Stores/IClientConfigurationStore.cs
+++ b/identity-server/src/Configuration/Stores/IClientConfigurationStore.cs
@@ -15,5 +15,6 @@ public interface IClientConfigurationStore
/// Adds a client to the configuration store.
///
/// The client to add to the store
- Task AddAsync(Client client);
+ /// The cancellation token.
+ Task AddAsync(Client client, Ct ct);
}
diff --git a/identity-server/src/Configuration/Stores/InMemoryClientConfigurationStore.cs b/identity-server/src/Configuration/Stores/InMemoryClientConfigurationStore.cs
index f1d6b0704..2fbf14575 100644
--- a/identity-server/src/Configuration/Stores/InMemoryClientConfigurationStore.cs
+++ b/identity-server/src/Configuration/Stores/InMemoryClientConfigurationStore.cs
@@ -24,7 +24,7 @@ public class InMemoryClientConfigurationStore : IClientConfigurationStore
/// registered in the DI system as an ICollection.
public InMemoryClientConfigurationStore(ICollection clients) => _clients = clients;
///
- public Task AddAsync(Client client)
+ public Task AddAsync(Client client, Ct _)
{
if (_clients.Select(c => c.ClientId).Contains(client.ClientId))
{
diff --git a/identity-server/src/Configuration/Validation/DynamicClientRegistration/DynamicClientRegistrationValidator.cs b/identity-server/src/Configuration/Validation/DynamicClientRegistration/DynamicClientRegistrationValidator.cs
index 3e38f8238..0f69ddf21 100644
--- a/identity-server/src/Configuration/Validation/DynamicClientRegistration/DynamicClientRegistrationValidator.cs
+++ b/identity-server/src/Configuration/Validation/DynamicClientRegistration/DynamicClientRegistrationValidator.cs
@@ -27,81 +27,81 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
ILogger logger) => Logger = logger;
///
- public async Task ValidateAsync(DynamicClientRegistrationContext context)
+ public async Task ValidateAsync(DynamicClientRegistrationContext context, Ct ct)
{
- var result = await ValidateSoftwareStatementAsync(context);
+ var result = await ValidateSoftwareStatementAsync(context, ct);
if (result is DynamicClientRegistrationError softwareStatementValidation)
{
return softwareStatementValidation;
}
- result = await SetGrantTypesAsync(context);
+ result = await SetGrantTypesAsync(context, ct);
if (result is DynamicClientRegistrationError grantTypeValidation)
{
return grantTypeValidation;
}
- result = await SetRedirectUrisAsync(context);
+ result = await SetRedirectUrisAsync(context, ct);
if (result is DynamicClientRegistrationError redirectUrisValidation)
{
return redirectUrisValidation;
}
- result = await SetScopesAsync(context);
+ result = await SetScopesAsync(context, ct);
if (result is DynamicClientRegistrationError scopeValidation)
{
return scopeValidation;
}
- result = await SetSecretsAsync(context);
+ result = await SetSecretsAsync(context, ct);
if (result is DynamicClientRegistrationError keySetValidation)
{
return keySetValidation;
}
- result = await SetClientNameAsync(context);
+ result = await SetClientNameAsync(context, ct);
if (result is DynamicClientRegistrationError nameValidation)
{
return nameValidation;
}
- result = await SetLogoutParametersAsync(context);
+ result = await SetLogoutParametersAsync(context, ct);
if (result is DynamicClientRegistrationError logoutValidation)
{
return logoutValidation;
}
- result = await SetMaxAgeAsync(context);
+ result = await SetMaxAgeAsync(context, ct);
if (result is DynamicClientRegistrationError maxAgeValidation)
{
return maxAgeValidation;
}
- result = await SetUserInterfaceProperties(context);
+ result = await SetUserInterfaceProperties(context, ct);
if (result is DynamicClientRegistrationError miscValidation)
{
return miscValidation;
}
- result = await SetPublicClientProperties(context);
+ result = await SetPublicClientProperties(context, ct);
if (result is DynamicClientRegistrationError publicClientValidation)
{
return publicClientValidation;
}
- result = await SetAccessTokenProperties(context);
+ result = await SetAccessTokenProperties(context, ct);
if (result is DynamicClientRegistrationError accessTokenValidation)
{
return accessTokenValidation;
}
- result = await SetIdTokenProperties(context);
+ result = await SetIdTokenProperties(context, ct);
if (result is DynamicClientRegistrationError idTokenValidation)
{
return idTokenValidation;
}
- result = await SetServerSideSessionProperties(context);
+ result = await SetServerSideSessionProperties(context, ct);
if (result is DynamicClientRegistrationError serverSideSessionValidation)
{
return serverSideSessionValidation;
@@ -118,9 +118,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its allowed grant types set,
/// the DCR request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetGrantTypesAsync(DynamicClientRegistrationContext context)
+ protected virtual Task SetGrantTypesAsync(DynamicClientRegistrationContext context, Ct ct)
{
if (context.Request.GrantTypes.Count == 0)
{
@@ -218,9 +219,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its redirect uri set, the DCR
/// request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetRedirectUrisAsync(DynamicClientRegistrationContext context)
+ protected virtual Task SetRedirectUrisAsync(DynamicClientRegistrationContext context, Ct ct)
{
if (context.Client.AllowedGrantTypes.Contains(GrantType.AuthorizationCode))
{
@@ -265,13 +267,14 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its scopes set, the DCR
/// request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetScopesAsync(DynamicClientRegistrationContext context)
+ protected virtual Task SetScopesAsync(DynamicClientRegistrationContext context, Ct ct)
{
if (string.IsNullOrEmpty(context.Request.Scope))
{
- return SetDefaultScopes(context);
+ return SetDefaultScopes(context, ct);
}
else
{
@@ -299,9 +302,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its scopes set, the DCR
/// request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetDefaultScopes(DynamicClientRegistrationContext context)
+ protected virtual Task SetDefaultScopes(DynamicClientRegistrationContext context, Ct ct)
{
Logger.LogDebug("No scopes requested for dynamic client registration, and no default scope behavior implemented. To set default scopes, extend the DynamicClientRegistrationValidator and override the SetDefaultScopes method.");
return StepResult.Success();
@@ -314,9 +318,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its secrets set, the DCR
/// request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetSecretsAsync(DynamicClientRegistrationContext context)
+ protected virtual Task SetSecretsAsync(DynamicClientRegistrationContext context, Ct ct)
{
if (context.Request.JwksUri is not null && context.Request.Jwks is not null)
{
@@ -398,9 +403,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its name set, the DCR request,
/// and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetClientNameAsync(DynamicClientRegistrationContext context)
+ protected virtual Task SetClientNameAsync(DynamicClientRegistrationContext context, Ct ct)
{
context.Client.ClientName = context.Request?.ClientName;
return StepResult.Success();
@@ -417,9 +423,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its logout parameters set, the
/// DCR request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetLogoutParametersAsync(DynamicClientRegistrationContext context)
+ protected virtual Task SetLogoutParametersAsync(DynamicClientRegistrationContext context, Ct ct)
{
context.Client.PostLogoutRedirectUris = context.Request.PostLogoutRedirectUris?.Select(uri => uri.ToString()).ToList() ?? new List();
context.Client.FrontChannelLogoutUri = context.Request.FrontChannelLogoutUri?.AbsoluteUri;
@@ -438,9 +445,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its max age set, the DCR
/// request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetMaxAgeAsync(DynamicClientRegistrationContext context)
+ protected virtual Task SetMaxAgeAsync(DynamicClientRegistrationContext context, Ct ct)
{
if (context.Request.DefaultMaxAge.HasValue)
{
@@ -465,9 +473,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// The dynamic client registration context, which
/// includes the client model that is being built up, the DCR request, and
/// other contextual information.
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task ValidateSoftwareStatementAsync(DynamicClientRegistrationContext context) => StepResult.Success();
+ protected virtual Task ValidateSoftwareStatementAsync(DynamicClientRegistrationContext context, Ct ct) => StepResult.Success();
///
/// Validates the requested client parameters related to public clients and
@@ -479,9 +488,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its public client properties
/// set, the DCR request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetPublicClientProperties(DynamicClientRegistrationContext context)
+ protected virtual Task SetPublicClientProperties(DynamicClientRegistrationContext context, Ct ct)
{
context.Client.AllowedCorsOrigins = context.Request.AllowedCorsOrigins ?? new();
if (context.Request.RequireClientSecret.HasValue)
@@ -506,9 +516,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its access token properties
/// set, the DCR request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetAccessTokenProperties(DynamicClientRegistrationContext context)
+ protected virtual Task SetAccessTokenProperties(DynamicClientRegistrationContext context, Ct ct)
{
if (context.Request.AccessTokenType != null)
{
@@ -540,9 +551,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its id token properties set,
/// the DCR request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetIdTokenProperties(DynamicClientRegistrationContext context)
+ protected virtual Task SetIdTokenProperties(DynamicClientRegistrationContext context, Ct ct)
{
if (context.Request.IdentityTokenLifetime.HasValue)
{
@@ -567,9 +579,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// includes the client model that will have its server side session
/// properties set, the DCR request, and other contextual information.
///
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- protected virtual Task SetServerSideSessionProperties(DynamicClientRegistrationContext context)
+ protected virtual Task SetServerSideSessionProperties(DynamicClientRegistrationContext context, Ct ct)
{
if (context.Request.CoordinateLifetimeWithUserSession.HasValue)
{
@@ -587,11 +600,10 @@ public class DynamicClientRegistrationValidator : IDynamicClientRegistrationVali
/// The dynamic client registration context, which
/// includes the client model that will have miscellaneous properties set,
/// the DCR request, and other contextual information.
+ /// The cancellation token.
/// A task that returns an , which either
/// represents that this step succeeded or failed.
- /// A task that returns an , which either
- /// represents that this step succeeded or failed.
- protected virtual Task SetUserInterfaceProperties(DynamicClientRegistrationContext context)
+ protected virtual Task SetUserInterfaceProperties(DynamicClientRegistrationContext context, Ct ct)
{
// Misc Uris
context.Client.LogoUri = context.Request.LogoUri?.ToString();
diff --git a/identity-server/src/Configuration/Validation/DynamicClientRegistration/IDynamicClientRegistrationValidator.cs b/identity-server/src/Configuration/Validation/DynamicClientRegistration/IDynamicClientRegistrationValidator.cs
index 3ac77dbe1..cf8ae04c6 100644
--- a/identity-server/src/Configuration/Validation/DynamicClientRegistration/IDynamicClientRegistrationValidator.cs
+++ b/identity-server/src/Configuration/Validation/DynamicClientRegistration/IDynamicClientRegistrationValidator.cs
@@ -16,8 +16,9 @@ public interface IDynamicClientRegistrationValidator
///
/// Contextual information about the DCR
/// request.
+ /// The cancellation token.
/// A task that returns an , which either
/// indicates success or failure.
- Task ValidateAsync(DynamicClientRegistrationContext context);
+ Task ValidateAsync(DynamicClientRegistrationContext context, Ct ct);
}
diff --git a/identity-server/src/EntityFramework.Storage/Extensions/DbContextExtensions.cs b/identity-server/src/EntityFramework.Storage/Extensions/DbContextExtensions.cs
index e88dceb6f..c3cc37209 100644
--- a/identity-server/src/EntityFramework.Storage/Extensions/DbContextExtensions.cs
+++ b/identity-server/src/EntityFramework.Storage/Extensions/DbContextExtensions.cs
@@ -18,7 +18,7 @@ public static class DbContextExtensions
///
/// Saves changes and handles concurrency exceptions.
///
- public static async Task> SaveChangesWithConcurrencyCheckAsync(this IPersistedGrantDbContext context, ILogger logger, CT ct = default)
+ public static async Task> SaveChangesWithConcurrencyCheckAsync(this IPersistedGrantDbContext context, ILogger logger, Ct ct)
where T : class
{
var list = new List();
diff --git a/identity-server/src/EntityFramework.Storage/Interfaces/IConfigurationDbContext.cs b/identity-server/src/EntityFramework.Storage/Interfaces/IConfigurationDbContext.cs
index e4efd57fc..710f39681 100644
--- a/identity-server/src/EntityFramework.Storage/Interfaces/IConfigurationDbContext.cs
+++ b/identity-server/src/EntityFramework.Storage/Interfaces/IConfigurationDbContext.cs
@@ -67,7 +67,7 @@ public interface IConfigurationDbContext : IDisposable
/// Saves the changes.
///
///
- Task SaveChangesAsync(CT ct);
+ Task SaveChangesAsync(Ct ct);
// this is here only because of this: https://github.com/DuendeSoftware/IdentityServer/issues/472
// and because Microsoft implements the old API explicitly: https://github.com/dotnet/aspnetcore/blob/v6.0.0-rc.2.21480.10/src/Identity/ApiAuthorization.IdentityServer/src/Data/ApiAuthorizationDbContext.cs
@@ -76,5 +76,5 @@ public interface IConfigurationDbContext : IDisposable
/// Saves the changes.
///
///
- Task SaveChangesAsync() => SaveChangesAsync(CT.None);
+ Task SaveChangesAsync() => SaveChangesAsync(Ct.None);
}
diff --git a/identity-server/src/EntityFramework.Storage/Interfaces/IPersistedGrantDbContext.cs b/identity-server/src/EntityFramework.Storage/Interfaces/IPersistedGrantDbContext.cs
index 9a530e666..7c4d2c51a 100644
--- a/identity-server/src/EntityFramework.Storage/Interfaces/IPersistedGrantDbContext.cs
+++ b/identity-server/src/EntityFramework.Storage/Interfaces/IPersistedGrantDbContext.cs
@@ -59,7 +59,7 @@ public interface IPersistedGrantDbContext : IDisposable
/// Saves the changes.
///
///
- Task SaveChangesAsync(CT ct);
+ Task SaveChangesAsync(Ct ct);
// this is here only because of this: https://github.com/DuendeSoftware/IdentityServer/issues/472
// and because Microsoft implements the old API explicitly: https://github.com/dotnet/aspnetcore/blob/v6.0.0-rc.2.21480.10/src/Identity/ApiAuthorization.IdentityServer/src/Data/ApiAuthorizationDbContext.cs
@@ -68,5 +68,5 @@ public interface IPersistedGrantDbContext : IDisposable
/// Saves the changes.
///
///
- Task SaveChangesAsync() => SaveChangesAsync(CT.None);
+ Task SaveChangesAsync() => SaveChangesAsync(Ct.None);
}
diff --git a/identity-server/src/EntityFramework.Storage/Stores/ClientStore.cs b/identity-server/src/EntityFramework.Storage/Stores/ClientStore.cs
index e392ea216..316a62821 100644
--- a/identity-server/src/EntityFramework.Storage/Stores/ClientStore.cs
+++ b/identity-server/src/EntityFramework.Storage/Stores/ClientStore.cs
@@ -2,9 +2,9 @@
// See LICENSE in the project root for license information.
+using System.Runtime.CompilerServices;
using Duende.IdentityServer.EntityFramework.Interfaces;
using Duende.IdentityServer.EntityFramework.Mappers;
-using Duende.IdentityServer.Services;
using Duende.IdentityServer.Stores;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@@ -22,11 +22,6 @@ public class ClientStore : IClientStore
///
protected readonly IConfigurationDbContext Context;
- ///
- /// The CancellationToken provider.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -37,23 +32,22 @@ public class ClientStore : IClientStore
///
/// The context.
/// The logger.
- ///
/// context
- public ClientStore(IConfigurationDbContext context, ILogger logger, ICancellationTokenProvider cancellationTokenProvider)
+ public ClientStore(IConfigurationDbContext context, ILogger logger)
{
Context = context ?? throw new ArgumentNullException(nameof(context));
Logger = logger;
- CancellationTokenProvider = cancellationTokenProvider;
}
///
/// Finds a client by id
///
/// The client id
+ /// The cancellation token.
///
/// The client
///
- public virtual async Task FindClientByIdAsync(string clientId)
+ public virtual async Task FindClientByIdAsync(string clientId, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ClientStore.FindClientById");
activity?.SetTag(Tracing.Properties.ClientId, clientId);
@@ -72,7 +66,7 @@ public class ClientStore : IClientStore
.AsNoTracking()
.AsSplitQuery();
- var client = (await query.ToArrayAsync(CancellationTokenProvider.CancellationToken)).
+ var client = (await query.ToArrayAsync(ct)).
SingleOrDefault(x => x.ClientId == clientId);
if (client == null)
{
@@ -87,7 +81,7 @@ public class ClientStore : IClientStore
}
///
- public virtual async IAsyncEnumerable GetAllClientsAsync()
+ public virtual async IAsyncEnumerable GetAllClientsAsync([EnumeratorCancellation] Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ClientStore.GetAllClients");
@@ -105,7 +99,7 @@ public class ClientStore : IClientStore
.AsSplitQuery();
var clientCount = 0;
- await foreach (var client in query.AsAsyncEnumerable().WithCancellation(CancellationTokenProvider.CancellationToken))
+ await foreach (var client in query.AsAsyncEnumerable().WithCancellation(ct))
{
clientCount++;
yield return client.ToModel();
diff --git a/identity-server/src/EntityFramework.Storage/Stores/DeviceFlowStore.cs b/identity-server/src/EntityFramework.Storage/Stores/DeviceFlowStore.cs
index 5da088a3b..f5718288f 100644
--- a/identity-server/src/EntityFramework.Storage/Stores/DeviceFlowStore.cs
+++ b/identity-server/src/EntityFramework.Storage/Stores/DeviceFlowStore.cs
@@ -6,7 +6,6 @@ using Duende.IdentityModel;
using Duende.IdentityServer.EntityFramework.Entities;
using Duende.IdentityServer.EntityFramework.Interfaces;
using Duende.IdentityServer.Models;
-using Duende.IdentityServer.Services;
using Duende.IdentityServer.Stores;
using Duende.IdentityServer.Stores.Serialization;
using Microsoft.EntityFrameworkCore;
@@ -30,11 +29,6 @@ public class DeviceFlowStore : IDeviceFlowStore
///
protected readonly IPersistentGrantSerializer Serializer;
- ///
- /// The CancellationToken provider.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -46,46 +40,33 @@ public class DeviceFlowStore : IDeviceFlowStore
/// The context.
/// The serializer
/// The logger.
- ///
public DeviceFlowStore(
IPersistedGrantDbContext context,
IPersistentGrantSerializer serializer,
- ILogger logger,
- ICancellationTokenProvider cancellationTokenProvider)
+ ILogger logger)
{
Context = context;
Serializer = serializer;
Logger = logger;
- CancellationTokenProvider = cancellationTokenProvider;
}
- ///
- /// Stores the device authorization request.
- ///
- /// The device code.
- /// The user code.
- /// The data.
- ///
- public virtual async Task StoreDeviceAuthorizationAsync(string deviceCode, string userCode, DeviceCode data)
+ ///
+ public virtual async Task StoreDeviceAuthorizationAsync(string deviceCode, string userCode, DeviceCode data, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("DeviceFlowStore.StoreDeviceAuthorization");
Context.DeviceFlowCodes.Add(ToEntity(data, deviceCode, userCode));
- await Context.SaveChangesAsync(CancellationTokenProvider.CancellationToken);
+ await Context.SaveChangesAsync(ct);
}
- ///
- /// Finds device authorization by user code.
- ///
- /// The user code.
- ///
- public virtual async Task FindByUserCodeAsync(string userCode)
+ ///
+ public virtual async Task FindByUserCodeAsync(string userCode, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("DeviceFlowStore.FindByUserCode");
var deviceFlowCodes = (await Context.DeviceFlowCodes.AsNoTracking().Where(x => x.UserCode == userCode)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ .ToArrayAsync(ct))
.SingleOrDefault(x => x.UserCode == userCode);
var model = ToModel(deviceFlowCodes?.Data);
@@ -94,17 +75,13 @@ public class DeviceFlowStore : IDeviceFlowStore
return model;
}
- ///
- /// Finds device authorization by device code.
- ///
- /// The device code.
- ///
- public virtual async Task FindByDeviceCodeAsync(string deviceCode)
+ ///
+ public virtual async Task FindByDeviceCodeAsync(string deviceCode, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("DeviceFlowStore.FindByDeviceCode");
var deviceFlowCodes = (await Context.DeviceFlowCodes.AsNoTracking().Where(x => x.DeviceCode == deviceCode)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ .ToArrayAsync(ct))
.SingleOrDefault(x => x.DeviceCode == deviceCode);
var model = ToModel(deviceFlowCodes?.Data);
@@ -113,18 +90,13 @@ public class DeviceFlowStore : IDeviceFlowStore
return model;
}
- ///
- /// Updates device authorization, searching by user code.
- ///
- /// The user code.
- /// The data.
- ///
- public virtual async Task UpdateByUserCodeAsync(string userCode, DeviceCode data)
+ ///
+ public virtual async Task UpdateByUserCodeAsync(string userCode, DeviceCode data, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("DeviceFlowStore.UpdateByUserCode");
var existing = (await Context.DeviceFlowCodes.Where(x => x.UserCode == userCode)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ .ToArrayAsync(ct))
.SingleOrDefault(x => x.UserCode == userCode);
if (existing == null)
{
@@ -141,7 +113,7 @@ public class DeviceFlowStore : IDeviceFlowStore
try
{
- await Context.SaveChangesAsync();
+ await Context.SaveChangesAsync(ct);
}
catch (DbUpdateConcurrencyException ex)
{
@@ -149,17 +121,13 @@ public class DeviceFlowStore : IDeviceFlowStore
}
}
- ///
- /// Removes the device authorization, searching by device code.
- ///
- /// The device code.
- ///
- public virtual async Task RemoveByDeviceCodeAsync(string deviceCode)
+ ///
+ public virtual async Task RemoveByDeviceCodeAsync(string deviceCode, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("DeviceFlowStore.RemoveByDeviceCode");
var deviceFlowCodes = (await Context.DeviceFlowCodes.Where(x => x.DeviceCode == deviceCode)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ .ToArrayAsync(ct))
.SingleOrDefault(x => x.DeviceCode == deviceCode);
if (deviceFlowCodes != null)
@@ -170,7 +138,7 @@ public class DeviceFlowStore : IDeviceFlowStore
try
{
- await Context.SaveChangesAsync();
+ await Context.SaveChangesAsync(ct);
}
catch (DbUpdateConcurrencyException ex)
{
diff --git a/identity-server/src/EntityFramework.Storage/Stores/IdentityProviderStore.cs b/identity-server/src/EntityFramework.Storage/Stores/IdentityProviderStore.cs
index 4560b2d61..79f44d2a7 100644
--- a/identity-server/src/EntityFramework.Storage/Stores/IdentityProviderStore.cs
+++ b/identity-server/src/EntityFramework.Storage/Stores/IdentityProviderStore.cs
@@ -5,7 +5,6 @@
using Duende.IdentityServer.EntityFramework.Interfaces;
using Duende.IdentityServer.EntityFramework.Mappers;
using Duende.IdentityServer.Models;
-using Duende.IdentityServer.Services;
using Duende.IdentityServer.Stores;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@@ -23,11 +22,6 @@ public class IdentityProviderStore : IIdentityProviderStore
///
protected readonly IConfigurationDbContext Context;
- ///
- /// The CancellationToken provider.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -38,17 +32,15 @@ public class IdentityProviderStore : IIdentityProviderStore
///
/// The context.
/// The logger.
- ///
/// context
- public IdentityProviderStore(IConfigurationDbContext context, ILogger logger, ICancellationTokenProvider cancellationTokenProvider)
+ public IdentityProviderStore(IConfigurationDbContext context, ILogger logger)
{
Context = context ?? throw new ArgumentNullException(nameof(context));
Logger = logger;
- CancellationTokenProvider = cancellationTokenProvider;
}
///
- public async Task> GetAllSchemeNamesAsync()
+ public async Task> GetAllSchemeNamesAsync(Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("IdentityProviderStore.GetAllSchemeNames");
@@ -59,17 +51,17 @@ public class IdentityProviderStore : IIdentityProviderStore
DisplayName = x.DisplayName
});
- return await query.ToArrayAsync(CancellationTokenProvider.CancellationToken);
+ return await query.ToArrayAsync(ct);
}
///
- public async Task GetBySchemeAsync(string scheme)
+ public async Task GetBySchemeAsync(string scheme, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("IdentityProviderStore.GetByScheme");
activity?.SetTag(Tracing.Properties.Scheme, scheme);
var idp = (await Context.IdentityProviders.AsNoTracking().Where(x => x.Scheme == scheme)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ .ToArrayAsync(ct))
.SingleOrDefault(x => x.Scheme == scheme);
if (idp == null)
{
diff --git a/identity-server/src/EntityFramework.Storage/Stores/PersistedGrantStore.cs b/identity-server/src/EntityFramework.Storage/Stores/PersistedGrantStore.cs
index bf6757357..91f9ad22f 100644
--- a/identity-server/src/EntityFramework.Storage/Stores/PersistedGrantStore.cs
+++ b/identity-server/src/EntityFramework.Storage/Stores/PersistedGrantStore.cs
@@ -6,7 +6,6 @@ using Duende.IdentityServer.EntityFramework.Entities;
using Duende.IdentityServer.EntityFramework.Interfaces;
using Duende.IdentityServer.EntityFramework.Mappers;
using Duende.IdentityServer.Extensions;
-using Duende.IdentityServer.Services;
using Duende.IdentityServer.Stores;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@@ -24,11 +23,6 @@ public class PersistedGrantStore : Duende.IdentityServer.Stores.IPersistedGrantS
///
protected readonly IPersistedGrantDbContext Context;
- ///
- /// The CancellationToken service.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -39,21 +33,19 @@ public class PersistedGrantStore : Duende.IdentityServer.Stores.IPersistedGrantS
///
/// The context.
/// The logger.
- ///
- public PersistedGrantStore(IPersistedGrantDbContext context, ILogger logger, ICancellationTokenProvider cancellationTokenProvider)
+ public PersistedGrantStore(IPersistedGrantDbContext context, ILogger logger)
{
Context = context;
Logger = logger;
- CancellationTokenProvider = cancellationTokenProvider;
}
///
- public virtual async Task StoreAsync(Duende.IdentityServer.Models.PersistedGrant token)
+ public virtual async Task StoreAsync(Duende.IdentityServer.Models.PersistedGrant token, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("PersistedGrantStore.Store");
var existing = (await Context.PersistedGrants.Where(x => x.Key == token.Key)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ .ToArrayAsync(ct))
.SingleOrDefault(x => x.Key == token.Key);
if (existing == null)
{
@@ -71,7 +63,7 @@ public class PersistedGrantStore : Duende.IdentityServer.Stores.IPersistedGrantS
try
{
- await Context.SaveChangesAsync(CancellationTokenProvider.CancellationToken);
+ await Context.SaveChangesAsync(ct);
}
catch (DbUpdateConcurrencyException ex)
{
@@ -80,12 +72,12 @@ public class PersistedGrantStore : Duende.IdentityServer.Stores.IPersistedGrantS
}
///
- public virtual async Task GetAsync(string key)
+ public virtual async Task GetAsync(string key, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("PersistedGrantStore.Get");
var persistedGrant = (await Context.PersistedGrants.AsNoTracking().Where(x => x.Key == key)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ .ToArrayAsync(ct))
.SingleOrDefault(x => x.Key == key);
var model = persistedGrant?.ToModel();
@@ -95,14 +87,14 @@ public class PersistedGrantStore : Duende.IdentityServer.Stores.IPersistedGrantS
}
///
- public virtual async Task> GetAllAsync(PersistedGrantFilter filter)
+ public virtual async Task> GetAllAsync(PersistedGrantFilter filter, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("PersistedGrantStore.GetAll");
filter.Validate();
var persistedGrants = await Filter(Context.PersistedGrants.AsQueryable(), filter)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken);
+ .ToArrayAsync(ct);
persistedGrants = Filter(persistedGrants.AsQueryable(), filter).ToArray();
var model = persistedGrants.Select(x => x.ToModel());
@@ -113,12 +105,12 @@ public class PersistedGrantStore : Duende.IdentityServer.Stores.IPersistedGrantS
}
///
- public virtual async Task RemoveAsync(string key)
+ public virtual async Task RemoveAsync(string key, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("PersistedGrantStore.Remove");
var persistedGrant = (await Context.PersistedGrants.Where(x => x.Key == key)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ .ToArrayAsync(ct))
.SingleOrDefault(x => x.Key == key);
if (persistedGrant != null)
{
@@ -128,7 +120,7 @@ public class PersistedGrantStore : Duende.IdentityServer.Stores.IPersistedGrantS
try
{
- await Context.SaveChangesAsync(CancellationTokenProvider.CancellationToken);
+ await Context.SaveChangesAsync(ct);
}
catch (DbUpdateConcurrencyException ex)
{
@@ -142,14 +134,14 @@ public class PersistedGrantStore : Duende.IdentityServer.Stores.IPersistedGrantS
}
///
- public virtual async Task RemoveAllAsync(PersistedGrantFilter filter)
+ public virtual async Task RemoveAllAsync(PersistedGrantFilter filter, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("PersistedGrantStore.RemoveAll");
filter.Validate();
var persistedGrants = await Filter(Context.PersistedGrants.AsQueryable(), filter)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken);
+ .ToArrayAsync(ct);
persistedGrants = Filter(persistedGrants.AsQueryable(), filter).ToArray();
Logger.LogDebug("removing {persistedGrantCount} persisted grants from database for {@filter}", persistedGrants.Length, filter);
@@ -158,7 +150,7 @@ public class PersistedGrantStore : Duende.IdentityServer.Stores.IPersistedGrantS
try
{
- await Context.SaveChangesAsync(CancellationTokenProvider.CancellationToken);
+ await Context.SaveChangesAsync(ct);
}
catch (DbUpdateConcurrencyException ex)
{
diff --git a/identity-server/src/EntityFramework.Storage/Stores/PushedAuthorizationRequestStore.cs b/identity-server/src/EntityFramework.Storage/Stores/PushedAuthorizationRequestStore.cs
index 47e21b14b..ea1172067 100644
--- a/identity-server/src/EntityFramework.Storage/Stores/PushedAuthorizationRequestStore.cs
+++ b/identity-server/src/EntityFramework.Storage/Stores/PushedAuthorizationRequestStore.cs
@@ -4,7 +4,6 @@
using Duende.IdentityServer.EntityFramework.Interfaces;
using Duende.IdentityServer.EntityFramework.Mappers;
-using Duende.IdentityServer.Services;
using Duende.IdentityServer.Stores;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@@ -19,11 +18,6 @@ public class PushedAuthorizationRequestStore : IPushedAuthorizationRequestStore
///
protected readonly IPersistedGrantDbContext Context;
- ///
- /// The CancellationToken service.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -34,22 +28,20 @@ public class PushedAuthorizationRequestStore : IPushedAuthorizationRequestStore
///
/// The context.
/// The logger.
- ///
- public PushedAuthorizationRequestStore(IPersistedGrantDbContext context, ILogger logger, ICancellationTokenProvider cancellationTokenProvider)
+ public PushedAuthorizationRequestStore(IPersistedGrantDbContext context, ILogger logger)
{
Context = context;
Logger = logger;
- CancellationTokenProvider = cancellationTokenProvider;
}
///
- public async Task ConsumeByHashAsync(string referenceValueHash)
+ public async Task ConsumeByHashAsync(string referenceValueHash, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("PersistedGrantStore.Remove");
Logger.LogDebug("removing {referenceValueHash} pushed authorization from database", referenceValueHash);
var numDeleted = await Context.PushedAuthorizationRequests
.Where(par => par.ReferenceValueHash == referenceValueHash)
- .ExecuteDeleteAsync(CancellationTokenProvider.CancellationToken);
+ .ExecuteDeleteAsync(ct);
if (numDeleted != 1)
{
Logger.LogWarning("attempted to remove {referenceValueHash} pushed authorization request because it was consumed, but no records were actually deleted.", referenceValueHash);
@@ -57,13 +49,13 @@ public class PushedAuthorizationRequestStore : IPushedAuthorizationRequestStore
}
///
- public virtual async Task GetByHashAsync(string referenceValueHash)
+ public virtual async Task GetByHashAsync(string referenceValueHash, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("PushedAuthorizationRequestStore.Get");
var par = (await Context.PushedAuthorizationRequests
.AsNoTracking().Where(x => x.ReferenceValueHash == referenceValueHash)
- .ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ .ToArrayAsync(ct))
.SingleOrDefault(x => x.ReferenceValueHash == referenceValueHash);
var model = par?.ToModel();
@@ -74,14 +66,14 @@ public class PushedAuthorizationRequestStore : IPushedAuthorizationRequestStore
///
- public virtual async Task StoreAsync(Models.PushedAuthorizationRequest par)
+ public virtual async Task StoreAsync(Models.PushedAuthorizationRequest par, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("PushedAuthorizationStore.Store");
Context.PushedAuthorizationRequests.Add(par.ToEntity());
try
{
- await Context.SaveChangesAsync(CancellationTokenProvider.CancellationToken);
+ await Context.SaveChangesAsync(ct);
}
// REVIEW - Is this exception possible, since we don't try to load (and then update) an existing entity?
// I think it isn't, but what happens if we somehow two calls to StoreAsync with the same PAR are made?
diff --git a/identity-server/src/EntityFramework.Storage/Stores/ResourceStore.cs b/identity-server/src/EntityFramework.Storage/Stores/ResourceStore.cs
index c1b0012f4..be024e192 100644
--- a/identity-server/src/EntityFramework.Storage/Stores/ResourceStore.cs
+++ b/identity-server/src/EntityFramework.Storage/Stores/ResourceStore.cs
@@ -6,7 +6,6 @@ using Duende.IdentityServer.EntityFramework.Interfaces;
using Duende.IdentityServer.EntityFramework.Mappers;
using Duende.IdentityServer.Extensions;
using Duende.IdentityServer.Models;
-using Duende.IdentityServer.Services;
using Duende.IdentityServer.Stores;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@@ -24,11 +23,6 @@ public class ResourceStore : IResourceStore
///
protected readonly IConfigurationDbContext Context;
- ///
- /// The CancellationToken provider.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -39,21 +33,20 @@ public class ResourceStore : IResourceStore
///
/// The context.
/// The logger.
- ///
/// context
- public ResourceStore(IConfigurationDbContext context, ILogger logger, ICancellationTokenProvider cancellationTokenProvider)
+ public ResourceStore(IConfigurationDbContext context, ILogger logger)
{
Context = context ?? throw new ArgumentNullException(nameof(context));
Logger = logger;
- CancellationTokenProvider = cancellationTokenProvider;
}
///
/// Finds the API resources by name.
///
/// The names.
+ /// The cancellation token.
///
- public virtual async Task> FindApiResourcesByNameAsync(IEnumerable apiResourceNames)
+ public virtual async Task> FindApiResourcesByNameAsync(IEnumerable apiResourceNames, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ResourceStore.FindApiResourcesByName");
activity?.SetTag(Tracing.Properties.ApiResourceNames, apiResourceNames.ToSpaceSeparatedString());
@@ -72,7 +65,7 @@ public class ResourceStore : IResourceStore
.Include(x => x.Properties)
.AsNoTracking();
- var result = (await apis.ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ var result = (await apis.ToArrayAsync(ct))
.Where(x => apiResourceNames.Contains(x.Name))
.Select(x => x.ToModel()).ToArray();
@@ -92,8 +85,9 @@ public class ResourceStore : IResourceStore
/// Gets API resources by scope name.
///
///
+ /// The cancellation token.
///
- public virtual async Task> FindApiResourcesByScopeNameAsync(IEnumerable scopeNames)
+ public virtual async Task> FindApiResourcesByScopeNameAsync(IEnumerable scopeNames, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ResourceStore.FindApiResourcesByScopeName");
activity?.SetTag(Tracing.Properties.ScopeNames, scopeNames.ToSpaceSeparatedString());
@@ -112,7 +106,7 @@ public class ResourceStore : IResourceStore
.Include(x => x.Properties)
.AsNoTracking();
- var results = (await apis.ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ var results = (await apis.ToArrayAsync(ct))
.Where(api => api.Scopes.Any(x => names.Contains(x.Scope)));
var models = results.Select(x => x.ToModel()).ToArray();
@@ -125,8 +119,9 @@ public class ResourceStore : IResourceStore
/// Gets identity resources by scope name.
///
///
+ /// The cancellation token.
///
- public virtual async Task> FindIdentityResourcesByScopeNameAsync(IEnumerable scopeNames)
+ public virtual async Task> FindIdentityResourcesByScopeNameAsync(IEnumerable scopeNames, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ResourceStore.FindIdentityResourcesByScopeName");
activity?.SetTag(Tracing.Properties.ScopeNames, scopeNames.ToSpaceSeparatedString());
@@ -143,7 +138,7 @@ public class ResourceStore : IResourceStore
.Include(x => x.Properties)
.AsNoTracking();
- var results = (await resources.ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ var results = (await resources.ToArrayAsync(ct))
.Where(x => scopes.Contains(x.Name));
Logger.LogDebug("Found {scopes} identity scopes in database", results.Select(x => x.Name));
@@ -155,8 +150,9 @@ public class ResourceStore : IResourceStore
/// Gets scopes by scope name.
///
///
+ /// The cancellation token.
///
- public virtual async Task> FindApiScopesByNameAsync(IEnumerable scopeNames)
+ public virtual async Task> FindApiScopesByNameAsync(IEnumerable scopeNames, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ResourceStore.FindApiScopesByName");
activity?.SetTag(Tracing.Properties.ScopeNames, scopeNames.ToSpaceSeparatedString());
@@ -173,7 +169,7 @@ public class ResourceStore : IResourceStore
.Include(x => x.Properties)
.AsNoTracking();
- var results = (await resources.ToArrayAsync(CancellationTokenProvider.CancellationToken))
+ var results = (await resources.ToArrayAsync(ct))
.Where(x => scopes.Contains(x.Name));
Logger.LogDebug("Found {scopes} scopes in database", results.Select(x => x.Name));
@@ -185,7 +181,7 @@ public class ResourceStore : IResourceStore
/// Gets all resources.
///
///
- public virtual async Task GetAllResourcesAsync()
+ public virtual async Task GetAllResourcesAsync(Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ResourceStore.GetAllResources");
@@ -207,9 +203,9 @@ public class ResourceStore : IResourceStore
.AsNoTracking();
var result = new Resources(
- (await identity.ToArrayAsync(CancellationTokenProvider.CancellationToken)).Select(x => x.ToModel()),
- (await apis.ToArrayAsync(CancellationTokenProvider.CancellationToken)).Select(x => x.ToModel()),
- (await scopes.ToArrayAsync(CancellationTokenProvider.CancellationToken)).Select(x => x.ToModel())
+ (await identity.ToArrayAsync(ct)).Select(x => x.ToModel()),
+ (await apis.ToArrayAsync(ct)).Select(x => x.ToModel()),
+ (await scopes.ToArrayAsync(ct)).Select(x => x.ToModel())
);
Logger.LogDebug("Found {scopes} as all scopes, and {apis} as API resources",
diff --git a/identity-server/src/EntityFramework.Storage/Stores/ServerSideSessionStore.cs b/identity-server/src/EntityFramework.Storage/Stores/ServerSideSessionStore.cs
index 872439991..d0ba58394 100644
--- a/identity-server/src/EntityFramework.Storage/Stores/ServerSideSessionStore.cs
+++ b/identity-server/src/EntityFramework.Storage/Stores/ServerSideSessionStore.cs
@@ -5,7 +5,6 @@
using Duende.IdentityServer.EntityFramework.Extensions;
using Duende.IdentityServer.EntityFramework.Interfaces;
using Duende.IdentityServer.Models;
-using Duende.IdentityServer.Services;
using Duende.IdentityServer.Stores;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@@ -23,11 +22,6 @@ public class ServerSideSessionStore : IServerSideSessionStore
///
protected readonly IPersistedGrantDbContext Context;
- ///
- /// The CancellationToken provider.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -38,24 +32,20 @@ public class ServerSideSessionStore : IServerSideSessionStore
///
/// The context.
/// The logger.
- ///
/// context
- public ServerSideSessionStore(IPersistedGrantDbContext context, ILogger logger, ICancellationTokenProvider cancellationTokenProvider)
+ public ServerSideSessionStore(IPersistedGrantDbContext context, ILogger logger)
{
Context = context ?? throw new ArgumentNullException(nameof(context));
Logger = logger;
- CancellationTokenProvider = cancellationTokenProvider;
}
///
- public virtual async Task CreateSessionAsync(ServerSideSession session, CT ct = default)
+ public virtual async Task CreateSessionAsync(ServerSideSession session, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ServerSideSessionStore.CreateSession");
- ct = ct == CT.None ? CancellationTokenProvider.CancellationToken : ct;
-
var entity = new Entities.ServerSideSession
{
Key = session.Key,
@@ -82,12 +72,10 @@ public class ServerSideSessionStore : IServerSideSessionStore
}
///
- public virtual async Task GetSessionAsync(string key, CT ct = default)
+ public virtual async Task GetSessionAsync(string key, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ServerSideSessionStore.GetSession");
- ct = ct == CT.None ? CancellationTokenProvider.CancellationToken : ct;
-
var entity = (await Context.ServerSideSessions.AsNoTracking().Where(x => x.Key == key)
.ToArrayAsync(ct))
.SingleOrDefault(x => x.Key == key);
@@ -115,12 +103,10 @@ public class ServerSideSessionStore : IServerSideSessionStore
}
///
- public virtual async Task UpdateSessionAsync(ServerSideSession session, CT ct = default)
+ public virtual async Task UpdateSessionAsync(ServerSideSession session, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ServerSideSessionStore.UpdateSession");
- ct = ct == CT.None ? CancellationTokenProvider.CancellationToken : ct;
-
var entity = (await Context.ServerSideSessions.Where(x => x.Key == session.Key)
.ToArrayAsync(ct))
.SingleOrDefault(x => x.Key == session.Key);
@@ -152,12 +138,10 @@ public class ServerSideSessionStore : IServerSideSessionStore
}
///
- public virtual async Task DeleteSessionAsync(string key, CT ct = default)
+ public virtual async Task DeleteSessionAsync(string key, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ServerSideSessionStore.DeleteSession");
- ct = ct == CT.None ? CancellationTokenProvider.CancellationToken : ct;
-
var entity = (await Context.ServerSideSessions.Where(x => x.Key == key)
.ToArrayAsync(ct))
.SingleOrDefault(x => x.Key == key);
@@ -184,12 +168,10 @@ public class ServerSideSessionStore : IServerSideSessionStore
///
- public virtual async Task> GetSessionsAsync(SessionFilter filter, CT ct = default)
+ public virtual async Task> GetSessionsAsync(SessionFilter filter, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ServerSideSessionStore.GetSessions");
- ct = ct == CT.None ? CancellationTokenProvider.CancellationToken : ct;
-
filter.Validate();
var entities = await Filter(Context.ServerSideSessions.AsNoTracking().AsQueryable(), filter)
@@ -215,12 +197,10 @@ public class ServerSideSessionStore : IServerSideSessionStore
}
///
- public virtual async Task DeleteSessionsAsync(SessionFilter filter, CT ct = default)
+ public virtual async Task DeleteSessionsAsync(SessionFilter filter, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ServerSideSessionStore.DeleteSessions");
- ct = ct == CT.None ? CancellationTokenProvider.CancellationToken : ct;
-
filter.Validate();
var entities = await Filter(Context.ServerSideSessions.AsQueryable(), filter)
@@ -256,12 +236,10 @@ public class ServerSideSessionStore : IServerSideSessionStore
///
- public virtual async Task> GetAndRemoveExpiredSessionsAsync(int count, CT ct = default)
+ public virtual async Task> GetAndRemoveExpiredSessionsAsync(int count, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ServerSideSessionStore.GetAndRemoveExpiredSessions");
- ct = ct == CT.None ? CancellationTokenProvider.CancellationToken : ct;
-
var entities = await Context.ServerSideSessions
.Where(x => x.Expires < DateTime.UtcNow)
.OrderBy(x => x.Id)
@@ -295,12 +273,10 @@ public class ServerSideSessionStore : IServerSideSessionStore
}
///
- public virtual async Task> QuerySessionsAsync(SessionQuery filter = null, CT ct = default)
+ public virtual async Task> QuerySessionsAsync(Ct ct, SessionQuery filter = null)
{
using var activity = Tracing.StoreActivitySource.StartActivity("ServerSideSessionStore.QuerySessions");
- ct = ct == CT.None ? CancellationTokenProvider.CancellationToken : ct;
-
// it's possible that this implementation could have been done differently (e.g. use the page number for the token)
// but it was done deliberately in such a way to allow document databases to mimic the logic
// and omit features not supported (such as total count, total pages, and current page)
@@ -338,7 +314,7 @@ public class ServerSideSessionStore : IServerSideSessionStore
// we need to start over and re-query from the beginning.
filter.ResultsToken = null;
filter.RequestPriorResults = false;
- return await QuerySessionsAsync(filter, ct);
+ return await QuerySessionsAsync(ct, filter);
}
}
else
@@ -401,7 +377,7 @@ public class ServerSideSessionStore : IServerSideSessionStore
Ticket = entity.Data,
}).ToArray();
- private static async Task NextPage(IQueryable query, int last, SessionPaginationContext pagination, CT ct)
+ private static async Task NextPage(IQueryable query, int last, SessionPaginationContext pagination, Ct ct)
{
pagination.Items = await query.OrderBy(x => x.Id)
// if lastResultsId is zero, then this will just start at beginning
@@ -429,7 +405,7 @@ public class ServerSideSessionStore : IServerSideSessionStore
}
}
- private static async Task PreviousPage(IQueryable query, int first, SessionPaginationContext pagination, CT ct)
+ private static async Task PreviousPage(IQueryable query, int first, SessionPaginationContext pagination, Ct ct)
{
// sets query at the prior record from the last results, but in reverse order
pagination.Items = await query.OrderByDescending(x => x.Id)
diff --git a/identity-server/src/EntityFramework.Storage/Stores/SigningKeyStore.cs b/identity-server/src/EntityFramework.Storage/Stores/SigningKeyStore.cs
index 318d7a6cd..fb574cf24 100644
--- a/identity-server/src/EntityFramework.Storage/Stores/SigningKeyStore.cs
+++ b/identity-server/src/EntityFramework.Storage/Stores/SigningKeyStore.cs
@@ -5,7 +5,6 @@
using Duende.IdentityServer.EntityFramework.Entities;
using Duende.IdentityServer.EntityFramework.Interfaces;
using Duende.IdentityServer.Models;
-using Duende.IdentityServer.Services;
using Duende.IdentityServer.Stores;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
@@ -25,11 +24,6 @@ public class SigningKeyStore : ISigningKeyStore
///
protected readonly IPersistedGrantDbContext Context;
- ///
- /// The CancellationToken provider.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -40,26 +34,25 @@ public class SigningKeyStore : ISigningKeyStore
///
/// The context.
/// The logger.
- ///
/// context
- public SigningKeyStore(IPersistedGrantDbContext context, ILogger logger, ICancellationTokenProvider cancellationTokenProvider)
+ public SigningKeyStore(IPersistedGrantDbContext context, ILogger logger)
{
Context = context ?? throw new ArgumentNullException(nameof(context));
Logger = logger;
- CancellationTokenProvider = cancellationTokenProvider;
}
///
/// Loads all keys from store.
///
+ /// The cancellation token.
///
- public async Task> LoadKeysAsync()
+ public async Task> LoadKeysAsync(Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("SigningKeyStore.LoadKeys");
var entities = await Context.Keys.Where(x => x.Use == Use)
.AsNoTracking()
- .ToArrayAsync(CancellationTokenProvider.CancellationToken);
+ .ToArrayAsync(ct);
return entities.Select(key => new SerializedKey
{
Id = key.Id,
@@ -76,8 +69,9 @@ public class SigningKeyStore : ISigningKeyStore
/// Persists new key in store.
///
///
+ /// The cancellation token.
///
- public async Task StoreKeyAsync(SerializedKey key)
+ public async Task StoreKeyAsync(SerializedKey key, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("SigningKeyStore.StoreKey");
@@ -93,26 +87,27 @@ public class SigningKeyStore : ISigningKeyStore
IsX509Certificate = key.IsX509Certificate
};
Context.Keys.Add(entity);
- await Context.SaveChangesAsync(CancellationTokenProvider.CancellationToken);
+ await Context.SaveChangesAsync(ct);
}
///
/// Deletes key from storage.
///
///
+ /// The cancellation token.
///
- public async Task DeleteKeyAsync(string id)
+ public async Task DeleteKeyAsync(string id, Ct ct)
{
using var activity = Tracing.StoreActivitySource.StartActivity("SigningKeyStore.DeleteKey");
var item = await Context.Keys.Where(x => x.Use == Use && x.Id == id)
- .FirstOrDefaultAsync(CancellationTokenProvider.CancellationToken);
+ .FirstOrDefaultAsync(ct);
if (item != null)
{
try
{
Context.Keys.Remove(item);
- await Context.SaveChangesAsync(CancellationTokenProvider.CancellationToken);
+ await Context.SaveChangesAsync(ct);
}
catch (DbUpdateConcurrencyException ex)
{
diff --git a/identity-server/src/EntityFramework.Storage/TokenCleanup/IOperationalStoreNotification.cs b/identity-server/src/EntityFramework.Storage/TokenCleanup/IOperationalStoreNotification.cs
index c8489fe3a..c14088dac 100644
--- a/identity-server/src/EntityFramework.Storage/TokenCleanup/IOperationalStoreNotification.cs
+++ b/identity-server/src/EntityFramework.Storage/TokenCleanup/IOperationalStoreNotification.cs
@@ -17,15 +17,15 @@ public interface IOperationalStoreNotification
/// Notification for persisted grants being removed.
///
///
- ///
+ /// The cancellation token.
///
- Task PersistedGrantsRemovedAsync(IEnumerable persistedGrants, CT ct = default);
+ Task PersistedGrantsRemovedAsync(IEnumerable persistedGrants, Ct ct);
///
/// Notification for device codes being removed.
///
- ///
- ///
+ /// The device codes being removed.
+ /// The cancellation token.
///
- Task DeviceCodesRemovedAsync(IEnumerable deviceCodes, CT ct = default);
+ Task DeviceCodesRemovedAsync(IEnumerable deviceCodes, Ct ct);
}
diff --git a/identity-server/src/EntityFramework.Storage/TokenCleanup/ITokenCleanupService.cs b/identity-server/src/EntityFramework.Storage/TokenCleanup/ITokenCleanupService.cs
index 5b5fc8a6e..f5223bcb8 100644
--- a/identity-server/src/EntityFramework.Storage/TokenCleanup/ITokenCleanupService.cs
+++ b/identity-server/src/EntityFramework.Storage/TokenCleanup/ITokenCleanupService.cs
@@ -16,8 +16,7 @@ public interface ITokenCleanupService
/// Removes expired persisted grants, expired device codes, and optionally
/// consumed persisted grants from the stores.
///
- /// A token that propagates notification
- /// that the cleanup operation should be canceled.
+ /// The cancellation token.
///
- Task CleanupGrantsAsync(CT ct = default);
+ Task CleanupGrantsAsync(Ct ct);
}
diff --git a/identity-server/src/EntityFramework.Storage/TokenCleanup/TokenCleanupService.cs b/identity-server/src/EntityFramework.Storage/TokenCleanup/TokenCleanupService.cs
index 0a0e0d4dc..d64acd443 100644
--- a/identity-server/src/EntityFramework.Storage/TokenCleanup/TokenCleanupService.cs
+++ b/identity-server/src/EntityFramework.Storage/TokenCleanup/TokenCleanupService.cs
@@ -43,7 +43,7 @@ public class TokenCleanupService : ITokenCleanupService
}
///
- public async Task CleanupGrantsAsync(CT ct = default)
+ public async Task CleanupGrantsAsync(Ct ct)
{
try
{
@@ -63,7 +63,7 @@ public class TokenCleanupService : ITokenCleanupService
/// Removes the stale persisted grants.
///
///
- protected virtual async Task RemoveGrantsAsync(CT ct = default)
+ protected virtual async Task RemoveGrantsAsync(Ct ct)
{
await RemoveExpiredPersistedGrantsAsync(ct);
if (_options.RemoveConsumedTokens)
@@ -76,7 +76,7 @@ public class TokenCleanupService : ITokenCleanupService
/// Removes the expired persisted grants.
///
///
- protected virtual async Task RemoveExpiredPersistedGrantsAsync(CT ct = default)
+ protected virtual async Task RemoveExpiredPersistedGrantsAsync(Ct ct)
{
var found = int.MaxValue;
@@ -145,7 +145,7 @@ public class TokenCleanupService : ITokenCleanupService
/// Removes the consumed persisted grants.
///
///
- protected virtual async Task RemoveConsumedPersistedGrantsAsync(CT ct = default)
+ protected virtual async Task RemoveConsumedPersistedGrantsAsync(Ct ct)
{
var found = int.MaxValue;
@@ -208,7 +208,7 @@ public class TokenCleanupService : ITokenCleanupService
/// Removes the stale device codes.
///
///
- protected virtual async Task RemoveDeviceCodesAsync(CT ct = default)
+ protected virtual async Task RemoveDeviceCodesAsync(Ct ct)
{
var found = int.MaxValue;
@@ -264,7 +264,7 @@ public class TokenCleanupService : ITokenCleanupService
///
/// Removes stale pushed authorization requests.
///
- protected virtual async Task RemovePushedAuthorizationRequestsAsync(CT ct = default)
+ protected virtual async Task RemovePushedAuthorizationRequestsAsync(Ct ct)
{
var found = int.MaxValue;
diff --git a/identity-server/src/EntityFramework/Services/CorsPolicyService.cs b/identity-server/src/EntityFramework/Services/CorsPolicyService.cs
index 8df28b106..5d80c7725 100644
--- a/identity-server/src/EntityFramework/Services/CorsPolicyService.cs
+++ b/identity-server/src/EntityFramework/Services/CorsPolicyService.cs
@@ -20,11 +20,6 @@ public class CorsPolicyService : ICorsPolicyService
///
protected readonly IConfigurationDbContext DbContext;
- ///
- /// The CancellationToken provider.
- ///
- protected readonly ICancellationTokenProvider CancellationTokenProvider;
-
///
/// The logger.
///
@@ -36,21 +31,15 @@ public class CorsPolicyService : ICorsPolicyService
///
/// The DbContext
/// The logger.
- ///
/// context
- public CorsPolicyService(IConfigurationDbContext dbContext, ILogger logger, ICancellationTokenProvider cancellationTokenProvider)
+ public CorsPolicyService(IConfigurationDbContext dbContext, ILogger logger)
{
DbContext = dbContext;
Logger = logger;
- CancellationTokenProvider = cancellationTokenProvider;
}
- ///
- /// Determines whether origin is allowed.
- ///
- /// The origin.
- ///
- public async Task IsOriginAllowedAsync(string origin)
+ ///
+ public async Task IsOriginAllowedAsync(string origin, Ct ct)
{
#pragma warning disable CA1308 // this has historically been normalized to lower case and RFC 3986 instructs to normalize to lowercase
origin = origin.ToLowerInvariant();
@@ -60,7 +49,7 @@ public class CorsPolicyService : ICorsPolicyService
where o.Origin == origin
select o;
- var isAllowed = await query.AnyAsync(CancellationTokenProvider.CancellationToken);
+ var isAllowed = await query.AnyAsync(ct);
Logger.LogDebug("Origin {origin} is allowed: {originAllowed}", origin, isAllowed);
diff --git a/identity-server/src/EntityFramework/TokenCleanupHost.cs b/identity-server/src/EntityFramework/TokenCleanupHost.cs
index 60153bb24..4431a4aca 100644
--- a/identity-server/src/EntityFramework/TokenCleanupHost.cs
+++ b/identity-server/src/EntityFramework/TokenCleanupHost.cs
@@ -38,7 +38,7 @@ public class TokenCleanupHost : IHostedService
///
/// Starts the token cleanup polling.
///
- public Task StartAsync(CT ct)
+ public Task StartAsync(Ct ct)
{
if (_options.EnableTokenCleanup)
{
@@ -60,7 +60,7 @@ public class TokenCleanupHost : IHostedService
///
/// Stops the token cleanup polling.
///
- public async Task StopAsync(CT ct)
+ public async Task StopAsync(Ct ct)
{
if (_options.EnableTokenCleanup)
{
@@ -76,7 +76,7 @@ public class TokenCleanupHost : IHostedService
}
}
- private async Task StartInternalAsync(CT ct)
+ private async Task StartInternalAsync(Ct ct)
{
// Start the first run at a random interval.
var delay = _options.FuzzTokenCleanupStart
@@ -121,7 +121,7 @@ public class TokenCleanupHost : IHostedService
}
}
- private async Task RemoveExpiredGrantsAsync(CT ct = default)
+ private async Task RemoveExpiredGrantsAsync(Ct ct)
{
try
{
diff --git a/identity-server/src/IdentityServer.ConformanceReport/IdentityServerClientStore.cs b/identity-server/src/IdentityServer.ConformanceReport/IdentityServerClientStore.cs
index 15f36ea9e..b29e71015 100644
--- a/identity-server/src/IdentityServer.ConformanceReport/IdentityServerClientStore.cs
+++ b/identity-server/src/IdentityServer.ConformanceReport/IdentityServerClientStore.cs
@@ -14,10 +14,10 @@ internal sealed class IdentityServerClientStore(IClientStore clientStore) : ICon
#pragma warning restore CA1812
{
public async Task> GetAllClientsAsync(
- CancellationToken ct = default)
+ CancellationToken ct)
{
var clients = new List();
- await foreach (var client in clientStore.GetAllClientsAsync().WithCancellation(ct))
+ await foreach (var client in clientStore.GetAllClientsAsync(ct))
{
clients.Add(client.ToConformanceReportClient());
}
diff --git a/identity-server/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Additional.cs b/identity-server/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Additional.cs
index d88e18730..265c9a373 100644
--- a/identity-server/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Additional.cs
+++ b/identity-server/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Additional.cs
@@ -454,7 +454,7 @@ public static class IdentityServerBuilderExtensionsAdditional
var httpClient = httpClientFactory.CreateClient(name);
var loggerFactory = s.GetRequiredService();
- return new DefaultBackChannelLogoutHttpClient(httpClient, loggerFactory, new NoneCancellationTokenProvider());
+ return new DefaultBackChannelLogoutHttpClient(httpClient, loggerFactory);
});
return httpBuilder;
@@ -491,7 +491,7 @@ public static class IdentityServerBuilderExtensionsAdditional
var loggerFactory = s.GetRequiredService();
var options = s.GetRequiredService();
- return new DefaultJwtRequestUriHttpClient(httpClient, options, loggerFactory, new NoneCancellationTokenProvider());
+ return new DefaultJwtRequestUriHttpClient(httpClient, options, loggerFactory);
});
return httpBuilder;
diff --git a/identity-server/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Core.cs b/identity-server/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Core.cs
index f524c677e..d595bc7fd 100644
--- a/identity-server/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Core.cs
+++ b/identity-server/src/IdentityServer/Configuration/DependencyInjection/BuilderExtensions/Core.cs
@@ -252,7 +252,6 @@ public static class IdentityServerBuilderExtensionsCore
///
public static IIdentityServerBuilder AddPluggableServices(this IIdentityServerBuilder builder)
{
- builder.Services.TryAddTransient();
builder.Services.TryAddTransient();
builder.Services.TryAddTransient();
builder.Services.TryAddTransient();
diff --git a/identity-server/src/IdentityServer/Endpoints/AuthorizeCallbackEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/AuthorizeCallbackEndpoint.cs
index 51dca4cc2..1d19bfb14 100644
--- a/identity-server/src/IdentityServer/Endpoints/AuthorizeCallbackEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/AuthorizeCallbackEndpoint.cs
@@ -45,9 +45,9 @@ internal class AuthorizeCallbackEndpoint : AuthorizeEndpointBase
Logger.LogDebug("Start authorize callback request");
var parameters = context.Request.Query.AsNameValueCollection();
- var user = await UserSession.GetUserAsync();
+ var user = await UserSession.GetUserAsync(context.RequestAborted);
- var result = await ProcessAuthorizeRequestAsync(parameters, user, true);
+ var result = await ProcessAuthorizeRequestAsync(parameters, user, context.RequestAborted, true);
Logger.LogTrace("End Authorize Request. Result type: {0}", result?.GetType().ToString() ?? "-none-");
diff --git a/identity-server/src/IdentityServer/Endpoints/AuthorizeEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/AuthorizeEndpoint.cs
index 7805bb32e..6bbf817a4 100644
--- a/identity-server/src/IdentityServer/Endpoints/AuthorizeEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/AuthorizeEndpoint.cs
@@ -59,8 +59,8 @@ internal class AuthorizeEndpoint : AuthorizeEndpointBase
return new StatusCodeResult(HttpStatusCode.MethodNotAllowed);
}
- var user = await UserSession.GetUserAsync();
- var result = await ProcessAuthorizeRequestAsync(values, user);
+ var user = await UserSession.GetUserAsync(context.RequestAborted);
+ var result = await ProcessAuthorizeRequestAsync(values, user, context.RequestAborted);
Logger.LogTrace("End authorize request. result type: {0}", result?.GetType().ToString() ?? "-none-");
diff --git a/identity-server/src/IdentityServer/Endpoints/AuthorizeEndpointBase.cs b/identity-server/src/IdentityServer/Endpoints/AuthorizeEndpointBase.cs
index 7b486a998..cbffae7cb 100644
--- a/identity-server/src/IdentityServer/Endpoints/AuthorizeEndpointBase.cs
+++ b/identity-server/src/IdentityServer/Endpoints/AuthorizeEndpointBase.cs
@@ -63,7 +63,7 @@ internal abstract class AuthorizeEndpointBase : IEndpointHandler
public abstract Task ProcessAsync(HttpContext context);
- internal async Task ProcessAuthorizeRequestAsync(NameValueCollection parameters, ClaimsPrincipal user, bool checkConsentResponse = false)
+ internal async Task ProcessAuthorizeRequestAsync(NameValueCollection parameters, ClaimsPrincipal user, Ct ct, bool checkConsentResponse = false)
{
if (user != null)
{
@@ -77,19 +77,20 @@ internal abstract class AuthorizeEndpointBase : IEndpointHandler
if (checkConsentResponse && _authorizationParametersMessageStore != null)
{
var messageStoreId = parameters[Constants.AuthorizationParamsStore.MessageStoreIdParameterName];
- var entry = await _authorizationParametersMessageStore.ReadAsync(messageStoreId);
+ var entry = await _authorizationParametersMessageStore.ReadAsync(messageStoreId, ct);
parameters = entry?.Data.FromFullDictionary() ?? new NameValueCollection();
- await _authorizationParametersMessageStore.DeleteAsync(messageStoreId);
+ await _authorizationParametersMessageStore.DeleteAsync(messageStoreId, ct);
}
// validate request
- var result = await _validator.ValidateAsync(parameters, user);
+ var result = await _validator.ValidateAsync(parameters, ct, user);
if (result.IsError)
{
return await CreateErrorResultAsync(
"Request validation failed",
+ ct,
result.ValidatedRequest,
result.Error,
result.ErrorDescription);
@@ -105,11 +106,11 @@ internal abstract class AuthorizeEndpointBase : IEndpointHandler
{
var consentRequest = new ConsentRequest(result.ValidatedRequest.Raw, user?.GetSubjectId());
consentRequestId = consentRequest.Id;
- consent = await _consentResponseStore.ReadAsync(consentRequestId);
+ consent = await _consentResponseStore.ReadAsync(consentRequestId, ct);
if (consent != null && consent.Data == null)
{
- return await CreateErrorResultAsync("consent message is missing data", result.ValidatedRequest);
+ return await CreateErrorResultAsync("consent message is missing data", ct, result.ValidatedRequest);
}
}
@@ -117,10 +118,10 @@ internal abstract class AuthorizeEndpointBase : IEndpointHandler
LogRequest(request);
// determine user interaction
- var interactionResult = await _interactionGenerator.ProcessInteractionAsync(request, consent?.Data);
+ var interactionResult = await _interactionGenerator.ProcessInteractionAsync(request, consent?.Data, ct);
if (interactionResult.ResponseType == InteractionResponseType.Error)
{
- return await CreateErrorResultAsync("Interaction generator error", request, interactionResult.Error, interactionResult.ErrorDescription, false);
+ return await CreateErrorResultAsync("Interaction generator error", ct, request, interactionResult.Error, interactionResult.ErrorDescription, false);
}
if (interactionResult.ResponseType == InteractionResponseType.UserInteraction)
@@ -143,9 +144,9 @@ internal abstract class AuthorizeEndpointBase : IEndpointHandler
}
}
- var response = await _authorizeResponseGenerator.CreateResponseAsync(request);
+ var response = await _authorizeResponseGenerator.CreateResponseAsync(request, ct);
- await RaiseResponseEventAsync(response);
+ await RaiseResponseEventAsync(response, ct);
LogResponse(response);
@@ -155,13 +156,14 @@ internal abstract class AuthorizeEndpointBase : IEndpointHandler
{
if (consentRequestId != null)
{
- await _consentResponseStore.DeleteAsync(consentRequestId);
+ await _consentResponseStore.DeleteAsync(consentRequestId, ct);
}
}
}
protected async Task CreateErrorResultAsync(
string logMessage,
+ Ct ct,
ValidatedAuthorizeRequest request = null,
string error = OidcConstants.AuthorizeErrors.ServerError,
string errorDescription = null,
@@ -181,7 +183,7 @@ internal abstract class AuthorizeEndpointBase : IEndpointHandler
}
// TODO: should we raise a token failure event for all errors to the authorize endpoint?
- await RaiseFailureEventAsync(request, error, errorDescription);
+ await RaiseFailureEventAsync(request, error, errorDescription, ct);
return new AuthorizeResult(new AuthorizeResponse
{
@@ -223,17 +225,17 @@ internal abstract class AuthorizeEndpointBase : IEndpointHandler
}
}
- private Task RaiseFailureEventAsync(ValidatedAuthorizeRequest request, string error, string errorDescription)
+ private Task RaiseFailureEventAsync(ValidatedAuthorizeRequest request, string error, string errorDescription, Ct ct)
{
Telemetry.Metrics.TokenIssuedFailure(
request.ClientId,
request.GrantType,
request.AuthorizeRequestType,
error);
- return _events.RaiseAsync(new TokenIssuedFailureEvent(request, error, errorDescription));
+ return _events.RaiseAsync(new TokenIssuedFailureEvent(request, error, errorDescription), ct);
}
- private Task RaiseResponseEventAsync(AuthorizeResponse response)
+ private Task RaiseResponseEventAsync(AuthorizeResponse response, Ct ct)
{
if (!response.IsError)
{
@@ -247,9 +249,9 @@ internal abstract class AuthorizeEndpointBase : IEndpointHandler
false,
ProofType.None,
response.IdentityToken.IsPresent());
- return _events.RaiseAsync(new TokenIssuedSuccessEvent(response));
+ return _events.RaiseAsync(new TokenIssuedSuccessEvent(response), ct);
}
- return RaiseFailureEventAsync(response.Request, response.Error, response.ErrorDescription);
+ return RaiseFailureEventAsync(response.Request, response.Error, response.ErrorDescription, ct);
}
}
diff --git a/identity-server/src/IdentityServer/Endpoints/BackchannelAuthenticationEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/BackchannelAuthenticationEndpoint.cs
index aea0cc79b..0ddfe604c 100644
--- a/identity-server/src/IdentityServer/Endpoints/BackchannelAuthenticationEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/BackchannelAuthenticationEndpoint.cs
@@ -70,7 +70,7 @@ internal class BackchannelAuthenticationEndpoint : IEndpointHandler
_logger.LogDebug("Start backchannel authentication request.");
// validate client
- var clientResult = await _clientValidator.ValidateAsync(context);
+ var clientResult = await _clientValidator.ValidateAsync(context, context.RequestAborted);
if (clientResult.IsError)
{
var error = clientResult.Error ?? OidcConstants.BackchannelAuthenticationRequestErrors.InvalidClient;
@@ -80,22 +80,22 @@ internal class BackchannelAuthenticationEndpoint : IEndpointHandler
}
// validate request
- var form = (await context.Request.ReadFormAsync()).AsNameValueCollection();
+ var form = (await context.Request.ReadFormAsync(context.RequestAborted)).AsNameValueCollection();
_logger.LogTrace("Calling into backchannel authentication request validator: {type}", _requestValidator.GetType().FullName);
- var requestResult = await _requestValidator.ValidateRequestAsync(form, clientResult);
+ var requestResult = await _requestValidator.ValidateRequestAsync(form, clientResult, context.RequestAborted);
if (requestResult.IsError)
{
- await _events.RaiseAsync(new BackchannelAuthenticationFailureEvent(requestResult));
+ await _events.RaiseAsync(new BackchannelAuthenticationFailureEvent(requestResult), context.RequestAborted);
Telemetry.Metrics.BackChannelAuthenticationFailure(clientResult.Client?.ClientId, requestResult.Error);
return Error(requestResult.Error, requestResult.ErrorDescription);
}
// create response
_logger.LogTrace("Calling into backchannel authentication request response generator: {type}", _responseGenerator.GetType().FullName);
- var response = await _responseGenerator.ProcessAsync(requestResult);
+ var response = await _responseGenerator.ProcessAsync(requestResult, context.RequestAborted);
- await _events.RaiseAsync(new BackchannelAuthenticationSuccessEvent(requestResult));
+ await _events.RaiseAsync(new BackchannelAuthenticationSuccessEvent(requestResult), context.RequestAborted);
Telemetry.Metrics.BackChannelAuthentication(clientResult.Client.ClientId);
LogResponse(response, requestResult);
diff --git a/identity-server/src/IdentityServer/Endpoints/BaseDiscoveryEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/BaseDiscoveryEndpoint.cs
index db79e5fe1..d44a39d71 100644
--- a/identity-server/src/IdentityServer/Endpoints/BaseDiscoveryEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/BaseDiscoveryEndpoint.cs
@@ -25,20 +25,20 @@ internal abstract class BaseDiscoveryEndpoint(
var distributedCache = context.RequestServices.GetRequiredService();
if (distributedCache is not null)
{
- return await GetCachedDiscoveryDocument(distributedCache, baseUrl, issuerUri);
+ return await GetCachedDiscoveryDocument(distributedCache, baseUrl, issuerUri, context.RequestAborted);
}
// fall through to default implementation if there is no cache provider registered
}
- var response = await ResponseGenerator.CreateDiscoveryDocumentAsync(baseUrl, issuerUri);
+ var response = await ResponseGenerator.CreateDiscoveryDocumentAsync(baseUrl, issuerUri, context.RequestAborted);
return new DiscoveryDocumentResult(response, Options.Discovery.ResponseCacheInterval);
}
private async Task GetCachedDiscoveryDocument(IDistributedCache cache, string baseUrl,
- string issuerUri)
+ string issuerUri, Ct ct)
{
var key = $"discoveryDocument/{baseUrl}/{issuerUri}";
- var json = await cache.GetStringAsync(key);
+ var json = await cache.GetStringAsync(key, ct);
if (json is not null)
{
@@ -49,7 +49,7 @@ internal abstract class BaseDiscoveryEndpoint(
}
var entries =
- await ResponseGenerator.CreateDiscoveryDocumentAsync(baseUrl, issuerUri);
+ await ResponseGenerator.CreateDiscoveryDocumentAsync(baseUrl, issuerUri, ct);
var expirationFromNow = Options.Preview.DiscoveryDocumentCacheDuration;
@@ -62,7 +62,7 @@ internal abstract class BaseDiscoveryEndpoint(
await cache.SetStringAsync(key, result.Json, new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow = expirationFromNow,
- });
+ }, ct);
return result;
}
diff --git a/identity-server/src/IdentityServer/Endpoints/DeviceAuthorizationEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/DeviceAuthorizationEndpoint.cs
index b9a417819..a92cc3b83 100644
--- a/identity-server/src/IdentityServer/Endpoints/DeviceAuthorizationEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/DeviceAuthorizationEndpoint.cs
@@ -79,7 +79,7 @@ internal class DeviceAuthorizationEndpoint : IEndpointHandler
_logger.LogDebug("Start device authorize request.");
// validate client
- var clientResult = await _clientValidator.ValidateAsync(context);
+ var clientResult = await _clientValidator.ValidateAsync(context, context.RequestAborted);
if (clientResult.IsError)
{
var error = clientResult.Error ?? OidcConstants.TokenErrors.InvalidClient;
@@ -88,21 +88,21 @@ internal class DeviceAuthorizationEndpoint : IEndpointHandler
}
// validate request
- var form = (await context.Request.ReadFormAsync()).AsNameValueCollection();
- var requestResult = await _requestValidator.ValidateAsync(form, clientResult);
+ var form = (await context.Request.ReadFormAsync(context.RequestAborted)).AsNameValueCollection();
+ var requestResult = await _requestValidator.ValidateAsync(form, clientResult, context.RequestAborted);
if (requestResult.IsError)
{
- await _events.RaiseAsync(new DeviceAuthorizationFailureEvent(requestResult));
+ await _events.RaiseAsync(new DeviceAuthorizationFailureEvent(requestResult), context.RequestAborted);
Telemetry.Metrics.DeviceAuthenticationFailure(clientResult.Client.ClientId, requestResult.Error);
return Error(requestResult.Error, requestResult.ErrorDescription);
}
// create response
_logger.LogTrace("Calling into device authorize response generator: {type}", _responseGenerator.GetType().FullName);
- var response = await _responseGenerator.ProcessAsync(requestResult, _urls.BaseUrl);
+ var response = await _responseGenerator.ProcessAsync(requestResult, _urls.BaseUrl, context.RequestAborted);
- await _events.RaiseAsync(new DeviceAuthorizationSuccessEvent(response, requestResult));
+ await _events.RaiseAsync(new DeviceAuthorizationSuccessEvent(response, requestResult), context.RequestAborted);
Telemetry.Metrics.DeviceAuthentication(clientResult.Client.ClientId);
// return result
diff --git a/identity-server/src/IdentityServer/Endpoints/DiscoveryEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/DiscoveryEndpoint.cs
index a44a9bbee..1941aaf64 100644
--- a/identity-server/src/IdentityServer/Endpoints/DiscoveryEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/DiscoveryEndpoint.cs
@@ -56,7 +56,7 @@ internal class DiscoveryEndpoint : BaseDiscoveryEndpoint, IEndpointHandler
}
var baseUrl = _urls.BaseUrl;
- var issuerUri = await _issuerNameService.GetCurrentAsync();
+ var issuerUri = await _issuerNameService.GetCurrentAsync(context.RequestAborted);
// generate response
_logger.LogTrace("Calling into discovery response generator: {type}", ResponseGenerator.GetType().FullName);
diff --git a/identity-server/src/IdentityServer/Endpoints/DiscoveryKeyEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/DiscoveryKeyEndpoint.cs
index 9a2cfc1be..143030e6d 100644
--- a/identity-server/src/IdentityServer/Endpoints/DiscoveryKeyEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/DiscoveryKeyEndpoint.cs
@@ -53,7 +53,7 @@ internal class DiscoveryKeyEndpoint : IEndpointHandler
// generate response
_logger.LogTrace("Calling into discovery response generator: {type}", _responseGenerator.GetType().FullName);
- var response = await _responseGenerator.CreateJwkDocumentAsync();
+ var response = await _responseGenerator.CreateJwkDocumentAsync(context.RequestAborted);
return new JsonWebKeysResult(response, _options.Discovery.ResponseCacheInterval);
}
diff --git a/identity-server/src/IdentityServer/Endpoints/EndSessionCallbackEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/EndSessionCallbackEndpoint.cs
index 5dbff422f..524ebf613 100644
--- a/identity-server/src/IdentityServer/Endpoints/EndSessionCallbackEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/EndSessionCallbackEndpoint.cs
@@ -38,7 +38,7 @@ internal class EndSessionCallbackEndpoint : IEndpointHandler
_logger.LogDebug("Processing signout callback request");
var parameters = context.Request.Query.AsNameValueCollection();
- var result = await _endSessionRequestValidator.ValidateCallbackAsync(parameters);
+ var result = await _endSessionRequestValidator.ValidateCallbackAsync(parameters, context.RequestAborted);
if (!result.IsError)
{
diff --git a/identity-server/src/IdentityServer/Endpoints/EndSessionEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/EndSessionEndpoint.cs
index efc8900ec..fa0a569cd 100644
--- a/identity-server/src/IdentityServer/Endpoints/EndSessionEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/EndSessionEndpoint.cs
@@ -59,7 +59,7 @@ internal class EndSessionEndpoint : IEndpointHandler
}
else if (HttpMethods.IsPost(context.Request.Method))
{
- parameters = (await context.Request.ReadFormAsync()).AsNameValueCollection();
+ parameters = (await context.Request.ReadFormAsync(context.RequestAborted)).AsNameValueCollection();
}
else
{
@@ -67,11 +67,11 @@ internal class EndSessionEndpoint : IEndpointHandler
return new StatusCodeResult(HttpStatusCode.MethodNotAllowed);
}
- var user = await _userSession.GetUserAsync();
+ var user = await _userSession.GetUserAsync(context.RequestAborted);
_logger.LogDebug("Processing signout request for {subjectId}", user?.GetSubjectId() ?? "anonymous");
- var result = await _endSessionRequestValidator.ValidateAsync(parameters, user);
+ var result = await _endSessionRequestValidator.ValidateAsync(parameters, user, context.RequestAborted);
if (result.IsError)
{
diff --git a/identity-server/src/IdentityServer/Endpoints/IntrospectionEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/IntrospectionEndpoint.cs
index a5923fa3c..f4de469ab 100644
--- a/identity-server/src/IdentityServer/Endpoints/IntrospectionEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/IntrospectionEndpoint.cs
@@ -100,10 +100,10 @@ internal class IntrospectionEndpoint : IEndpointHandler
ApiResource api = null;
Client client = null;
- var apiResult = await _apiSecretValidator.ValidateAsync(context);
+ var apiResult = await _apiSecretValidator.ValidateAsync(context, context.RequestAborted);
if (apiResult.IsError)
{
- clientResult = await _clientValidator.ValidateAsync(context);
+ clientResult = await _clientValidator.ValidateAsync(context, context.RequestAborted);
if (clientResult.IsError)
{
_logger.LogError("Unauthorized call introspection endpoint. aborting.");
@@ -123,12 +123,12 @@ internal class IntrospectionEndpoint : IEndpointHandler
var callerName = api?.Name ?? client.ClientId;
- var body = await context.Request.ReadFormAsync();
+ var body = await context.Request.ReadFormAsync(context.RequestAborted);
if (body == null)
{
_logger.LogError("Malformed request body. aborting.");
const string error = "Malformed request body";
- await _events.RaiseAsync(new TokenIntrospectionFailureEvent(callerName, error));
+ await _events.RaiseAsync(new TokenIntrospectionFailureEvent(callerName, error), context.RequestAborted);
Telemetry.Metrics.IntrospectionFailure(callerName, error);
return new StatusCodeResult(HttpStatusCode.BadRequest);
}
@@ -141,18 +141,18 @@ internal class IntrospectionEndpoint : IEndpointHandler
Api = api,
Client = client,
};
- var validationResult = await _requestValidator.ValidateAsync(validationRequest);
+ var validationResult = await _requestValidator.ValidateAsync(validationRequest, context.RequestAborted);
if (validationResult.IsError)
{
LogFailure(validationResult.Error, callerName);
- await _events.RaiseAsync(new TokenIntrospectionFailureEvent(callerName, validationResult.Error));
+ await _events.RaiseAsync(new TokenIntrospectionFailureEvent(callerName, validationResult.Error), context.RequestAborted);
Telemetry.Metrics.IntrospectionFailure(callerName, validationResult.Error);
return new BadRequestResult(validationResult.Error);
}
// response generation
_logger.LogTrace("Calling into introspection response generator: {type}", _responseGenerator.GetType().FullName);
- var response = await _responseGenerator.ProcessAsync(validationResult);
+ var response = await _responseGenerator.ProcessAsync(validationResult, context.RequestAborted);
// render result
LogSuccess(validationResult.IsActive, callerName);
diff --git a/identity-server/src/IdentityServer/Endpoints/OAuthMetadataEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/OAuthMetadataEndpoint.cs
index f00fd120a..8db1fb715 100644
--- a/identity-server/src/IdentityServer/Endpoints/OAuthMetadataEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/OAuthMetadataEndpoint.cs
@@ -51,7 +51,7 @@ internal class OAuthMetadataEndpoint(
}
context.Request.Path.StartsWithSegments("/.well-known/oauth-authorization-server", StringComparison.OrdinalIgnoreCase, out var issuerSubPath);
- if (!await issuerPathValidator.ValidateAsync(issuerSubPath))
+ if (!await issuerPathValidator.ValidateAsync(issuerSubPath, context.RequestAborted))
{
logger.LogDebug("Request for OAuth discovery document contains invalid sub-path. Returning 404");
return new StatusCodeResult(HttpStatusCode.NotFound);
@@ -62,7 +62,7 @@ internal class OAuthMetadataEndpoint(
serverUrls.BasePath = issuerSubPath;
}
- var issuerUri = await issuerNameService.GetCurrentAsync();
+ var issuerUri = await issuerNameService.GetCurrentAsync(context.RequestAborted);
var baseUrl = serverUrls.BaseUrl;
if (!issuerUri.Equals($"{context.Request.Scheme}://{context.Request.Host}{issuerSubPath}", StringComparison.Ordinal))
diff --git a/identity-server/src/IdentityServer/Endpoints/PushedAuthorizationEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/PushedAuthorizationEndpoint.cs
index 32a198982..fb0d22e92 100644
--- a/identity-server/src/IdentityServer/Endpoints/PushedAuthorizationEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/PushedAuthorizationEndpoint.cs
@@ -56,7 +56,7 @@ internal class PushedAuthorizationEndpoint : IEndpointHandler
NameValueCollection values;
if (HttpMethods.IsPost(context.Request.Method))
{
- var form = await context.Request.ReadFormAsync();
+ var form = await context.Request.ReadFormAsync(context.RequestAborted);
values = form.AsNameValueCollection();
}
else
@@ -65,7 +65,7 @@ internal class PushedAuthorizationEndpoint : IEndpointHandler
}
// Authenticate Client
- var client = await _clientValidator.ValidateAsync(context);
+ var client = await _clientValidator.ValidateAsync(context, context.RequestAborted);
if (client.IsError)
{
return CreateErrorResult(
@@ -87,11 +87,11 @@ internal class PushedAuthorizationEndpoint : IEndpointHandler
validationContext.DPoPProofToken = dpopHeader.First();
//Note: if the client authenticated with mTLS, we need to know to properly validate the htu of the DPoP proof token
- validationContext.ClientCertificate = await context.Connection.GetClientCertificateAsync();
+ validationContext.ClientCertificate = await context.Connection.GetClientCertificateAsync(context.RequestAborted);
}
// Perform validations specific to PAR, as well as validation of the pushed parameters
- var parValidationResult = await _parValidator.ValidateAsync(validationContext);
+ var parValidationResult = await _parValidator.ValidateAsync(validationContext, context.RequestAborted);
if (parValidationResult.IsError)
{
return CreateErrorResult(
@@ -110,7 +110,7 @@ internal class PushedAuthorizationEndpoint : IEndpointHandler
throw new InvalidOperationException("Invalid PAR validation result: success without a validated request");
}
- var response = await _responseGenerator.CreateResponseAsync(parValidationResult.ValidatedRequest);
+ var response = await _responseGenerator.CreateResponseAsync(parValidationResult.ValidatedRequest, context.RequestAborted);
switch (response)
{
diff --git a/identity-server/src/IdentityServer/Endpoints/Results/AuthorizeInteractionPageResult.cs b/identity-server/src/IdentityServer/Endpoints/Results/AuthorizeInteractionPageResult.cs
index 4b3757250..fd7cfcced 100644
--- a/identity-server/src/IdentityServer/Endpoints/Results/AuthorizeInteractionPageResult.cs
+++ b/identity-server/src/IdentityServer/Endpoints/Results/AuthorizeInteractionPageResult.cs
@@ -84,7 +84,7 @@ internal class AuthorizeInteractionPageHttpWriter : IHttpResponseWriter>(result.Request.ToOptimizedFullDictionary());
#pragma warning restore CS0618 // Type or member is obsolete
- var id = await _authorizationParametersMessageStore.WriteAsync(msg);
+ var id = await _authorizationParametersMessageStore.WriteAsync(msg, context.RequestAborted);
returnUrl = returnUrl.AddQueryString(Constants.AuthorizationParamsStore.MessageStoreIdParameterName, id);
}
else
@@ -122,7 +122,7 @@ internal class AuthorizeInteractionPageHttpWriter : IHttpResponseWriter
///
public async Task WriteHttpResponse(AuthorizeResult result, HttpContext context)
{
- await ConsumePushedAuthorizationRequest(result);
+ await ConsumePushedAuthorizationRequest(result, context.RequestAborted);
if (result.Response.IsError)
{
@@ -80,12 +80,12 @@ public class AuthorizeHttpWriter : IHttpResponseWriter
}
}
- private async Task ConsumePushedAuthorizationRequest(AuthorizeResult result)
+ private async Task ConsumePushedAuthorizationRequest(AuthorizeResult result, Ct ct)
{
var referenceValue = result.Response?.Request?.PushedAuthorizationReferenceValue;
if (referenceValue.IsPresent())
{
- await _pushedAuthorizationService.ConsumeAsync(referenceValue);
+ await _pushedAuthorizationService.ConsumeAsync(referenceValue, ct);
}
}
@@ -119,7 +119,7 @@ public class AuthorizeHttpWriter : IHttpResponseWriter
{
// success response -- track client authorization for sign-out
//_logger.LogDebug("Adding client {0} to client list cookie for subject {1}", request.ClientId, request.Subject.GetSubjectId());
- await _userSession.AddClientIdAsync(response.Request.ClientId);
+ await _userSession.AddClientIdAsync(response.Request.ClientId, context.RequestAborted);
}
await RenderAuthorizeResponseAsync(response, context);
@@ -221,13 +221,13 @@ public class AuthorizeHttpWriter : IHttpResponseWriter
var uiLocalesService = context.RequestServices.GetService();
if (uiLocalesService != null)
{
- await uiLocalesService.StoreUiLocalesForRedirectAsync(response.Request?.UiLocales);
+ await uiLocalesService.StoreUiLocalesForRedirectAsync(response.Request?.UiLocales, context.RequestAborted);
}
var errorModel = await CreateErrorMessage(response, context);
var message = new Message(errorModel, _timeProvider.GetUtcNow().UtcDateTime);
- var id = await _errorMessageStore.WriteAsync(message);
+ var id = await _errorMessageStore.WriteAsync(message, context.RequestAborted);
var errorUrl = _options.UserInteraction.ErrorUrl;
diff --git a/identity-server/src/IdentityServer/Endpoints/Results/EndSessionResult.cs b/identity-server/src/IdentityServer/Endpoints/Results/EndSessionResult.cs
index 2a98f5132..e05b65d69 100644
--- a/identity-server/src/IdentityServer/Endpoints/Results/EndSessionResult.cs
+++ b/identity-server/src/IdentityServer/Endpoints/Results/EndSessionResult.cs
@@ -66,7 +66,7 @@ internal class EndSessionHttpWriter : IHttpResponseWriter
if (logoutMessage.ContainsPayload)
{
var msg = new Message(logoutMessage, _timeProvider.GetUtcNow().UtcDateTime);
- id = await _logoutMessageStore.WriteAsync(msg);
+ id = await _logoutMessageStore.WriteAsync(msg, context.RequestAborted);
}
}
@@ -75,7 +75,7 @@ internal class EndSessionHttpWriter : IHttpResponseWriter
if (redirect.IsLocalUrl())
{
redirect = _urls.GetIdentityServerRelativeUrl(redirect);
- await _localesService.StoreUiLocalesForRedirectAsync(result.Result.ValidatedRequest?.UiLocales);
+ await _localesService.StoreUiLocalesForRedirectAsync(result.Result.ValidatedRequest?.UiLocales, context.RequestAborted);
}
if (id != null)
diff --git a/identity-server/src/IdentityServer/Endpoints/Results/IntrospectionResult.cs b/identity-server/src/IdentityServer/Endpoints/Results/IntrospectionResult.cs
index 7a13027ab..77f6023c8 100644
--- a/identity-server/src/IdentityServer/Endpoints/Results/IntrospectionResult.cs
+++ b/identity-server/src/IdentityServer/Endpoints/Results/IntrospectionResult.cs
@@ -79,12 +79,12 @@ internal class IntrospectionHttpWriter(IIssuerNameService issuerNameService, ITo
var token = new Token
{
Type = JwtClaimTypes.JwtTypes.IntrospectionJwtResponse,
- Issuer = await issuerNameService.GetCurrentAsync(),
+ Issuer = await issuerNameService.GetCurrentAsync(context.RequestAborted),
Audiences = [result.CallerName],
CreationTime = DateTime.UtcNow,
Claims = [new Claim("token_introspection", ObjectSerializer.ToString(result.Entries), IdentityServerConstants.ClaimValueTypes.Json)]
};
- var jwt = await tokenCreationService.CreateTokenAsync(token);
+ var jwt = await tokenCreationService.CreateTokenAsync(token, context.RequestAborted);
await context.Response.WriteAsync(jwt);
}
diff --git a/identity-server/src/IdentityServer/Endpoints/TokenEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/TokenEndpoint.cs
index b64739c83..37389638d 100644
--- a/identity-server/src/IdentityServer/Endpoints/TokenEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/TokenEndpoint.cs
@@ -88,7 +88,7 @@ internal class TokenEndpoint : IEndpointHandler
_logger.LogDebug("Start token request.");
// validate client
- var clientResult = await _clientValidator.ValidateAsync(context);
+ var clientResult = await _clientValidator.ValidateAsync(context, context.RequestAborted);
if (clientResult.IsError)
{
var errorMsg = clientResult.Error ?? OidcConstants.TokenErrors.InvalidClient;
@@ -97,7 +97,7 @@ internal class TokenEndpoint : IEndpointHandler
}
// validate request
- var form = (await context.Request.ReadFormAsync()).AsNameValueCollection();
+ var form = (await context.Request.ReadFormAsync(context.RequestAborted)).AsNameValueCollection();
_logger.LogTrace("Calling into token request validator: {type}", _requestValidator.GetType().FullName);
var requestContext = new TokenRequestValidationContext
@@ -113,7 +113,7 @@ internal class TokenEndpoint : IEndpointHandler
return error;
}
- var requestResult = await _requestValidator.ValidateRequestAsync(requestContext);
+ var requestResult = await _requestValidator.ValidateRequestAsync(requestContext, context.RequestAborted);
if (requestResult.IsError)
{
// Note: this is an expected case in the normal DPoP flow and is not a real failure event.
@@ -124,7 +124,7 @@ internal class TokenEndpoint : IEndpointHandler
}
else
{
- await _events.RaiseAsync(new TokenIssuedFailureEvent(requestResult));
+ await _events.RaiseAsync(new TokenIssuedFailureEvent(requestResult), context.RequestAborted);
}
Telemetry.Metrics.TokenIssuedFailure(
@@ -136,9 +136,9 @@ internal class TokenEndpoint : IEndpointHandler
// create response
_logger.LogTrace("Calling into token request response generator: {type}", _responseGenerator.GetType().FullName);
- var response = await _responseGenerator.ProcessAsync(requestResult);
+ var response = await _responseGenerator.ProcessAsync(requestResult, context.RequestAborted);
- await _events.RaiseAsync(new TokenIssuedSuccessEvent(response, requestResult));
+ await _events.RaiseAsync(new TokenIssuedSuccessEvent(response, requestResult), context.RequestAborted);
Telemetry.Metrics.TokenIssued(clientResult.Client.ClientId, requestResult.ValidatedRequest.GrantType, null,
response.AccessToken.IsPresent(), response.AccessTokenType.IsPresent() ? requestResult.ValidatedRequest.AccessTokenType : null, response.RefreshToken.IsPresent(),
@@ -153,7 +153,7 @@ internal class TokenEndpoint : IEndpointHandler
private async Task TryReadProofTokens(HttpContext context, TokenRequestValidationContext tokenRequest)
{
// mTLS cert
- tokenRequest.ClientCertificate = await context.Connection.GetClientCertificateAsync();
+ tokenRequest.ClientCertificate = await context.Connection.GetClientCertificateAsync(context.RequestAborted);
// DPoP header value
if (context.Request.Headers.TryGetValue(OidcConstants.HttpHeaders.DPoP, out var dpopHeader))
diff --git a/identity-server/src/IdentityServer/Endpoints/TokenRevocationEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/TokenRevocationEndpoint.cs
index d36073bf7..28fb6da67 100644
--- a/identity-server/src/IdentityServer/Endpoints/TokenRevocationEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/TokenRevocationEndpoint.cs
@@ -89,7 +89,7 @@ internal class TokenRevocationEndpoint : IEndpointHandler
_logger.LogDebug("Start revocation request.");
// validate client
- var clientValidationResult = await _clientValidator.ValidateAsync(context);
+ var clientValidationResult = await _clientValidator.ValidateAsync(context, context.RequestAborted);
if (clientValidationResult.IsError)
{
var error = clientValidationResult.Error ?? OidcConstants.TokenErrors.InvalidClient;
@@ -100,10 +100,10 @@ internal class TokenRevocationEndpoint : IEndpointHandler
_logger.LogTrace("Client validation successful");
// validate the token request
- var form = (await context.Request.ReadFormAsync()).AsNameValueCollection();
+ var form = (await context.Request.ReadFormAsync(context.RequestAborted)).AsNameValueCollection();
_logger.LogTrace("Calling into token revocation request validator: {type}", _requestValidator.GetType().FullName);
- var requestValidationResult = await _requestValidator.ValidateRequestAsync(form, clientValidationResult.Client);
+ var requestValidationResult = await _requestValidator.ValidateRequestAsync(form, clientValidationResult.Client, context.RequestAborted);
if (requestValidationResult.IsError)
{
@@ -112,13 +112,13 @@ internal class TokenRevocationEndpoint : IEndpointHandler
}
_logger.LogTrace("Calling into token revocation response generator: {type}", _responseGenerator.GetType().FullName);
- var response = await _responseGenerator.ProcessAsync(requestValidationResult);
+ var response = await _responseGenerator.ProcessAsync(requestValidationResult, context.RequestAborted);
if (response.Success)
{
_logger.LogInformation("Token revocation complete");
Telemetry.Metrics.Revocation(clientValidationResult.Client.ClientId);
- await _events.RaiseAsync(new TokenRevokedSuccessEvent(requestValidationResult, requestValidationResult.Client));
+ await _events.RaiseAsync(new TokenRevokedSuccessEvent(requestValidationResult, requestValidationResult.Client), context.RequestAborted);
}
else
{
diff --git a/identity-server/src/IdentityServer/Endpoints/UserInfoEndpoint.cs b/identity-server/src/IdentityServer/Endpoints/UserInfoEndpoint.cs
index d875b38b9..ec888f615 100644
--- a/identity-server/src/IdentityServer/Endpoints/UserInfoEndpoint.cs
+++ b/identity-server/src/IdentityServer/Endpoints/UserInfoEndpoint.cs
@@ -79,7 +79,7 @@ internal class UserInfoEndpoint : IEndpointHandler
// validate the request
_logger.LogTrace("Calling into userinfo request validator: {type}", _requestValidator.GetType().FullName);
- var validationResult = await _requestValidator.ValidateRequestAsync(tokenUsageResult.Token);
+ var validationResult = await _requestValidator.ValidateRequestAsync(tokenUsageResult.Token, context.RequestAborted);
if (validationResult.IsError)
{
@@ -89,7 +89,7 @@ internal class UserInfoEndpoint : IEndpointHandler
// generate response
_logger.LogTrace("Calling into userinfo response generator: {type}", _responseGenerator.GetType().FullName);
- var response = await _responseGenerator.ProcessAsync(validationResult);
+ var response = await _responseGenerator.ProcessAsync(validationResult, context.RequestAborted);
_logger.LogDebug("End userinfo request");
return new UserInfoResult(response);
diff --git a/identity-server/src/IdentityServer/Extensions/HttpContextExtensions.cs b/identity-server/src/IdentityServer/Extensions/HttpContextExtensions.cs
index 1ea488f12..235feb016 100644
--- a/identity-server/src/IdentityServer/Extensions/HttpContextExtensions.cs
+++ b/identity-server/src/IdentityServer/Extensions/HttpContextExtensions.cs
@@ -51,7 +51,7 @@ public static class HttpContextExtensions
internal static async Task GetIdentityServerSignoutFrameCallbackUrlAsync(this HttpContext context, LogoutMessage logoutMessage = null)
{
var userSession = context.RequestServices.GetRequiredService();
- var user = await userSession.GetUserAsync();
+ var user = await userSession.GetUserAsync(context.RequestAborted);
var currentSubId = user?.GetSubjectId();
LogoutNotificationContext endSessionMsg = null;
@@ -64,7 +64,7 @@ public static class HttpContextExtensions
// check if current user is same, since we might have new clients (albeit unlikely)
if (currentSubId == logoutMessage.SubjectId)
{
- clientIds = clientIds.Union(await userSession.GetClientListAsync());
+ clientIds = clientIds.Union(await userSession.GetClientListAsync(context.RequestAborted));
}
if (await AnyClientHasFrontChannelLogout(logoutMessage.ClientIds))
@@ -80,13 +80,13 @@ public static class HttpContextExtensions
else if (currentSubId != null)
{
// see if current user has any clients they need to signout of
- var clientIds = await userSession.GetClientListAsync();
+ var clientIds = await userSession.GetClientListAsync(context.RequestAborted);
if (clientIds.Any() && await AnyClientHasFrontChannelLogout(clientIds))
{
endSessionMsg = new LogoutNotificationContext
{
SubjectId = currentSubId,
- SessionId = await userSession.GetSessionIdAsync(),
+ SessionId = await userSession.GetSessionIdAsync(context.RequestAborted),
ClientIds = clientIds
};
}
@@ -98,7 +98,7 @@ public static class HttpContextExtensions
var msg = new Message(endSessionMsg, timeProvider.GetUtcNow().UtcDateTime);
var endSessionMessageStore = context.RequestServices.GetRequiredService>();
- var id = await endSessionMessageStore.WriteAsync(msg);
+ var id = await endSessionMessageStore.WriteAsync(msg, context.RequestAborted);
var urls = context.RequestServices.GetRequiredService();
var signoutIframeUrl = urls.BaseUrl.EnsureTrailingSlash() + ProtocolRoutePaths.EndSessionCallback;
@@ -115,7 +115,7 @@ public static class HttpContextExtensions
var clientStore = context.RequestServices.GetRequiredService();
foreach (var clientId in clientIds)
{
- var client = await clientStore.FindEnabledClientByIdAsync(clientId);
+ var client = await clientStore.FindEnabledClientByIdAsync(clientId, context.RequestAborted);
if (client?.FrontChannelLogoutUri.IsPresent() == true)
{
return true;
diff --git a/identity-server/src/IdentityServer/Extensions/IClientStoreExtensions.cs b/identity-server/src/IdentityServer/Extensions/IClientStoreExtensions.cs
index eb161bc00..8ab4c206d 100644
--- a/identity-server/src/IdentityServer/Extensions/IClientStoreExtensions.cs
+++ b/identity-server/src/IdentityServer/Extensions/IClientStoreExtensions.cs
@@ -16,10 +16,11 @@ public static class IClientStoreExtensions
///
/// The store.
/// The client identifier.
+ /// The cancellation token.
///
- public static async Task FindEnabledClientByIdAsync(this IClientStore store, string clientId)
+ public static async Task FindEnabledClientByIdAsync(this IClientStore store, string clientId, Ct ct)
{
- var client = await store.FindClientByIdAsync(clientId);
+ var client = await store.FindClientByIdAsync(clientId, ct);
if (client != null && client.Enabled)
{
return client;
diff --git a/identity-server/src/IdentityServer/Extensions/IResourceStoreExtensions.cs b/identity-server/src/IdentityServer/Extensions/IResourceStoreExtensions.cs
index d658dd740..fada564ac 100644
--- a/identity-server/src/IdentityServer/Extensions/IResourceStoreExtensions.cs
+++ b/identity-server/src/IdentityServer/Extensions/IResourceStoreExtensions.cs
@@ -16,12 +16,13 @@ public static class IResourceStoreExtensions
///
/// The store.
/// The scope names.
+ /// The cancellation token.
///
- public static async Task FindResourcesByScopeAsync(this IResourceStore store, IEnumerable scopeNames)
+ public static async Task FindResourcesByScopeAsync(this IResourceStore store, IEnumerable scopeNames, Ct ct)
{
- var identity = await store.FindIdentityResourcesByScopeNameAsync(scopeNames);
- var apiResources = await store.FindApiResourcesByScopeNameAsync(scopeNames);
- var scopes = await store.FindApiScopesByNameAsync(scopeNames);
+ var identity = await store.FindIdentityResourcesByScopeNameAsync(scopeNames, ct);
+ var apiResources = await store.FindApiResourcesByScopeNameAsync(scopeNames, ct);
+ var scopes = await store.FindApiScopesByNameAsync(scopeNames, ct);
ValidateNameUniqueness(identity, apiResources, scopes);
@@ -88,17 +89,19 @@ public static class IResourceStoreExtensions
///
/// The store.
/// The scope names.
+ /// The cancellation token.
///
- public static async Task FindEnabledResourcesByScopeAsync(this IResourceStore store, IEnumerable scopeNames) => (await store.FindResourcesByScopeAsync(scopeNames)).FilterEnabled();
+ public static async Task FindEnabledResourcesByScopeAsync(this IResourceStore store, IEnumerable scopeNames, Ct ct) => (await store.FindResourcesByScopeAsync(scopeNames, ct)).FilterEnabled();
///
/// Gets all enabled resources.
///
/// The store.
+ /// The cancellation token.
///
- public static async Task GetAllEnabledResourcesAsync(this IResourceStore store)
+ public static async Task GetAllEnabledResourcesAsync(this IResourceStore store, Ct ct)
{
- var resources = await store.GetAllResourcesAsync();
+ var resources = await store.GetAllResourcesAsync(ct);
ValidateNameUniqueness(resources.IdentityResources, resources.ApiResources, resources.ApiScopes);
return resources.FilterEnabled();
@@ -109,11 +112,15 @@ public static class IResourceStoreExtensions
///
/// The store.
/// The scope names.
+ /// The cancellation token.
///
- public static async Task> FindEnabledIdentityResourcesByScopeAsync(this IResourceStore store, IEnumerable scopeNames) => (await store.FindIdentityResourcesByScopeNameAsync(scopeNames)).Where(x => x.Enabled).ToArray();
+ public static async Task