Skip to content

Commit f69718e

Browse files
authored
Merge pull request #1401 from DuendeSoftware/dom/update-to-net8-preview7
Updates for .NET8 Preview 7
2 parents 34045c2 + fcc5ee5 commit f69718e

31 files changed

+126
-60
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/setup-dotnet@v2
3333
with:
3434
dotnet-version: |
35-
8.0.100-preview.6.23330.14
35+
8.0.100-preview.7.23376.3
3636
3737
- run: dotnet --info
3838

.github/workflows/codeql-analysis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
uses: actions/setup-dotnet@v2
4242
with:
4343
dotnet-version: |
44-
8.0.100-preview.6.23330.14
44+
8.0.100-preview.7.23376.3
4545
4646
- run: dotnet --info
4747

Directory.Build.targets

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
</PropertyGroup>-->
1616

1717
<PropertyGroup Condition=" '$(TargetFramework)' == 'net8.0'">
18-
<FrameworkVersion>8.0.0-preview.6.23329.11</FrameworkVersion>
19-
<ExtensionsVersion>8.0.0-preview.6.23329.7</ExtensionsVersion>
20-
<EntityFrameworkVersion>8.0.0-preview.6.23329.4</EntityFrameworkVersion>
21-
<WilsonVersion>6.15.1</WilsonVersion>
18+
<FrameworkVersion>8.0.0-preview.7.23375.9</FrameworkVersion>
19+
<ExtensionsVersion>8.0.0-preview.7.23375.6</ExtensionsVersion>
20+
<EntityFrameworkVersion>8.0.0-preview.7.23375.4</EntityFrameworkVersion>
21+
<WilsonVersion>7.0.0</WilsonVersion>
2222
</PropertyGroup>
2323

2424
<ItemGroup>

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100-preview.6.23330.14",
3+
"version": "8.0.100-preview.7.23376.3",
44
"rollForward": "latestMajor",
55
"allowPrerelease": true
66
}

hosts/AspNetIdentity/GlobalSuppressions.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@
1313
[assembly: SuppressMessage("Design", "CA1054:URI-like parameters should not be strings", Justification = "Consistent with the IdentityServer APIs")]
1414
[assembly: SuppressMessage("Design", "CA1056:URI-like properties should not be strings", Justification = "Consistent with the IdentityServer APIs")]
1515
[assembly: SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "This namespace is just for organization, and won't be referenced elsewhere", Scope = "namespace", Target = "~N:IdentityServerHost.Pages.Error")]
16-
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Namespaces of pages are not likely to be used elsewhere, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Pages.Ciba.Consent")]
1716
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Namespaces of pages are not likely to be used elsewhere, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Pages.Extensions")]
18-
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Resources is only used for initalization, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Configuration.Resources")]
17+
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Resources is only used for initialization, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Configuration.Resources")]
1918
[assembly: SuppressMessage("Performance", "CA1805:Do not initialize unnecessarily", Justification = "This is for clarity and consistency with the surrounding code", Scope = "member", Target = "~F:IdentityServerHost.Pages.Logout.LogoutOptions.AutomaticRedirectAfterSignOut")]
2019
[assembly: SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "No need for ConfigureAwait in ASP.NET Core application code, as there is no SynchronizationContext.")]
2120

hosts/Configuration/GlobalSuppressions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[assembly: SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "This namespace is just for organization, and won't be referenced elsewhere", Scope = "namespace", Target = "~N:IdentityServerHost.Pages.Error")]
1717
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Namespaces of pages are not likely to be used elsewhere, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Pages.Ciba.Consent")]
1818
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Namespaces of pages are not likely to be used elsewhere, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Pages.Extensions")]
19-
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Resources is only used for initalization, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Configuration.Resources")]
19+
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Resources is only used for initialization, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Configuration.Resources")]
2020
[assembly: SuppressMessage("Performance", "CA1805:Do not initialize unnecessarily", Justification = "This is for clarity and consistency with the surrounding code", Scope = "member", Target = "~F:IdentityServerHost.Pages.Logout.LogoutOptions.AutomaticRedirectAfterSignOut")]
2121
[assembly: SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "No need for ConfigureAwait in ASP.NET Core application code, as there is no SynchronizationContext.")]
2222
[assembly: SuppressMessage("Performance", "CA1812:Avoid uninstantiated internal classes", Justification = "CustomClientRegistrationProcessor is created through DI", Scope = "type", Target = "~T:IdentityServerHost.CustomClientRegistrationProcessor")]

