Skip to content

Commit f647f49

Browse files
apply changes from main
1 parent 76a1613 commit f647f49

9 files changed

Lines changed: 18 additions & 13 deletions

File tree

access-token-management/samples/WebClientAssertions/Controllers/HomeController.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
using System.Text.Json;
5-
using Duende.AccessTokenManagement;
65
using Duende.AccessTokenManagement.OpenIdConnect;
7-
using Duende.IdentityModel.Client;
86
using Microsoft.AspNetCore.Authentication;
97
using Microsoft.AspNetCore.Authorization;
108
using Microsoft.AspNetCore.Mvc;

access-token-management/src/AccessTokenManagement.OpenIdConnect/Internal/ConfigureOpenIdConnectOptions.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ internal class ConfigureOpenIdConnectOptions(
2222
IHttpContextAccessor httpContextAccessor,
2323
IOptions<UserTokenManagementOptions> userAccessTokenManagementOptions,
2424
IAuthenticationSchemeProvider schemeProvider,
25-
IClientAssertionService clientAssertionService,
25+
IServiceProvider serviceProvider,
2626
ILoggerFactory loggerFactory) : IConfigureNamedOptions<OpenIdConnectOptions>
2727
{
28+
2829
private readonly Scheme _configScheme = GetConfigScheme(userAccessTokenManagementOptions.Value, schemeProvider);
2930

31+
// Normally, we'd resolve this directly from DI in the constructor. However
32+
// This would cause a circular dependency since the IClientAssertionService may depend on the OIDC configuration,
33+
// which is what we're configuring here.
34+
private IClientAssertionService ClientAssertionService => serviceProvider.GetRequiredService<IClientAssertionService>();
35+
3036
private ClientCredentialsClientName ClientName => _configScheme.ToClientName();
3137

3238
private static Scheme GetConfigScheme(UserTokenManagementOptions options, IAuthenticationSchemeProvider schemeProvider)
@@ -120,7 +126,7 @@ async Task Callback(AuthorizationCodeReceivedContext context)
120126
}
121127

122128
// Automatically send client assertion during code exchange if a service is registered
123-
var assertion = await clientAssertionService
129+
var assertion = await ClientAssertionService
124130
.GetClientAssertionAsync(ClientName, ct: context.HttpContext.RequestAborted)
125131
.ConfigureAwait(false);
126132

@@ -164,7 +170,7 @@ async Task Callback(PushedAuthorizationContext context)
164170
await inner.Invoke(context);
165171

166172
// --- Client assertion ---
167-
var assertion = await clientAssertionService
173+
var assertion = await ClientAssertionService
168174
.GetClientAssertionAsync(ClientName, ct: context.HttpContext.RequestAborted)
169175
.ConfigureAwait(false);
170176

access-token-management/test/AccessTokenManagement.Tests/ClientTokenManagementTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Duende.AccessTokenManagement;
1616

1717
public class ClientTokenManagementTests
1818
{
19+
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
1920
private readonly ServiceCollection _services = [];
2021
private readonly MockHttpMessageHandler _mockHttp = new();
2122

access-token-management/test/AccessTokenManagement.Tests/PARWithClientAssertionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
#if NET9_0_OR_GREATER
34

45
using System.Net.Http.Json;
56
using Duende.AccessTokenManagement.DPoP;
@@ -12,7 +13,6 @@
1213

1314
namespace Duende.AccessTokenManagement;
1415

15-
#if NET9_0_OR_GREATER
1616
/// <summary>
1717
/// Tests that client assertions are sent on Pushed Authorization Requests (PAR).
1818
/// </summary>

access-token-management/test/AccessTokenManagement.Tests/UserAccessAccessTokenManagerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
33

44
using System.Security.Claims;
5-
using Duende.AccessTokenManagement.OTel;
65
using Duende.AccessTokenManagement.OpenIdConnect;
76
using Duende.AccessTokenManagement.OpenIdConnect.Internal;
7+
using Duende.AccessTokenManagement.OTel;
88
using Microsoft.Extensions.Logging.Abstractions;
99
using Microsoft.Extensions.Options;
1010

access-token-management/test/AccessTokenManagement.Tests/UserTokenManagementTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Duende.AccessTokenManagement;
1818

1919
public class UserTokenManagementTests(ITestOutputHelper output) : IntegrationTestBase(output)
2020
{
21+
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
2122
[Fact]
2223
public async Task Anonymous_user_should_return_user_token_error()
2324
{

access-token-management/test/AccessTokenManagement.Tests/UserTokenManagementWithDPoPTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class UserTokenManagementWithDPoPTests(ITestOutputHelper output)
2020
opt.DPoPJsonWebKey = DPoPProofKey.Parse(PrivateJwk);
2121
})
2222
{
23+
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
2324
// (An example jwk from RFC7517)
2425
private const string PrivateJwk = "{\"kty\":\"RSA\",\"n\":\"0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbISD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqbw0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw\",\"e\":\"AQAB\",\"d\":\"X4cTteJY_gn4FYPsXB8rdXix5vwsg1FLN5E3EaG6RJoVH-HLLKD9M7dx5oo7GURknchnrRweUkC7hT5fJLM0WbFAKNLWY2vv7B6NqXSzUvxT0_YSfqijwp3RTzlBaCxWp4doFk5N2o8Gy_nHNKroADIkJ46pRUohsXywbReAdYaM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"RS256\",\"kid\":\"2011-04-29\"}";
2526

identity-model-oidc-client/src/IdentityModel.OidcClient.Extensions/DPoP/ProofTokenMessageHandler.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright (c) Duende Software. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3-
3+
#pragma warning disable IDE0005 // Using directive is unnecessary. Remove unnecessary usings.
44
using System.Web;
55
using Duende.IdentityModel.Client;
66
using Microsoft.Extensions.Logging;
@@ -86,7 +86,7 @@ private void CreateProofToken(HttpRequestMessage request)
8686
request.SetDPoPProofToken(proof.ProofToken);
8787
}
8888

89-
#if NET5_0_OR_GREATER
89+
#if NET5_0_OR_GREATER
9090
/// <summary>
9191
/// Reads the <see cref="ProtocolRequestOptions.ClientAssertionFactory"/> from
9292
/// <see cref="HttpRequestMessage.Options"/> and, if present, invokes it to obtain a
@@ -149,10 +149,7 @@ private async Task RefreshClientAssertionAsync(HttpRequestMessage request)
149149
"application/x-www-form-urlencoded");
150150
}
151151
#else
152-
private Task RefreshClientAssertionAsync(HttpRequestMessage request)
153-
{
154-
return Task.CompletedTask;
155-
}
152+
private Task RefreshClientAssertionAsync(HttpRequestMessage request) => Task.CompletedTask;
156153
#endif
157154

158155
}

identity-model-oidc-client/test/IdentityModel.OidcClient.Tests/DPoP/DPoPTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Duende.IdentityModel.OidcClient.DPoP;
1616

1717
public class DPoPTest : IntegrationTestBase
1818
{
19+
private readonly CancellationToken _ct = TestContext.Current.CancellationToken;
1920
private static readonly string _jwkJson;
2021
private readonly IDPoPProofTokenFactory _proofTokenFactory;
2122
private readonly IdentityServer.Models.Client _client;

0 commit comments

Comments
 (0)