hosts/EntityFramework/Pages/Admin/ApiScopes/ApiScopeRepository.cs

+5
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,12 @@ public async Task CreateAsync(ApiScopeModel model)
8282
scope.UserClaims = claims.ToList();
8383
}
8484

85+
#pragma warning disable CA1849 // Call async methods when in an async method
86+
// CA1849 Suppressed because AddAsync is only needed for value generators that
87+
// need async database access (e.g., HiLoValueGenerator), and we don't use those
88+
// generators
8589
_context.ApiScopes.Add(scope.ToEntity());
90+
#pragma warning restore CA1849 // Call async methods when in an async method
8691
await _context.SaveChangesAsync();
8792
}
8893

hosts/EntityFramework/Pages/Admin/Clients/ClientRepository.cs

+5
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,12 @@ public async Task CreateAsync(CreateClientModel model)
137137
client.AllowOfflineAccess = true;
138138
}
139139

140+
#pragma warning disable CA1849 // Call async methods when in an async method
141+
// CA1849 Suppressed because AddAsync is only needed for value generators that
142+
// need async database access (e.g., HiLoValueGenerator), and we don't use those
143+
// generators
140144
_context.Clients.Add(client.ToEntity());
145+
#pragma warning restore CA1849 // Call async methods when in an async method
141146
await _context.SaveChangesAsync();
142147
}
143148

hosts/EntityFramework/Pages/Admin/IdentityScopes/IdentityScopeRepository.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@ public async Task CreateAsync(IdentityScopeModel model)
8181
{
8282
scope.UserClaims = claims.ToList();
8383
}
84-
84+
#pragma warning disable CA1849 // Call async methods when in an async method
85+
// CA1849 Suppressed because AddAsync is only needed for value generators that
86+
// need async database access (e.g., HiLoValueGenerator), and we don't use those
87+
// generators
8588
_context.IdentityResources.Add(scope.ToEntity());
89+
#pragma warning restore CA1849
8690
await _context.SaveChangesAsync();
8791
}
8892

hosts/main/GlobalSuppressions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
[assembly: SuppressMessage("Naming", "CA1716:Identifiers should not match keywords", Justification = "This namespace is just for organization, and won't be referenced elsewhere", Scope = "namespace", Target = "~N:IdentityServerHost.Pages.Error")]
1717
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Namespaces of pages are not likely to be used elsewhere, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Pages.Ciba.Consent")]
1818
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Namespaces of pages are not likely to be used elsewhere, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Pages.Extensions")]
19-
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Resources is only used for initalization, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Configuration.Resources")]
19+
[assembly: SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Resources is only used for initialization, so there is little chance of confusion", Scope = "type", Target = "~T:IdentityServerHost.Configuration.Resources")]
2020
[assembly: SuppressMessage("Performance", "CA1805:Do not initialize unnecessarily", Justification = "This is for clarity and consistency with the surrounding code", Scope = "member", Target = "~F:IdentityServerHost.Pages.Logout.LogoutOptions.AutomaticRedirectAfterSignOut")]
2121
[assembly: SuppressMessage("Reliability", "CA2007:Consider calling ConfigureAwait on the awaited task", Justification = "No need for ConfigureAwait in ASP.NET Core application code, as there is no SynchronizationContext.")]
2222

src/Configuration/Extensions/ConfigurationEndpointExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal static void CheckLicense(this IEndpointRouteBuilder endpoints)
3636
var loggerFactory = endpoints.ServiceProvider.GetRequiredService<ILoggerFactory>();
3737
var options = endpoints.ServiceProvider.GetRequiredService<IOptions<IdentityServerConfigurationOptions>>().Value;
3838

39-
ConfigurationLicenseValidator.Instance.Initalize(loggerFactory, options);
39+
ConfigurationLicenseValidator.Instance.Initialize(loggerFactory, options);
4040
}
4141

4242
_licenseChecked = true;

src/Configuration/Licensing/ConfigurationLicense.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ public ConfigurationLicense()
2323
// for testing
2424
internal ConfigurationLicense(params Claim[] claims)
2525
{
26-
Initalize(new ClaimsPrincipal(new ClaimsIdentity(claims)));
26+
Initialize(new ClaimsPrincipal(new ClaimsIdentity(claims)));
2727
}
2828

29-
internal override void Initalize(ClaimsPrincipal claims)
29+
internal override void Initialize(ClaimsPrincipal claims)
3030
{
31-
base.Initalize(claims);
31+
base.Initialize(claims);
3232

3333
ConfigApiFeature = claims.HasClaim("feature", "config_api");
3434
switch (Edition)

src/Configuration/Licensing/ConfigurationLicenseValidator.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ internal class ConfigurationLicenseValidator : LicenseValidator<ConfigurationLic
1515
{
1616
internal readonly static ConfigurationLicenseValidator Instance = new ConfigurationLicenseValidator();
1717

18-
public void Initalize(ILoggerFactory loggerFactory, IdentityServerConfigurationOptions options)
18+
public void Initialize(ILoggerFactory loggerFactory, IdentityServerConfigurationOptions options)
1919
{
20-
Initalize(loggerFactory, "IdentityServer.Configuration", options.LicenseKey);
20+
Initialize(loggerFactory, "IdentityServer.Configuration", options.LicenseKey);
2121
ValidateLicense();
2222
}
2323

src/Configuration/Licensing/License.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected License()
2525
/// <summary>
2626
/// Initializes the license from the claims in the key.
2727
/// </summary>
28-
internal virtual void Initalize(ClaimsPrincipal claims)
28+
internal virtual void Initialize(ClaimsPrincipal claims)
2929
{
3030
Claims = claims;
3131

src/Configuration/Licensing/LicenseValidator.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public T GetLicense()
3737
if (_copy == null && License != null)
3838
{
3939
_copy = new T();
40-
_copy.Initalize(License.Claims.Clone());
40+
_copy.Initialize(License.Claims.Clone());
4141
}
4242
return _copy;
4343
}
4444

45-
protected void Initalize(ILoggerFactory loggerFactory, string productName, string key)
45+
protected void Initialize(ILoggerFactory loggerFactory, string productName, string key)
4646
{
4747
Logger = loggerFactory.CreateLogger($"Duende.{productName}.License");
4848

@@ -166,11 +166,11 @@ internal T ValidateKey(string licenseKey)
166166
ValidateLifetime = false
167167
};
168168

169-
var validateResult = handler.ValidateToken(licenseKey, parms);
169+
var validateResult = handler.ValidateTokenAsync(licenseKey, parms).Result;
170170
if (validateResult.IsValid)
171171
{
172172
var license = new T();
173-
license.Initalize(new ClaimsPrincipal(validateResult.ClaimsIdentity));
173+
license.Initialize(new ClaimsPrincipal(validateResult.ClaimsIdentity));
174174
return license;
175175
}
176176
else

src/IdentityServer/Configuration/IdentityServerApplicationBuilderExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ internal static void Validate(this IApplicationBuilder app)
7676

7777
var options = serviceProvider.GetRequiredService<IdentityServerOptions>();
7878
var env = serviceProvider.GetRequiredService<IHostEnvironment>();
79-
IdentityServerLicenseValidator.Instance.Initalize(loggerFactory, options, env.IsDevelopment());
79+
IdentityServerLicenseValidator.Instance.Initialize(loggerFactory, options, env.IsDevelopment());
8080

8181
TestService(serviceProvider, typeof(IPersistedGrantStore), logger, "No storage mechanism for grants specified. Use the 'AddInMemoryPersistedGrants' extension method to register a development version.");
8282
TestService(serviceProvider, typeof(IClientStore), logger, "No storage mechanism for clients specified. Use the 'AddInMemoryClients' extension method to register a development version.");

src/IdentityServer/Hosting/LocalApiAuthentication/LocalApiAuthenticationHandler.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,14 @@ protected override Task HandleChallengeAsync(AuthenticationProperties properties
255255

256256
if (sb.Length > 0)
257257
{
258-
Response.Headers.Add(HeaderNames.WWWAuthenticate, sb.ToString());
258+
if(Response.Headers.ContainsKey(HeaderNames.WWWAuthenticate))
259+
{
260+
261+
throw new InvalidOperationException("Attempted to set the WWW-Authenticate header when it is already set");
262+
}
263+
Response.Headers[HeaderNames.WWWAuthenticate] = sb.ToString();
259264
}
260265

261266
return Task.CompletedTask;
262267
}
263-
}
268+
}

src/IdentityServer/Licensing/IdentityServerLicense.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public IdentityServerLicense()
2424
// for testing
2525
internal IdentityServerLicense(params Claim[] claims)
2626
{
27-
Initalize(new ClaimsPrincipal(new ClaimsIdentity(claims)));
27+
Initialize(new ClaimsPrincipal(new ClaimsIdentity(claims)));
2828
}
2929

30-
internal override void Initalize(ClaimsPrincipal claims)
30+
internal override void Initialize(ClaimsPrincipal claims)
3131
{
32-
base.Initalize(claims);
32+
base.Initialize(claims);
3333

3434
RedistributionFeature = claims.HasClaim("feature", "isv") || claims.HasClaim("feature", "redistribution");
3535

src/IdentityServer/Licensing/IdentityServerLicenseValidator.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ internal class IdentityServerLicenseValidator : LicenseValidator<IdentityServerL
2222
ConcurrentDictionary<string, byte> _clientIds = new ConcurrentDictionary<string, byte>();
2323
ConcurrentDictionary<string, byte> _issuers = new ConcurrentDictionary<string, byte>();
2424

25-
public void Initalize(ILoggerFactory loggerFactory, IdentityServerOptions options, bool isDevelopment = false)
25+
public void Initialize(ILoggerFactory loggerFactory, IdentityServerOptions options, bool isDevelopment = false)
2626
{
2727
_options = options;
2828

29-
Initalize(loggerFactory, "IdentityServer", options.LicenseKey);
29+
Initialize(loggerFactory, "IdentityServer", options.LicenseKey);
3030

3131
if (License?.RedistributionFeature == true && !isDevelopment)
3232
{

src/IdentityServer/Licensing/License.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected License()
2626
/// <summary>
2727
/// Initializes the license from the claims in the key.
2828
/// </summary>
29-
internal virtual void Initalize(ClaimsPrincipal claims)
29+
internal virtual void Initialize(ClaimsPrincipal claims)
3030
{
3131
Claims = claims;
3232

src/IdentityServer/Licensing/LicenseValidator.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public T GetLicense()
4040
if (_copy == null && License != null)
4141
{
4242
_copy = new T();
43-
_copy.Initalize(License.Claims.Clone());
43+
_copy.Initialize(License.Claims.Clone());
4444
}
4545
return _copy;
4646
}
4747

48-
protected void Initalize(ILoggerFactory loggerFactory, string productName, string key)
48+
protected void Initialize(ILoggerFactory loggerFactory, string productName, string key)
4949
{
5050
//if (Logger != null) throw new InvalidOperationException("LicenseValidator already initialized.");
5151

@@ -171,11 +171,11 @@ internal T ValidateKey(string licenseKey)
171171
ValidateLifetime = false
172172
};
173173

174-
var validateResult = handler.ValidateToken(licenseKey, parms);
174+
var validateResult = handler.ValidateTokenAsync(licenseKey, parms).Result;
175175
if (validateResult.IsValid)
176176
{
177177
var license = new T();
178-
license.Initalize(new ClaimsPrincipal(validateResult.ClaimsIdentity));
178+
license.Initialize(new ClaimsPrincipal(validateResult.ClaimsIdentity));
179179
return license;
180180
}
181181
else

src/IdentityServer/Validation/Default/DefaultDPoPProofValidator.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ protected virtual Task ValidateHeaderAsync(DPoPProofValidatonContext context, DP
154154
return Task.CompletedTask;
155155
}
156156

157-
if (!token.TryGetHeaderValue<IDictionary<string, object>>(JwtClaimTypes.JsonWebKey, out var jwkValues))
157+
if (!token.TryGetHeaderValue<JsonElement>(JwtClaimTypes.JsonWebKey, out var jwkValues))
158158
{
159159
result.IsError = true;
160160
result.ErrorDescription = "Invalid 'jwk' value.";
@@ -193,7 +193,7 @@ protected virtual Task ValidateHeaderAsync(DPoPProofValidatonContext context, DP
193193
/// <summary>
194194
/// Validates the signature.
195195
/// </summary>
196-
protected virtual Task ValidateSignatureAsync(DPoPProofValidatonContext context, DPoPProofValidatonResult result)
196+
protected virtual async Task ValidateSignatureAsync(DPoPProofValidatonContext context, DPoPProofValidatonResult result)
197197
{
198198
Microsoft.IdentityModel.Tokens.TokenValidationResult tokenValidationResult;
199199

@@ -209,27 +209,27 @@ protected virtual Task ValidateSignatureAsync(DPoPProofValidatonContext context,
209209
};
210210

211211
var handler = new JsonWebTokenHandler();
212-
tokenValidationResult = handler.ValidateToken(context.ProofToken, tvp);
212+
tokenValidationResult = await handler.ValidateTokenAsync(context.ProofToken, tvp);
213213
}
214214
catch (Exception ex)
215215
{
216216
Logger.LogDebug("Error parsing DPoP token: {error}", ex.Message);
217217
result.IsError = true;
218218
result.ErrorDescription = "Invalid signature on DPoP token.";
219-
return Task.CompletedTask;
219+
return;
220220
}
221221

222222
if (tokenValidationResult.Exception != null)
223223
{
224224
Logger.LogDebug("Error parsing DPoP token: {error}", tokenValidationResult.Exception.Message);
225225
result.IsError = true;
226226
result.ErrorDescription = "Invalid signature on DPoP token.";
227-
return Task.CompletedTask;
227+
return;
228228
}
229229

230230
result.Payload = tokenValidationResult.Claims;
231231

232-
return Task.CompletedTask;
232+
return;
233233
}
234234

235235
/// <summary>

src/IdentityServer/Validation/Default/JwtRequestValidator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ protected virtual async Task<JsonWebToken> ValidateJwtAsync(JwtRequestValidation
179179
tokenValidationParameters.ValidTypes = new[] { JwtClaimTypes.JwtTypes.AuthorizationRequest };
180180
}
181181

182-
var result = Handler.ValidateToken(context.JwtTokenString, tokenValidationParameters);
182+
var result = await Handler.ValidateTokenAsync(context.JwtTokenString, tokenValidationParameters);
183183
if (!result.IsValid)
184184
{
185185
throw result.Exception;

src/IdentityServer/Validation/Default/PrivateKeyJwtSecretValidator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ await _issuerNameService.GetCurrentAsync(),
120120
};
121121

122122
var handler = new JsonWebTokenHandler() { MaximumTokenSizeInBytes = _options.InputLengthRestrictions.Jwt };
123-
var result = handler.ValidateToken(jwtTokenString, tokenValidationParameters);
123+
var result = await handler.ValidateTokenAsync(jwtTokenString, tokenValidationParameters);
124124
if (!result.IsValid)
125125
{
126126
_logger.LogError(result.Exception, "JWT token validation error");

src/IdentityServer/Validation/Default/TokenValidator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ private async Task<TokenValidationResult> ValidateJwtAsync(string jwtString,
300300
}
301301
}
302302

303-
var result = handler.ValidateToken(jwtString, parameters);
303+
var result = await handler.ValidateTokenAsync(jwtString, parameters);
304304
if (!result.IsValid)
305305
{
306306
if (result.Exception is SecurityTokenExpiredException expiredException)

0 commit comments

Comments
 (0)