Browse Source

Decorate the claim extensions with [OverloadResolutionPriority] and collection expressions for ImmutableArray<T>

pull/2272/head
Kévin Chalet 11 months ago
parent
commit
e39c635631
  1. 6
      sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthorizationController.cs
  2. 10
      sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthorizationController.cs
  3. 2
      shared/OpenIddict.Extensions/OpenIddictHelpers.cs
  4. 2
      src/OpenIddict.Abstractions/OpenIddictExceptions.cs
  5. 104
      src/OpenIddict.Abstractions/Primitives/OpenIddictExtensions.cs
  6. 2
      src/OpenIddict.Abstractions/Primitives/OpenIddictParameter.cs
  7. 5
      src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs
  8. 5
      src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs
  9. 5
      src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs
  10. 5
      src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs
  11. 3
      src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.cs
  12. 5
      src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs
  13. 5
      src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs
  14. 5
      src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs
  15. 5
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Authentication.cs
  16. 5
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Session.cs
  17. 5
      src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs
  18. 5
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Authorization.cs
  19. 5
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Device.cs
  20. 5
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs
  21. 5
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Exchange.cs
  22. 5
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Introspection.cs
  23. 5
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Revocation.cs
  24. 5
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Userinfo.cs
  25. 5
      src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs
  26. 5
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Authentication.cs
  27. 5
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Device.cs
  28. 5
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs
  29. 5
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs
  30. 5
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Protection.cs
  31. 5
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Revocation.cs
  32. 5
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs
  33. 5
      src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs
  34. 9
      src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs
  35. 5
      src/OpenIddict.Client/OpenIddictClientHandlers.Authentication.cs
  36. 5
      src/OpenIddict.Client/OpenIddictClientHandlers.Device.cs
  37. 5
      src/OpenIddict.Client/OpenIddictClientHandlers.Discovery.cs
  38. 5
      src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs
  39. 14
      src/OpenIddict.Client/OpenIddictClientHandlers.Introspection.cs
  40. 7
      src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs
  41. 5
      src/OpenIddict.Client/OpenIddictClientHandlers.Revocation.cs
  42. 5
      src/OpenIddict.Client/OpenIddictClientHandlers.Session.cs
  43. 5
      src/OpenIddict.Client/OpenIddictClientHandlers.Userinfo.cs
  44. 7
      src/OpenIddict.Client/OpenIddictClientHandlers.cs
  45. 4
      src/OpenIddict.Client/OpenIddictClientService.cs
  46. 8
      src/OpenIddict.Core/Managers/OpenIddictApplicationManager.cs
  47. 2
      src/OpenIddict.Core/Managers/OpenIddictAuthorizationManager.cs
  48. 2
      src/OpenIddict.Core/Managers/OpenIddictScopeManager.cs
  49. 8
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs
  50. 2
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs
  51. 2
      src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs
  52. 8
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs
  53. 2
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs
  54. 2
      src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs
  55. 8
      src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs
  56. 2
      src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs
  57. 2
      src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs
  58. 2
      src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs
  59. 2
      src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs
  60. 2
      src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs
  61. 2
      src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs
  62. 16
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs
  63. 4
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs
  64. 4
      src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs
  65. 5
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs
  66. 5
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Device.cs
  67. 5
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs
  68. 5
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Exchange.cs
  69. 5
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Introspection.cs
  70. 5
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Revocation.cs
  71. 5
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs
  72. 5
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Userinfo.cs
  73. 5
      src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs
  74. 5
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs
  75. 3
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs
  76. 5
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs
  77. 5
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs
  78. 5
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs
  79. 5
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Exchange.cs
  80. 5
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Introspection.cs
  81. 5
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Revocation.cs
  82. 5
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs
  83. 5
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Userinfo.cs
  84. 5
      src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs
  85. 7
      src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs
  86. 9
      src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs
  87. 7
      src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs
  88. 5
      src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs
  89. 7
      src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs
  90. 5
      src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs
  91. 7
      src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs
  92. 5
      src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs
  93. 5
      src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs
  94. 5
      src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs
  95. 5
      src/OpenIddict.Server/OpenIddictServerHandlers.cs
  96. 5
      src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs
  97. 5
      src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs
  98. 3
      src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs
  99. 5
      src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs
  100. 5
      src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Discovery.cs

6
sandbox/OpenIddict.Sandbox.AspNet.Server/Controllers/AuthorizationController.cs

@ -156,7 +156,7 @@ public class AuthorizationController : Controller
.SetClaim(Claims.Email, user.Email)
.SetClaim(Claims.Name, user.UserName)
.SetClaim(Claims.PreferredUsername, user.UserName)
.SetClaims(Claims.Role, (await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)).ToImmutableArray());
.SetClaims(Claims.Role, [.. await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)]);
// Note: in this sample, the granted scopes match the requested scope
// but you may want to allow the user to uncheck specific scopes.
@ -280,7 +280,7 @@ public class AuthorizationController : Controller
.SetClaim(Claims.Email, user.Email)
.SetClaim(Claims.Name, user.UserName)
.SetClaim(Claims.PreferredUsername, user.UserName)
.SetClaims(Claims.Role, (await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)).ToImmutableArray());
.SetClaims(Claims.Role, [.. await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)]);
// Note: in this sample, the granted scopes match the requested scope
// but you may want to allow the user to uncheck specific scopes.
@ -400,7 +400,7 @@ public class AuthorizationController : Controller
.SetClaim(Claims.Email, user.Email)
.SetClaim(Claims.Name, user.UserName)
.SetClaim(Claims.PreferredUsername, user.UserName)
.SetClaims(Claims.Role, (await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)).ToImmutableArray());
.SetClaims(Claims.Role, [.. await context.Get<ApplicationUserManager>().GetRolesAsync(user.Id)]);
identity.SetDestinations(GetDestinations);

10
sandbox/OpenIddict.Sandbox.AspNetCore.Server/Controllers/AuthorizationController.cs

@ -190,7 +190,7 @@ public class AuthorizationController : Controller
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
// Note: in this sample, the granted scopes match the requested scope
// but you may want to allow the user to uncheck specific scopes.
@ -289,7 +289,7 @@ public class AuthorizationController : Controller
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
// Note: in this sample, the granted scopes match the requested scope
// but you may want to allow the user to uncheck specific scopes.
@ -381,7 +381,7 @@ public class AuthorizationController : Controller
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
// Note: in this sample, the granted scopes match the requested scope
// but you may want to allow the user to uncheck specific scopes.
@ -496,7 +496,7 @@ public class AuthorizationController : Controller
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
// Note: in this sample, the granted scopes match the requested scope
// but you may want to allow the user to uncheck specific scopes.
@ -550,7 +550,7 @@ public class AuthorizationController : Controller
.SetClaim(Claims.Email, await _userManager.GetEmailAsync(user))
.SetClaim(Claims.Name, await _userManager.GetUserNameAsync(user))
.SetClaim(Claims.PreferredUsername, await _userManager.GetUserNameAsync(user))
.SetClaims(Claims.Role, (await _userManager.GetRolesAsync(user)).ToImmutableArray());
.SetClaims(Claims.Role, [.. await _userManager.GetRolesAsync(user)]);
identity.SetDestinations(GetDestinations);

2
shared/OpenIddict.Extensions/OpenIddictHelpers.cs

@ -1128,7 +1128,7 @@ internal static class OpenIddictHelpers
private readonly TextReader _reader;
private readonly char[] _buffer;
private readonly StringBuilder _builder = new StringBuilder();
private readonly StringBuilder _builder = new();
private int _bufferOffset;
private int _bufferCount;
private string? _currentKey;

2
src/OpenIddict.Abstractions/OpenIddictExceptions.cs

@ -109,7 +109,7 @@ public static class OpenIddictExceptions
/// </summary>
/// <param name="message">The exception message.</param>
public ValidationException(string? message)
: this(message, ImmutableArray<ValidationResult>.Empty)
: this(message, [])
{
}

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

@ -7,6 +7,7 @@
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Security.Claims;
using System.Text;
using System.Text.Encodings.Web;
@ -510,7 +511,7 @@ public static class OpenIddictExtensions
if (string.IsNullOrEmpty(destinations))
{
return ImmutableArray<string>.Empty;
return [];
}
using var document = JsonDocument.Parse(destinations);
@ -573,6 +574,7 @@ public static class OpenIddictExtensions
/// </summary>
/// <param name="claim">The <see cref="Claim"/> instance.</param>
/// <param name="destinations">The destinations.</param>
[OverloadResolutionPriority(0)]
public static Claim SetDestinations(this Claim claim, ImmutableArray<string> destinations)
{
if (claim is null)
@ -619,16 +621,18 @@ public static class OpenIddictExtensions
/// </summary>
/// <param name="claim">The <see cref="Claim"/> instance.</param>
/// <param name="destinations">The destinations.</param>
public static Claim SetDestinations(this Claim claim, IEnumerable<string>? destinations)
=> claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-1)]
public static Claim SetDestinations(this Claim claim, params string[]? destinations)
=> claim.SetDestinations([.. destinations ?? []]);
/// <summary>
/// Adds specific destinations to a claim.
/// </summary>
/// <param name="claim">The <see cref="Claim"/> instance.</param>
/// <param name="destinations">The destinations.</param>
public static Claim SetDestinations(this Claim claim, params string[]? destinations)
=> claim.SetDestinations(destinations?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-2)]
public static Claim SetDestinations(this Claim claim, IEnumerable<string>? destinations)
=> claim.SetDestinations([.. destinations ?? []]);
/// <summary>
/// Gets the destinations associated with all the claims of the given identity.
@ -2923,6 +2927,7 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="audiences">The audiences to store.</param>
/// <returns>The claims identity.</returns>
[OverloadResolutionPriority(0)]
public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, ImmutableArray<string> audiences)
=> identity.SetClaims(Claims.Private.Audience, audiences);
@ -2933,6 +2938,7 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="audiences">The audiences to store.</param>
/// <returns>The claims principal.</returns>
[OverloadResolutionPriority(0)]
public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, ImmutableArray<string> audiences)
=> principal.SetClaims(Claims.Private.Audience, audiences);
@ -2943,8 +2949,9 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="audiences">The audiences to store.</param>
/// <returns>The claims identity.</returns>
public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, IEnumerable<string>? audiences)
=> identity.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-1)]
public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, params string[]? audiences)
=> identity.SetAudiences([.. audiences ?? []]);
/// <summary>
/// Sets the audiences list in the claims principal.
@ -2953,8 +2960,9 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="audiences">The audiences to store.</param>
/// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, IEnumerable<string>? audiences)
=> principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-1)]
public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, params string[]? audiences)
=> principal.SetAudiences([.. audiences ?? []]);
/// <summary>
/// Sets the audiences list in the claims identity.
@ -2963,8 +2971,9 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="audiences">The audiences to store.</param>
/// <returns>The claims identity.</returns>
public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, params string[]? audiences)
=> identity.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-2)]
public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, IEnumerable<string>? audiences)
=> identity.SetAudiences([.. audiences ?? []]);
/// <summary>
/// Sets the audiences list in the claims principal.
@ -2973,8 +2982,9 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="audiences">The audiences to store.</param>
/// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, params string[]? audiences)
=> principal.SetAudiences(audiences?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-2)]
public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, IEnumerable<string>? audiences)
=> principal.SetAudiences([.. audiences ?? []]);
/// <summary>
/// Sets the presenters list in the claims identity.
@ -2983,6 +2993,7 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="presenters">The presenters to store.</param>
/// <returns>The claims identity.</returns>
[OverloadResolutionPriority(0)]
public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, ImmutableArray<string> presenters)
=> identity.SetClaims(Claims.Private.Presenter, presenters);
@ -2993,6 +3004,7 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="presenters">The presenters to store.</param>
/// <returns>The claims principal.</returns>
[OverloadResolutionPriority(0)]
public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, ImmutableArray<string> presenters)
=> principal.SetClaims(Claims.Private.Presenter, presenters);
@ -3003,8 +3015,9 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="presenters">The presenters to store.</param>
/// <returns>The claims identity.</returns>
public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, IEnumerable<string>? presenters)
=> identity.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-1)]
public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, params string[]? presenters)
=> identity.SetPresenters([.. presenters ?? []]);
/// <summary>
/// Sets the presenters list in the claims principal.
@ -3013,8 +3026,9 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="presenters">The presenters to store.</param>
/// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, IEnumerable<string>? presenters)
=> principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-1)]
public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, params string[]? presenters)
=> principal.SetPresenters([.. presenters ?? []]);
/// <summary>
/// Sets the presenters list in the claims identity.
@ -3023,8 +3037,9 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="presenters">The presenters to store.</param>
/// <returns>The claims identity.</returns>
public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, params string[]? presenters)
=> identity.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-2)]
public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, IEnumerable<string>? presenters)
=> identity.SetPresenters([.. presenters ?? []]);
/// <summary>
/// Sets the presenters list in the claims principal.
@ -3033,8 +3048,9 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="presenters">The presenters to store.</param>
/// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, params string[]? presenters)
=> principal.SetPresenters(presenters?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-2)]
public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, IEnumerable<string>? presenters)
=> principal.SetPresenters([.. presenters ?? []]);
/// <summary>
/// Sets the resources list in the claims identity.
@ -3043,6 +3059,7 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="resources">The resources to store.</param>
/// <returns>The claims identity.</returns>
[OverloadResolutionPriority(0)]
public static ClaimsIdentity SetResources(this ClaimsIdentity identity, ImmutableArray<string> resources)
=> identity.SetClaims(Claims.Private.Resource, resources);
@ -3053,6 +3070,7 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="resources">The resources to store.</param>
/// <returns>The claims principal.</returns>
[OverloadResolutionPriority(0)]
public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, ImmutableArray<string> resources)
=> principal.SetClaims(Claims.Private.Resource, resources);
@ -3063,8 +3081,9 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="resources">The resources to store.</param>
/// <returns>The claims identity.</returns>
public static ClaimsIdentity SetResources(this ClaimsIdentity identity, IEnumerable<string>? resources)
=> identity.SetResources(resources?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-1)]
public static ClaimsIdentity SetResources(this ClaimsIdentity identity, params string[]? resources)
=> identity.SetResources([.. resources ?? []]);
/// <summary>
/// Sets the resources list in the claims principal.
@ -3073,8 +3092,9 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="resources">The resources to store.</param>
/// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, IEnumerable<string>? resources)
=> principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-1)]
public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, params string[]? resources)
=> principal.SetResources([.. resources ?? []]);
/// <summary>
/// Sets the resources list in the claims identity.
@ -3083,8 +3103,9 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="resources">The resources to store.</param>
/// <returns>The claims identity.</returns>
public static ClaimsIdentity SetResources(this ClaimsIdentity identity, params string[]? resources)
=> identity.SetResources(resources?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-2)]
public static ClaimsIdentity SetResources(this ClaimsIdentity identity, IEnumerable<string>? resources)
=> identity.SetResources([.. resources ?? []]);
/// <summary>
/// Sets the resources list in the claims principal.
@ -3093,8 +3114,9 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="resources">The resources to store.</param>
/// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, params string[]? resources)
=> principal.SetResources(resources?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-2)]
public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, IEnumerable<string>? resources)
=> principal.SetResources([.. resources ?? []]);
/// <summary>
/// Sets the scopes list in the claims identity.
@ -3103,6 +3125,7 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="scopes">The scopes to store.</param>
/// <returns>The claims identity.</returns>
[OverloadResolutionPriority(0)]
public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, ImmutableArray<string> scopes)
=> identity.SetClaims(Claims.Private.Scope, scopes);
@ -3113,6 +3136,7 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="scopes">The scopes to store.</param>
/// <returns>The claims principal.</returns>
[OverloadResolutionPriority(0)]
public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, ImmutableArray<string> scopes)
=> principal.SetClaims(Claims.Private.Scope, scopes);
@ -3123,8 +3147,9 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="scopes">The scopes to store.</param>
/// <returns>The claims identity.</returns>
public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, IEnumerable<string>? scopes)
=> identity.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-1)]
public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, params string[]? scopes)
=> identity.SetScopes([.. scopes ?? []]);
/// <summary>
/// Sets the scopes list in the claims principal.
@ -3133,8 +3158,9 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="scopes">The scopes to store.</param>
/// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, IEnumerable<string>? scopes)
=> principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-1)]
public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, params string[]? scopes)
=> principal.SetScopes([.. scopes ?? []]);
/// <summary>
/// Sets the scopes list in the claims identity.
@ -3143,8 +3169,9 @@ public static class OpenIddictExtensions
/// <param name="identity">The claims identity.</param>
/// <param name="scopes">The scopes to store.</param>
/// <returns>The claims identity.</returns>
public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, params string[]? scopes)
=> identity.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-2)]
public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, IEnumerable<string>? scopes)
=> identity.SetScopes([.. scopes ?? []]);
/// <summary>
/// Sets the scopes list in the claims principal.
@ -3153,8 +3180,9 @@ public static class OpenIddictExtensions
/// <param name="principal">The claims principal.</param>
/// <param name="scopes">The scopes to store.</param>
/// <returns>The claims principal.</returns>
public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, params string[]? scopes)
=> principal.SetScopes(scopes?.ToImmutableArray() ?? ImmutableArray<string>.Empty);
[OverloadResolutionPriority(-2)]
public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, IEnumerable<string>? scopes)
=> principal.SetScopes([.. scopes ?? []]);
/// <summary>
/// Sets the access token lifetime associated with the claims identity.
@ -3342,7 +3370,7 @@ public static class OpenIddictExtensions
if (string.IsNullOrEmpty(source))
{
return ImmutableArray<string>.Empty;
return [];
}
var builder = ImmutableArray.CreateBuilder<string>();

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

@ -528,7 +528,7 @@ public readonly struct OpenIddictParameter : IEquatable<OpenIddictParameter>
is JsonElement { ValueKind: JsonValueKind.Array } element
=> GetParametersFromJsonElement(element),
_ => ImmutableList.Create<OpenIddictParameter>()
_ => []
};
static IReadOnlyList<OpenIddictParameter> GetParametersFromArray(string?[] array)

5
src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Authentication.cs

@ -14,7 +14,8 @@ public static partial class OpenIddictClientAspNetCoreHandlers
{
public static class Authentication
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authorization request processing:
*/
@ -38,7 +39,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers
ProcessPassthroughErrorResponse<ApplyRedirectionResponseContext, RequireRedirectionEndpointPassthroughEnabled>.Descriptor,
ProcessStatusCodePagesErrorResponse<ApplyRedirectionResponseContext>.Descriptor,
ProcessLocalErrorResponse<ApplyRedirectionResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for processing authorization requests using 302 redirects.

5
src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.Session.cs

@ -14,7 +14,8 @@ public static partial class OpenIddictClientAspNetCoreHandlers
{
public static class Session
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* End session request processing:
*/
@ -38,7 +39,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers
ProcessPassthroughErrorResponse<ApplyPostLogoutRedirectionResponseContext, RequirePostLogoutRedirectionEndpointPassthroughEnabled>.Descriptor,
ProcessStatusCodePagesErrorResponse<ApplyPostLogoutRedirectionResponseContext>.Descriptor,
ProcessLocalErrorResponse<ApplyPostLogoutRedirectionResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for processing end session requests using 302 redirects.

5
src/OpenIddict.Client.AspNetCore/OpenIddictClientAspNetCoreHandlers.cs

@ -27,7 +27,8 @@ namespace OpenIddict.Client.AspNetCore;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictClientAspNetCoreHandlers
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Top-level request processing:
*/
@ -72,7 +73,7 @@ public static partial class OpenIddictClientAspNetCoreHandlers
.. Authentication.DefaultHandlers,
.. Session.DefaultHandlers
]);
];
/// <summary>
/// Contains the logic responsible for resolving the request URI from the ASP.NET Core environment.

5
src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.Protection.cs

@ -21,7 +21,8 @@ public static partial class OpenIddictClientDataProtectionHandlers
{
public static class Protection
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token validation:
*/
@ -32,7 +33,7 @@ public static partial class OpenIddictClientDataProtectionHandlers
*/
OverrideGeneratedTokenFormat.Descriptor,
GenerateDataProtectionToken.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for validating tokens generated using Data Protection.

3
src/OpenIddict.Client.DataProtection/OpenIddictClientDataProtectionHandlers.cs

@ -12,6 +12,5 @@ namespace OpenIddict.Client.DataProtection;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictClientDataProtectionHandlers
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; }
= ImmutableArray.Create([.. Protection.DefaultHandlers]);
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = [.. Protection.DefaultHandlers];
}

5
src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Authentication.cs

@ -13,7 +13,8 @@ public static partial class OpenIddictClientOwinHandlers
{
public static class Authentication
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authorization request processing:
*/
@ -38,7 +39,7 @@ public static partial class OpenIddictClientOwinHandlers
AttachCacheControlHeader<ApplyRedirectionResponseContext>.Descriptor,
ProcessPassthroughErrorResponse<ApplyRedirectionResponseContext, RequireRedirectionEndpointPassthroughEnabled>.Descriptor,
ProcessLocalErrorResponse<ApplyRedirectionResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for processing authorization requests using 302 redirects.

5
src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.Session.cs

@ -13,7 +13,8 @@ public static partial class OpenIddictClientOwinHandlers
{
public static class Session
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* End session request processing:
*/
@ -36,7 +37,7 @@ public static partial class OpenIddictClientOwinHandlers
AttachCacheControlHeader<ApplyPostLogoutRedirectionResponseContext>.Descriptor,
ProcessPassthroughErrorResponse<ApplyPostLogoutRedirectionResponseContext, RequirePostLogoutRedirectionEndpointPassthroughEnabled>.Descriptor,
ProcessLocalErrorResponse<ApplyPostLogoutRedirectionResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for processing end session requests using 302 redirects.

5
src/OpenIddict.Client.Owin/OpenIddictClientOwinHandlers.cs

@ -25,7 +25,8 @@ namespace OpenIddict.Client.Owin;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictClientOwinHandlers
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Top-level request processing:
*/
@ -69,7 +70,7 @@ public static partial class OpenIddictClientOwinHandlers
.. Authentication.DefaultHandlers,
.. Session.DefaultHandlers
]);
];
/// <summary>
/// Contains the logic responsible for resolving the request URI from the OWIN environment.

5
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Authentication.cs

@ -43,7 +43,8 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
{
public static class Authentication
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authorization request processing:
*/
@ -67,7 +68,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
ProcessEmptyHttpResponse.Descriptor,
ProcessProtocolActivationResponse<ApplyRedirectionResponseContext>.Descriptor,
ProcessPlatformCallbackResponse<ApplyRedirectionResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for initiating authorization requests using an AS web authentication session.

5
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.Session.cs

@ -43,7 +43,8 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
{
public static class Session
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* End session request processing:
*/
@ -67,7 +68,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
ProcessEmptyHttpResponse.Descriptor,
ProcessProtocolActivationResponse<ApplyPostLogoutRedirectionResponseContext>.Descriptor,
ProcessPlatformCallbackResponse<ApplyPostLogoutRedirectionResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for initiating end session requests using an AS web authentication session.

5
src/OpenIddict.Client.SystemIntegration/OpenIddictClientSystemIntegrationHandlers.cs

@ -24,7 +24,8 @@ namespace OpenIddict.Client.SystemIntegration;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictClientSystemIntegrationHandlers
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Top-level request processing:
*/
@ -86,7 +87,7 @@ public static partial class OpenIddictClientSystemIntegrationHandlers
.. Authentication.DefaultHandlers,
.. Session.DefaultHandlers
]);
];
/// <summary>
/// Contains the logic responsible for resolving the request URI from the HTTP listener request.

5
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Authorization.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
{
public static class Authorization
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Pushed authorization request processing:
*/
@ -35,6 +36,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
ExtractWwwAuthenticateHeader<ExtractPushedAuthorizationResponseContext>.Descriptor,
ValidateHttpResponse<ExtractPushedAuthorizationResponseContext>.Descriptor,
DisposeHttpResponse<ExtractPushedAuthorizationResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Device.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
{
public static class Device
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Device authorization request processing:
*/
@ -35,6 +36,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
ExtractWwwAuthenticateHeader<ExtractDeviceAuthorizationResponseContext>.Descriptor,
ValidateHttpResponse<ExtractDeviceAuthorizationResponseContext>.Descriptor,
DisposeHttpResponse<ExtractDeviceAuthorizationResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Discovery.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
{
public static class Discovery
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Configuration request processing:
*/
@ -56,6 +57,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
ExtractWwwAuthenticateHeader<ExtractJsonWebKeySetResponseContext>.Descriptor,
ValidateHttpResponse<ExtractJsonWebKeySetResponseContext>.Descriptor,
DisposeHttpResponse<ExtractJsonWebKeySetResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Exchange.cs

@ -16,7 +16,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
{
public static class Exchange
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token request processing:
*/
@ -39,6 +40,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
ExtractWwwAuthenticateHeader<ExtractTokenResponseContext>.Descriptor,
ValidateHttpResponse<ExtractTokenResponseContext>.Descriptor,
DisposeHttpResponse<ExtractTokenResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Introspection.cs

@ -16,7 +16,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
{
public static class Introspection
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Introspection request processing:
*/
@ -39,6 +40,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
ExtractWwwAuthenticateHeader<ExtractIntrospectionResponseContext>.Descriptor,
ValidateHttpResponse<ExtractIntrospectionResponseContext>.Descriptor,
DisposeHttpResponse<ExtractIntrospectionResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Revocation.cs

@ -16,7 +16,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
{
public static class Revocation
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Revocation request processing:
*/
@ -40,6 +41,6 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
ExtractEmptyHttpResponse<ExtractRevocationResponseContext>.Descriptor,
ValidateHttpResponse<ExtractRevocationResponseContext>.Descriptor,
DisposeHttpResponse<ExtractRevocationResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.Userinfo.cs

@ -16,7 +16,8 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
{
public static class UserInfo
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* UserInfo request processing:
*/
@ -40,7 +41,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
ExtractWwwAuthenticateHeader<ExtractUserInfoResponseContext>.Descriptor,
ValidateHttpResponse<ExtractUserInfoResponseContext>.Descriptor,
DisposeHttpResponse<ExtractUserInfoResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for attaching the access token to the HTTP Authorization header.

5
src/OpenIddict.Client.SystemNetHttp/OpenIddictClientSystemNetHttpHandlers.cs

@ -25,7 +25,8 @@ namespace OpenIddict.Client.SystemNetHttp;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictClientSystemNetHttpHandlers
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authentication processing:
*/
@ -54,7 +55,7 @@ public static partial class OpenIddictClientSystemNetHttpHandlers
.. Introspection.DefaultHandlers,
.. Revocation.DefaultHandlers,
.. UserInfo.DefaultHandlers
]);
];
/// <summary>
/// Contains the logic responsible for negotiating the best token endpoint client

5
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Authentication.cs

@ -13,12 +13,13 @@ public static partial class OpenIddictClientWebIntegrationHandlers
{
public static class Authentication
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authorization request preparation:
*/
MapNonStandardRequestParameters.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for mapping non-standard request parameters

5
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Device.cs

@ -15,12 +15,13 @@ public static partial class OpenIddictClientWebIntegrationHandlers
{
public static class Device
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Device authorization response extraction:
*/
MapNonStandardResponseParameters.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for mapping non-standard response parameters

5
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Discovery.cs

@ -15,7 +15,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers
{
public static class Discovery
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Configuration response handling:
*/
@ -25,7 +26,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers
AmendScopes.Descriptor,
AmendClientAuthenticationMethods.Descriptor,
AmendEndpoints.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for amending the issuer for the providers that require it.

5
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs

@ -24,7 +24,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers
{
public static class Exchange
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token request preparation:
*/
@ -38,7 +39,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers
* Token response extraction:
*/
MapNonStandardResponseParameters.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for mapping non-standard request parameters

5
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Protection.cs

@ -14,12 +14,13 @@ public static partial class OpenIddictClientWebIntegrationHandlers
{
public static class Protection
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token validation:
*/
AmendTokenValidationParameters.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for amending the token validation parameters for the providers that require it.

5
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Revocation.cs

@ -17,7 +17,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers
{
public static class Revocation
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Revocation request preparation:
*/
@ -29,7 +30,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers
* Revocation response extraction:
*/
NormalizeContentType.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for mapping non-standard request parameters

5
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs

@ -21,7 +21,8 @@ public static partial class OpenIddictClientWebIntegrationHandlers
{
public static class UserInfo
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* UserInfo request preparation:
*/
@ -37,7 +38,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers
NormalizeContentType.Descriptor,
UnwrapUserInfoResponse.Descriptor,
MapNonStandardResponseParameters.Descriptor,
]);
];
/// <summary>
/// Contains the logic responsible for overriding the HTTP method for the providers that require it.

5
src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs

@ -18,7 +18,8 @@ namespace OpenIddict.Client.WebIntegration;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictClientWebIntegrationHandlers
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authentication processing:
*/
@ -64,7 +65,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers
.. Protection.DefaultHandlers,
.. Revocation.DefaultHandlers,
.. UserInfo.DefaultHandlers
]);
];
/// <summary>
/// Contains the logic responsible for validating the signature or message authentication

9
src/OpenIddict.Client/OpenIddictClientHandlerDescriptor.cs

@ -31,7 +31,7 @@ public sealed class OpenIddictClientHandlerDescriptor
/// Gets the list of filters responsible for excluding the handler
/// from the activated handlers if it doesn't meet the criteria.
/// </summary>
public ImmutableArray<Type> FilterTypes { get; private set; } = ImmutableArray<Type>.Empty;
public ImmutableArray<Type> FilterTypes { get; private set; } = [];
/// <summary>
/// Gets the order assigned to the handler.
@ -53,8 +53,7 @@ public sealed class OpenIddictClientHandlerDescriptor
/// </summary>
/// <typeparam name="TContext">The event context type.</typeparam>
/// <returns>A new descriptor builder.</returns>
public static Builder<TContext> CreateBuilder<TContext>() where TContext : BaseContext
=> new Builder<TContext>();
public static Builder<TContext> CreateBuilder<TContext>() where TContext : BaseContext => new();
/// <summary>
/// Contains methods allowing to build a descriptor instance.
@ -269,10 +268,10 @@ public sealed class OpenIddictClientHandlerDescriptor
/// Build a new descriptor instance, based on the parameters that were previously set.
/// </summary>
/// <returns>The builder instance, so that calls can be easily chained.</returns>
public OpenIddictClientHandlerDescriptor Build() => new OpenIddictClientHandlerDescriptor
public OpenIddictClientHandlerDescriptor Build() => new()
{
ContextType = typeof(TContext),
FilterTypes = _filters.ToImmutableArray(),
FilterTypes = [.. _filters],
Order = _order,
ServiceDescriptor = _descriptor ?? throw new InvalidOperationException(SR.GetResourceString(SR.ID0105)),
Type = _type

5
src/OpenIddict.Client/OpenIddictClientHandlers.Authentication.cs

@ -15,7 +15,8 @@ public static partial class OpenIddictClientHandlers
{
public static class Authentication
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authorization request top-level processing:
*/
@ -53,7 +54,7 @@ public static partial class OpenIddictClientHandlers
* Redirection request validation:
*/
ValidateTokens.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for preparing authorization requests and invoking the corresponding event handlers.

5
src/OpenIddict.Client/OpenIddictClientHandlers.Device.cs

@ -15,7 +15,8 @@ public static partial class OpenIddictClientHandlers
{
public static class Device
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Device authorization response handling:
*/
@ -23,7 +24,7 @@ public static partial class OpenIddictClientHandlers
HandleErrorResponse.Descriptor,
ValidateVerificationEndpointUri.Descriptor,
ValidateExpiration.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for validating the well-known parameters contained in the device authorization response.

5
src/OpenIddict.Client/OpenIddictClientHandlers.Discovery.cs

@ -17,7 +17,8 @@ public static partial class OpenIddictClientHandlers
{
public static class Discovery
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Configuration response handling:
*/
@ -59,7 +60,7 @@ public static partial class OpenIddictClientHandlers
ValidateWellKnownJsonWebKeySetParameters.Descriptor,
HandleJsonWebKeySetErrorResponse.Descriptor,
ExtractSigningKeys.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for validating the well-known parameters contained in the configuration response.

5
src/OpenIddict.Client/OpenIddictClientHandlers.Exchange.cs

@ -14,13 +14,14 @@ public static partial class OpenIddictClientHandlers
{
public static class Exchange
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token response handling:
*/
ValidateWellKnownParameters.Descriptor,
HandleErrorResponse.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for validating the well-known parameters contained in the token response.

14
src/OpenIddict.Client/OpenIddictClientHandlers.Introspection.cs

@ -18,7 +18,8 @@ public static partial class OpenIddictClientHandlers
{
public static class Introspection
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Introspection response handling:
*/
@ -30,7 +31,7 @@ public static partial class OpenIddictClientHandlers
ValidateTokenUsage.Descriptor,
PopulateClaims.Descriptor,
MapInternalClaims.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for validating the well-known parameters contained in the introspection response.
@ -504,18 +505,17 @@ public static partial class OpenIddictClientHandlers
// Map the internal "oi_prst" claims from the standard "client_id" claim, if available.
context.Principal.SetPresenters(context.Principal.GetClaim(Claims.ClientId) switch
{
string identifier when !string.IsNullOrEmpty(identifier)
=> ImmutableArray.Create(identifier),
string identifier when !string.IsNullOrEmpty(identifier) => [identifier],
_ => ImmutableArray<string>.Empty
_ => []
});
// Map the internal "oi_scp" claims from the standard, space-separated "scope" claim, if available.
context.Principal.SetScopes(context.Principal.GetClaim(Claims.Scope) switch
{
string scope => scope.Split(Separators.Space, StringSplitOptions.RemoveEmptyEntries).ToImmutableArray(),
string scope => [.. scope.Split(Separators.Space, StringSplitOptions.RemoveEmptyEntries)],
_ => ImmutableArray<string>.Empty
_ => []
});
return default;

7
src/OpenIddict.Client/OpenIddictClientHandlers.Protection.cs

@ -19,7 +19,8 @@ public static partial class OpenIddictClientHandlers
{
public static class Protection
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token validation:
*/
@ -40,7 +41,7 @@ public static partial class OpenIddictClientHandlers
CreateTokenEntry.Descriptor,
GenerateIdentityModelToken.Descriptor,
AttachTokenPayload.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for resolving the validation parameters used to validate tokens.
@ -287,7 +288,7 @@ public static partial class OpenIddictClientHandlers
{
0 => true, // If no specific token type is expected, accept all token types at this stage.
1 => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ElementAt(0)),
_ => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ToImmutableArray())
_ => await _tokenManager.HasTypeAsync(token, [.. context.ValidTokenTypes])
}))
{
context.Reject(

5
src/OpenIddict.Client/OpenIddictClientHandlers.Revocation.cs

@ -14,13 +14,14 @@ public static partial class OpenIddictClientHandlers
{
public static class Revocation
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Revocation response handling:
*/
ValidateWellKnownParameters.Descriptor,
HandleErrorResponse.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for validating the well-known parameters contained in the revocation response.

5
src/OpenIddict.Client/OpenIddictClientHandlers.Session.cs

@ -14,7 +14,8 @@ public static partial class OpenIddictClientHandlers
{
public static class Session
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* EndSession request top-level processing:
*/
@ -39,7 +40,7 @@ public static partial class OpenIddictClientHandlers
* Post-logout redirection request validation:
*/
ValidateTokens.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for preparing authorization requests and invoking the corresponding event handlers.

5
src/OpenIddict.Client/OpenIddictClientHandlers.Userinfo.cs

@ -16,14 +16,15 @@ public static partial class OpenIddictClientHandlers
{
public static class UserInfo
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* UserInfo response handling:
*/
ValidateWellKnownParameters.Descriptor,
HandleErrorResponse.Descriptor,
PopulateClaims.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for validating the well-known parameters contained in the userinfo response.

7
src/OpenIddict.Client/OpenIddictClientHandlers.cs

@ -23,7 +23,8 @@ namespace OpenIddict.Client;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictClientHandlers
{
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictClientHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Top-level request processing:
*/
@ -217,7 +218,7 @@ public static partial class OpenIddictClientHandlers
.. Revocation.DefaultHandlers,
.. Session.DefaultHandlers,
.. UserInfo.DefaultHandlers
]);
];
/// <summary>
/// Contains the logic responsible for inferring the endpoint type from the request URI.
@ -5385,7 +5386,7 @@ public static partial class OpenIddictClientHandlers
principal.SetClaim(Claims.Private.Nonce, context.Nonce);
// Store the requested scopes in the state token.
principal.SetClaims(Claims.Private.Scope, context.Scopes.ToImmutableArray());
principal.SetClaims(Claims.Private.Scope, [.. context.Scopes]);
context.StateTokenPrincipal = principal;

4
src/OpenIddict.Client/OpenIddictClientService.cs

@ -48,8 +48,8 @@ public class OpenIddictClientService
var options = _provider.GetRequiredService<IOptionsMonitor<OpenIddictClientOptions>>();
return new(options.CurrentValue.Registrations switch
{
[ ] => ImmutableArray<OpenIddictClientRegistration>.Empty,
[..] registrations => registrations.ToImmutableArray()
[ ] => [],
[..] registrations => [.. registrations]
});
}

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

@ -1025,12 +1025,10 @@ public class OpenIddictApplicationManager<TApplication> : IOpenIddictApplication
await Store.SetDisplayNamesAsync(application, descriptor.DisplayNames.ToImmutableDictionary(), cancellationToken);
await Store.SetJsonWebKeySetAsync(application, descriptor.JsonWebKeySet, cancellationToken);
await Store.SetPermissionsAsync(application, descriptor.Permissions.ToImmutableArray(), cancellationToken);
await Store.SetPostLogoutRedirectUrisAsync(application,
descriptor.PostLogoutRedirectUris.Select(uri => uri.OriginalString).ToImmutableArray(), cancellationToken);
await Store.SetPostLogoutRedirectUrisAsync(application, [.. descriptor.PostLogoutRedirectUris.Select(uri => uri.OriginalString)], cancellationToken);
await Store.SetPropertiesAsync(application, descriptor.Properties.ToImmutableDictionary(), cancellationToken);
await Store.SetRedirectUrisAsync(application,
descriptor.RedirectUris.Select(uri => uri.OriginalString).ToImmutableArray(), cancellationToken);
await Store.SetRequirementsAsync(application, descriptor.Requirements.ToImmutableArray(), cancellationToken);
await Store.SetRedirectUrisAsync(application, [.. descriptor.RedirectUris.Select(uri => uri.OriginalString)], cancellationToken);
await Store.SetRequirementsAsync(application, [.. descriptor.Requirements], cancellationToken);
await Store.SetSettingsAsync(application, descriptor.Settings.ToImmutableDictionary(), cancellationToken);
}

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

@ -781,7 +781,7 @@ public class OpenIddictAuthorizationManager<TAuthorization> : IOpenIddictAuthori
await Store.SetApplicationIdAsync(authorization, descriptor.ApplicationId, cancellationToken);
await Store.SetCreationDateAsync(authorization, descriptor.CreationDate, cancellationToken);
await Store.SetPropertiesAsync(authorization, descriptor.Properties.ToImmutableDictionary(), cancellationToken);
await Store.SetScopesAsync(authorization, descriptor.Scopes.ToImmutableArray(), cancellationToken);
await Store.SetScopesAsync(authorization, [.. descriptor.Scopes], cancellationToken);
await Store.SetStatusAsync(authorization, descriptor.Status, cancellationToken);
await Store.SetSubjectAsync(authorization, descriptor.Subject, cancellationToken);
await Store.SetTypeAsync(authorization, descriptor.Type, cancellationToken);

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

@ -783,7 +783,7 @@ public class OpenIddictScopeManager<TScope> : IOpenIddictScopeManager where TSco
await Store.SetDisplayNamesAsync(scope, descriptor.DisplayNames.ToImmutableDictionary(), cancellationToken);
await Store.SetNameAsync(scope, descriptor.Name, cancellationToken);
await Store.SetPropertiesAsync(scope, descriptor.Properties.ToImmutableDictionary(), cancellationToken);
await Store.SetResourcesAsync(scope, descriptor.Resources.ToImmutableArray(), cancellationToken);
await Store.SetResourcesAsync(scope, [.. descriptor.Resources], cancellationToken);
}
/// <summary>

8
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkApplicationStore.cs

@ -475,7 +475,7 @@ public class OpenIddictEntityFrameworkApplicationStore<TApplication, TAuthorizat
if (string.IsNullOrEmpty(application.Permissions))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified permissions is an expensive operation.
@ -516,7 +516,7 @@ public class OpenIddictEntityFrameworkApplicationStore<TApplication, TAuthorizat
if (string.IsNullOrEmpty(application.PostLogoutRedirectUris))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified URIs is an expensive operation.
@ -592,7 +592,7 @@ public class OpenIddictEntityFrameworkApplicationStore<TApplication, TAuthorizat
if (string.IsNullOrEmpty(application.RedirectUris))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified URIs is an expensive operation.
@ -633,7 +633,7 @@ public class OpenIddictEntityFrameworkApplicationStore<TApplication, TAuthorizat
if (string.IsNullOrEmpty(application.Requirements))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified requirements is an expensive operation.

2
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkAuthorizationStore.cs

@ -377,7 +377,7 @@ public class OpenIddictEntityFrameworkAuthorizationStore<TAuthorization, TApplic
if (string.IsNullOrEmpty(authorization.Scopes))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified scopes is an expensive operation.

2
src/OpenIddict.EntityFramework/Stores/OpenIddictEntityFrameworkScopeStore.cs

@ -407,7 +407,7 @@ public class OpenIddictEntityFrameworkScopeStore<TScope, TContext, TKey> : IOpen
if (string.IsNullOrEmpty(scope.Resources))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified resources is an expensive operation.

8
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreApplicationStore.cs

@ -558,7 +558,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<TApplication, TAuthor
if (string.IsNullOrEmpty(application.Permissions))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified permissions is an expensive operation.
@ -599,7 +599,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<TApplication, TAuthor
if (string.IsNullOrEmpty(application.PostLogoutRedirectUris))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified URIs is an expensive operation.
@ -675,7 +675,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<TApplication, TAuthor
if (string.IsNullOrEmpty(application.RedirectUris))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified URIs is an expensive operation.
@ -716,7 +716,7 @@ public class OpenIddictEntityFrameworkCoreApplicationStore<TApplication, TAuthor
if (string.IsNullOrEmpty(application.Requirements))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified requirements is an expensive operation.

2
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreAuthorizationStore.cs

@ -464,7 +464,7 @@ public class OpenIddictEntityFrameworkCoreAuthorizationStore<TAuthorization, TAp
if (string.IsNullOrEmpty(authorization.Scopes))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified scopes is an expensive operation.

2
src/OpenIddict.EntityFrameworkCore/Stores/OpenIddictEntityFrameworkCoreScopeStore.cs

@ -423,7 +423,7 @@ public class OpenIddictEntityFrameworkCoreScopeStore<TScope, TContext, TKey> : I
if (string.IsNullOrEmpty(scope.Resources))
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
// Note: parsing the stringified resources is an expensive operation.

8
src/OpenIddict.MongoDb.Models/OpenIddictMongoDbApplication.cs

@ -82,13 +82,13 @@ public class OpenIddictMongoDbApplication
/// Gets or sets the permissions associated with the current application.
/// </summary>
[BsonElement("permissions"), BsonIgnoreIfNull]
public virtual IReadOnlyList<string>? Permissions { get; set; } = ImmutableList.Create<string>();
public virtual IReadOnlyList<string>? Permissions { get; set; } = [];
/// <summary>
/// Gets or sets the post-logout redirect URIs associated with the current application.
/// </summary>
[BsonElement("post_logout_redirect_uris"), BsonIgnoreIfNull]
public virtual IReadOnlyList<string>? PostLogoutRedirectUris { get; set; } = ImmutableList.Create<string>();
public virtual IReadOnlyList<string>? PostLogoutRedirectUris { get; set; } = [];
/// <summary>
/// Gets or sets the additional properties associated with the current application.
@ -100,13 +100,13 @@ public class OpenIddictMongoDbApplication
/// Gets or sets the redirect URIs associated with the current application.
/// </summary>
[BsonElement("redirect_uris"), BsonIgnoreIfNull]
public virtual IReadOnlyList<string>? RedirectUris { get; set; } = ImmutableList.Create<string>();
public virtual IReadOnlyList<string>? RedirectUris { get; set; } = [];
/// <summary>
/// Gets or sets the requirements associated with the current application.
/// </summary>
[BsonElement("requirements"), BsonIgnoreIfNull]
public virtual IReadOnlyList<string>? Requirements { get; set; } = ImmutableList.Create<string>();
public virtual IReadOnlyList<string>? Requirements { get; set; } = [];
/// <summary>
/// Gets or sets the settings associated with the current application.

2
src/OpenIddict.MongoDb.Models/OpenIddictMongoDbAuthorization.cs

@ -49,7 +49,7 @@ public class OpenIddictMongoDbAuthorization
/// Gets or sets the scopes associated with the current authorization.
/// </summary>
[BsonElement("scopes"), BsonIgnoreIfNull]
public virtual IReadOnlyList<string>? Scopes { get; set; } = ImmutableList.Create<string>();
public virtual IReadOnlyList<string>? Scopes { get; set; } = [];
/// <summary>
/// Gets or sets the status of the current authorization.

2
src/OpenIddict.MongoDb.Models/OpenIddictMongoDbScope.cs

@ -69,5 +69,5 @@ public class OpenIddictMongoDbScope
/// Gets or sets the resources associated with the current scope.
/// </summary>
[BsonElement("resources"), BsonIgnoreIfNull]
public virtual IReadOnlyList<string>? Resources { get; set; } = ImmutableList.Create<string>();
public virtual IReadOnlyList<string>? Resources { get; set; } = [];
}

2
src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbApplicationStoreResolver.cs

@ -15,7 +15,7 @@ namespace OpenIddict.MongoDb;
/// </summary>
public sealed class OpenIddictMongoDbApplicationStoreResolver : IOpenIddictApplicationStoreResolver
{
private readonly ConcurrentDictionary<Type, Type> _cache = new ConcurrentDictionary<Type, Type>();
private readonly ConcurrentDictionary<Type, Type> _cache = new();
private readonly IServiceProvider _provider;
public OpenIddictMongoDbApplicationStoreResolver(IServiceProvider provider)

2
src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbAuthorizationStoreResolver.cs

@ -15,7 +15,7 @@ namespace OpenIddict.MongoDb;
/// </summary>
public sealed class OpenIddictMongoDbAuthorizationStoreResolver : IOpenIddictAuthorizationStoreResolver
{
private readonly ConcurrentDictionary<Type, Type> _cache = new ConcurrentDictionary<Type, Type>();
private readonly ConcurrentDictionary<Type, Type> _cache = new();
private readonly IServiceProvider _provider;
public OpenIddictMongoDbAuthorizationStoreResolver(IServiceProvider provider)

2
src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbScopeStoreResolver.cs

@ -15,7 +15,7 @@ namespace OpenIddict.MongoDb;
/// </summary>
public sealed class OpenIddictMongoDbScopeStoreResolver : IOpenIddictScopeStoreResolver
{
private readonly ConcurrentDictionary<Type, Type> _cache = new ConcurrentDictionary<Type, Type>();
private readonly ConcurrentDictionary<Type, Type> _cache = new();
private readonly IServiceProvider _provider;
public OpenIddictMongoDbScopeStoreResolver(IServiceProvider provider)

2
src/OpenIddict.MongoDb/Resolvers/OpenIddictMongoDbTokenStoreResolver.cs

@ -15,7 +15,7 @@ namespace OpenIddict.MongoDb;
/// </summary>
public sealed class OpenIddictMongoDbTokenStoreResolver : IOpenIddictTokenStoreResolver
{
private readonly ConcurrentDictionary<Type, Type> _cache = new ConcurrentDictionary<Type, Type>();
private readonly ConcurrentDictionary<Type, Type> _cache = new();
private readonly IServiceProvider _provider;
public OpenIddictMongoDbTokenStoreResolver(IServiceProvider provider)

16
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbApplicationStore.cs

@ -323,10 +323,10 @@ public class OpenIddictMongoDbApplicationStore<TApplication> : IOpenIddictApplic
if (application.Permissions is not { Count: > 0 })
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
return new(application.Permissions.ToImmutableArray());
return new([.. application.Permissions]);
}
/// <inheritdoc/>
@ -340,10 +340,10 @@ public class OpenIddictMongoDbApplicationStore<TApplication> : IOpenIddictApplic
if (application.PostLogoutRedirectUris is not { Count: > 0 })
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
return new(application.PostLogoutRedirectUris.ToImmutableArray());
return new([.. application.PostLogoutRedirectUris]);
}
/// <inheritdoc/>
@ -381,10 +381,10 @@ public class OpenIddictMongoDbApplicationStore<TApplication> : IOpenIddictApplic
if (application.RedirectUris is not { Count: > 0 })
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
return new(application.RedirectUris.ToImmutableArray());
return new([.. application.RedirectUris]);
}
/// <inheritdoc/>
@ -397,10 +397,10 @@ public class OpenIddictMongoDbApplicationStore<TApplication> : IOpenIddictApplic
if (application.Requirements is not { Count: > 0 })
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
return new(application.Requirements.ToImmutableArray());
return new([.. application.Requirements]);
}
/// <inheritdoc/>

4
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbAuthorizationStore.cs

@ -302,10 +302,10 @@ public class OpenIddictMongoDbAuthorizationStore<TAuthorization> : IOpenIddictAu
if (authorization.Scopes is not { Count: > 0 })
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
return new(authorization.Scopes.ToImmutableArray());
return new([.. authorization.Scopes]);
}
/// <inheritdoc/>

4
src/OpenIddict.MongoDb/Stores/OpenIddictMongoDbScopeStore.cs

@ -302,10 +302,10 @@ public class OpenIddictMongoDbScopeStore<TScope> : IOpenIddictScopeStore<TScope>
if (scope.Resources is not { Count: > 0 })
{
return new(ImmutableArray<string>.Empty);
return new([]);
}
return new(scope.Resources.ToImmutableArray());
return new([.. scope.Resources]);
}
/// <inheritdoc/>

5
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Authentication.cs

@ -20,7 +20,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers
{
public static class Authentication
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authorization request extraction:
*/
@ -58,7 +59,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers
AttachCacheControlHeader<ApplyPushedAuthorizationResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyPushedAuthorizationResponseContext>.Descriptor,
ProcessJsonResponse<ApplyPushedAuthorizationResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for restoring cached requests from the request_id, if specified.

5
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Device.cs

@ -14,7 +14,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers
{
public static class Device
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Device request extraction:
*/
@ -50,7 +51,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers
ProcessStatusCodePagesErrorResponse<ApplyEndUserVerificationResponseContext>.Descriptor,
ProcessLocalErrorResponse<ApplyEndUserVerificationResponseContext>.Descriptor,
ProcessEmptyResponse<ApplyEndUserVerificationResponseContext>.Descriptor
]);
];
}
/// <summary>

5
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Discovery.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers
{
public static class Discovery
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Configuration request extraction:
*/
@ -36,6 +37,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers
AttachHttpResponseCode<ApplyJsonWebKeySetResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyJsonWebKeySetResponseContext>.Descriptor,
ProcessJsonResponse<ApplyJsonWebKeySetResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Exchange.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers
{
public static class Exchange
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token request extraction:
*/
@ -32,6 +33,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers
AttachCacheControlHeader<ApplyTokenResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyTokenResponseContext>.Descriptor,
ProcessJsonResponse<ApplyTokenResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Introspection.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers
{
public static class Introspection
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Introspection request extraction:
*/
@ -26,6 +27,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers
AttachHttpResponseCode<ApplyIntrospectionResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyIntrospectionResponseContext>.Descriptor,
ProcessJsonResponse<ApplyIntrospectionResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Revocation.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers
{
public static class Revocation
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Revocation request extraction:
*/
@ -27,6 +28,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers
AttachCacheControlHeader<ApplyRevocationResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyRevocationResponseContext>.Descriptor,
ProcessJsonResponse<ApplyRevocationResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Session.cs

@ -17,7 +17,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers
{
public static class Session
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* End-session request extraction:
*/
@ -40,7 +41,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers
ProcessStatusCodePagesErrorResponse<ApplyEndSessionResponseContext>.Descriptor,
ProcessLocalErrorResponse<ApplyEndSessionResponseContext>.Descriptor,
ProcessEmptyResponse<ApplyEndSessionResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for restoring cached requests from the request_id, if specified.

5
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.Userinfo.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerAspNetCoreHandlers
{
public static class UserInfo
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* UserInfo request extraction:
*/
@ -31,6 +32,6 @@ public static partial class OpenIddictServerAspNetCoreHandlers
AttachWwwAuthenticateHeader<ApplyUserInfoResponseContext>.Descriptor,
ProcessChallengeErrorResponse<ApplyUserInfoResponseContext>.Descriptor,
ProcessJsonResponse<ApplyUserInfoResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.AspNetCore/OpenIddictServerAspNetCoreHandlers.cs

@ -25,7 +25,8 @@ namespace OpenIddict.Server.AspNetCore;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictServerAspNetCoreHandlers
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Top-level request processing:
*/
@ -57,7 +58,7 @@ public static partial class OpenIddictServerAspNetCoreHandlers
.. Revocation.DefaultHandlers,
.. Session.DefaultHandlers,
.. UserInfo.DefaultHandlers
]);
];
/// <summary>
/// Contains the logic responsible for resolving the request URI from the ASP.NET Core environment.

5
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.Protection.cs

@ -21,7 +21,8 @@ public static partial class OpenIddictServerDataProtectionHandlers
{
public static class Protection
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token validation:
*/
@ -32,7 +33,7 @@ public static partial class OpenIddictServerDataProtectionHandlers
*/
OverrideGeneratedTokenFormat.Descriptor,
GenerateDataProtectionToken.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for validating tokens generated using Data Protection.

3
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionHandlers.cs

@ -12,6 +12,5 @@ namespace OpenIddict.Server.DataProtection;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictServerDataProtectionHandlers
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; }
= ImmutableArray.Create([.. Protection.DefaultHandlers]);
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = [.. Protection.DefaultHandlers];
}

5
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Authentication.cs

@ -19,7 +19,8 @@ public static partial class OpenIddictServerOwinHandlers
{
public static class Authentication
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authorization request extraction:
*/
@ -60,7 +61,7 @@ public static partial class OpenIddictServerOwinHandlers
AttachCacheControlHeader<ApplyPushedAuthorizationResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyPushedAuthorizationResponseContext>.Descriptor,
ProcessJsonResponse<ApplyPushedAuthorizationResponseContext>.Descriptor,
]);
];
/// <summary>
/// Contains the logic responsible for restoring cached requests from the request_id, if specified.

5
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Device.cs

@ -14,7 +14,8 @@ public static partial class OpenIddictServerOwinHandlers
{
public static class Device
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Device request extraction:
*/
@ -53,7 +54,7 @@ public static partial class OpenIddictServerOwinHandlers
ProcessPassthroughErrorResponse<ApplyEndUserVerificationResponseContext, RequireVerificationEndpointPassthroughEnabled>.Descriptor,
ProcessLocalErrorResponse<ApplyEndUserVerificationResponseContext>.Descriptor,
ProcessEmptyResponse<ApplyEndUserVerificationResponseContext>.Descriptor
]);
];
}
/// <summary>

5
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Discovery.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers
{
public static class Discovery
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Configuration request extraction:
*/
@ -40,6 +41,6 @@ public static partial class OpenIddictServerOwinHandlers
SuppressFormsAuthenticationRedirect<ApplyJsonWebKeySetResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyJsonWebKeySetResponseContext>.Descriptor,
ProcessJsonResponse<ApplyJsonWebKeySetResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Exchange.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers
{
public static class Exchange
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token request extraction:
*/
@ -34,6 +35,6 @@ public static partial class OpenIddictServerOwinHandlers
AttachCacheControlHeader<ApplyTokenResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyTokenResponseContext>.Descriptor,
ProcessJsonResponse<ApplyTokenResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Introspection.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers
{
public static class Introspection
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Introspection request extraction:
*/
@ -28,6 +29,6 @@ public static partial class OpenIddictServerOwinHandlers
SuppressFormsAuthenticationRedirect<ApplyIntrospectionResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyIntrospectionResponseContext>.Descriptor,
ProcessJsonResponse<ApplyIntrospectionResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Revocation.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers
{
public static class Revocation
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Revocation request extraction:
*/
@ -29,6 +30,6 @@ public static partial class OpenIddictServerOwinHandlers
AttachCacheControlHeader<ApplyRevocationResponseContext>.Descriptor,
AttachWwwAuthenticateHeader<ApplyRevocationResponseContext>.Descriptor,
ProcessJsonResponse<ApplyRevocationResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Session.cs

@ -16,7 +16,8 @@ public static partial class OpenIddictServerOwinHandlers
{
public static class Session
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* End-session request extraction:
*/
@ -40,7 +41,7 @@ public static partial class OpenIddictServerOwinHandlers
ProcessPassthroughErrorResponse<ApplyEndSessionResponseContext, RequireEndSessionEndpointPassthroughEnabled>.Descriptor,
ProcessLocalErrorResponse<ApplyEndSessionResponseContext>.Descriptor,
ProcessEmptyResponse<ApplyEndSessionResponseContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for restoring cached requests from the request_id, if specified.

5
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.Userinfo.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictServerOwinHandlers
{
public static class UserInfo
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* UserInfo request extraction:
*/
@ -33,6 +34,6 @@ public static partial class OpenIddictServerOwinHandlers
AttachWwwAuthenticateHeader<ApplyUserInfoResponseContext>.Descriptor,
ProcessChallengeErrorResponse<ApplyUserInfoResponseContext>.Descriptor,
ProcessJsonResponse<ApplyUserInfoResponseContext>.Descriptor
]);
];
}
}

5
src/OpenIddict.Server.Owin/OpenIddictServerOwinHandlers.cs

@ -23,7 +23,8 @@ namespace OpenIddict.Server.Owin;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictServerOwinHandlers
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Top-level request processing:
*/
@ -55,7 +56,7 @@ public static partial class OpenIddictServerOwinHandlers
.. Revocation.DefaultHandlers,
.. Session.DefaultHandlers,
.. UserInfo.DefaultHandlers
]);
];
/// <summary>
/// Contains the logic responsible for resolving the request URI from the OWIN environment.

7
src/OpenIddict.Server/OpenIddictServerHandlerDescriptor.cs

@ -31,7 +31,7 @@ public sealed class OpenIddictServerHandlerDescriptor
/// Gets the list of filters responsible for excluding the handler
/// from the activated handlers if it doesn't meet the criteria.
/// </summary>
public ImmutableArray<Type> FilterTypes { get; private set; } = ImmutableArray<Type>.Empty;
public ImmutableArray<Type> FilterTypes { get; private set; } = [];
/// <summary>
/// Gets the order assigned to the handler.
@ -53,8 +53,7 @@ public sealed class OpenIddictServerHandlerDescriptor
/// </summary>
/// <typeparam name="TContext">The event context type.</typeparam>
/// <returns>A new descriptor builder.</returns>
public static Builder<TContext> CreateBuilder<TContext>() where TContext : BaseContext
=> new Builder<TContext>();
public static Builder<TContext> CreateBuilder<TContext>() where TContext : BaseContext => new();
/// <summary>
/// Contains methods allowing to build a descriptor instance.
@ -269,7 +268,7 @@ public sealed class OpenIddictServerHandlerDescriptor
/// Build a new descriptor instance, based on the parameters that were previously set.
/// </summary>
/// <returns>The builder instance, so that calls can be easily chained.</returns>
public OpenIddictServerHandlerDescriptor Build() => new OpenIddictServerHandlerDescriptor
public OpenIddictServerHandlerDescriptor Build() => new()
{
ContextType = typeof(TContext),
FilterTypes = _filters.ToImmutableArray(),

9
src/OpenIddict.Server/OpenIddictServerHandlers.Authentication.cs

@ -20,7 +20,8 @@ public static partial class OpenIddictServerHandlers
{
public static class Authentication
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Authorization request top-level processing:
*/
@ -110,7 +111,7 @@ public static partial class OpenIddictServerHandlers
* Pushed authorization request handling:
*/
AttachPushedPrincipal.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for extracting authorization requests and invoking the corresponding event handlers.
@ -1509,7 +1510,7 @@ public static partial class OpenIddictServerHandlers
throw new InvalidOperationException(SR.GetResourceString(SR.ID0016));
}
await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray()))
await foreach (var scope in _scopeManager.FindByNamesAsync([.. scopes]))
{
var name = await _scopeManager.GetNameAsync(scope);
if (!string.IsNullOrEmpty(name))
@ -3466,7 +3467,7 @@ public static partial class OpenIddictServerHandlers
throw new InvalidOperationException(SR.GetResourceString(SR.ID0016));
}
await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray()))
await foreach (var scope in _scopeManager.FindByNamesAsync([.. scopes]))
{
var name = await _scopeManager.GetNameAsync(scope);
if (!string.IsNullOrEmpty(name))

7
src/OpenIddict.Server/OpenIddictServerHandlers.Device.cs

@ -18,7 +18,8 @@ public static partial class OpenIddictServerHandlers
{
public static class Device
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Device request top-level processing:
*/
@ -61,7 +62,7 @@ public static partial class OpenIddictServerHandlers
* Verification request handling:
*/
AttachUserCodePrincipal.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for extracting device requests and invoking the corresponding event handlers.
@ -502,7 +503,7 @@ public static partial class OpenIddictServerHandlers
throw new InvalidOperationException(SR.GetResourceString(SR.ID0016));
}
await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray()))
await foreach (var scope in _scopeManager.FindByNamesAsync([.. scopes]))
{
var name = await _scopeManager.GetNameAsync(scope);
if (!string.IsNullOrEmpty(name))

5
src/OpenIddict.Server/OpenIddictServerHandlers.Discovery.cs

@ -18,7 +18,8 @@ public static partial class OpenIddictServerHandlers
{
public static class Discovery
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Configuration request top-level processing:
*/
@ -59,7 +60,7 @@ public static partial class OpenIddictServerHandlers
* JSON Web Key Set request handling:
*/
AttachSigningKeys.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for extracting configuration requests and invoking the corresponding event handlers.

7
src/OpenIddict.Server/OpenIddictServerHandlers.Exchange.cs

@ -21,7 +21,8 @@ public static partial class OpenIddictServerHandlers
{
public static class Exchange
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token request top-level processing:
*/
@ -65,7 +66,7 @@ public static partial class OpenIddictServerHandlers
* Token response handling:
*/
NormalizeErrorResponse.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for extracting token requests and invoking the corresponding event handlers.
@ -873,7 +874,7 @@ public static partial class OpenIddictServerHandlers
throw new InvalidOperationException(SR.GetResourceString(SR.ID0016));
}
await foreach (var scope in _scopeManager.FindByNamesAsync(scopes.ToImmutableArray()))
await foreach (var scope in _scopeManager.FindByNamesAsync([.. scopes]))
{
var name = await _scopeManager.GetNameAsync(scope);
if (!string.IsNullOrEmpty(name))

5
src/OpenIddict.Server/OpenIddictServerHandlers.Introspection.cs

@ -21,7 +21,8 @@ public static partial class OpenIddictServerHandlers
{
public static class Introspection
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Introspection request top-level processing:
*/
@ -52,7 +53,7 @@ public static partial class OpenIddictServerHandlers
* Introspection response handling:
*/
NormalizeErrorResponse.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for extracting introspection requests and invoking the corresponding event handlers.

7
src/OpenIddict.Server/OpenIddictServerHandlers.Protection.cs

@ -21,7 +21,8 @@ public static partial class OpenIddictServerHandlers
{
public static class Protection
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token validation:
*/
@ -44,7 +45,7 @@ public static partial class OpenIddictServerHandlers
CreateTokenEntry.Descriptor,
GenerateIdentityModelToken.Descriptor,
AttachTokenPayload.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for resolving the validation parameters used to validate tokens.
@ -338,7 +339,7 @@ public static partial class OpenIddictServerHandlers
{
0 => true, // If no specific token type is expected, accept all token types at this stage.
1 => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ElementAt(0)),
_ => await _tokenManager.HasTypeAsync(token, context.ValidTokenTypes.ToImmutableArray())
_ => await _tokenManager.HasTypeAsync(token, [.. context.ValidTokenTypes])
}))
{
context.Reject(

5
src/OpenIddict.Server/OpenIddictServerHandlers.Revocation.cs

@ -15,7 +15,8 @@ public static partial class OpenIddictServerHandlers
{
public static class Revocation
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Revocation request top-level processing:
*/
@ -45,7 +46,7 @@ public static partial class OpenIddictServerHandlers
* Revocation response handling:
*/
NormalizeErrorResponse.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for extracting revocation requests and invoking the corresponding event handlers.

5
src/OpenIddict.Server/OpenIddictServerHandlers.Session.cs

@ -20,7 +20,8 @@ public static partial class OpenIddictServerHandlers
{
public static class Session
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* End-session request top-level processing:
*/
@ -53,7 +54,7 @@ public static partial class OpenIddictServerHandlers
*/
AttachPostLogoutRedirectUri.Descriptor,
AttachResponseState.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for extracting end session requests and invoking the corresponding event handlers.

5
src/OpenIddict.Server/OpenIddictServerHandlers.Userinfo.cs

@ -15,7 +15,8 @@ public static partial class OpenIddictServerHandlers
{
public static class UserInfo
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* UserInfo request top-level processing:
*/
@ -38,7 +39,7 @@ public static partial class OpenIddictServerHandlers
AttachPrincipal.Descriptor,
AttachAudiences.Descriptor,
AttachClaims.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for extracting userinfo requests and invoking the corresponding event handlers.

5
src/OpenIddict.Server/OpenIddictServerHandlers.cs

@ -23,7 +23,8 @@ namespace OpenIddict.Server;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictServerHandlers
{
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictServerHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Top-level request processing:
*/
@ -126,7 +127,7 @@ public static partial class OpenIddictServerHandlers
.. Revocation.DefaultHandlers,
.. Session.DefaultHandlers,
.. UserInfo.DefaultHandlers
]);
];
/// <summary>
/// Contains the logic responsible for inferring the endpoint type from the request URI.

5
src/OpenIddict.Validation.AspNetCore/OpenIddictValidationAspNetCoreHandlers.cs

@ -23,7 +23,8 @@ namespace OpenIddict.Validation.AspNetCore;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictValidationAspNetCoreHandlers
{
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Request top-level processing:
*/
@ -55,7 +56,7 @@ public static partial class OpenIddictValidationAspNetCoreHandlers
AttachCacheControlHeader<ProcessErrorContext>.Descriptor,
AttachWwwAuthenticateHeader<ProcessErrorContext>.Descriptor,
ProcessChallengeErrorResponse<ProcessErrorContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for resolving the request URI from the ASP.NET Core environment.

5
src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.Protection.cs

@ -21,12 +21,13 @@ public static partial class OpenIddictValidationDataProtectionHandlers
{
public static class Protection
{
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Token validation:
*/
ValidateDataProtectionToken.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for validating tokens generated using Data Protection.

3
src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionHandlers.cs

@ -12,6 +12,5 @@ namespace OpenIddict.Validation.DataProtection;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictValidationDataProtectionHandlers
{
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; }
= ImmutableArray.Create([.. Protection.DefaultHandlers]);
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; } = [.. Protection.DefaultHandlers];
}

5
src/OpenIddict.Validation.Owin/OpenIddictValidationOwinHandlers.cs

@ -22,7 +22,8 @@ namespace OpenIddict.Validation.Owin;
[EditorBrowsable(EditorBrowsableState.Never)]
public static partial class OpenIddictValidationOwinHandlers
{
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Request top-level processing:
*/
@ -58,7 +59,7 @@ public static partial class OpenIddictValidationOwinHandlers
AttachCacheControlHeader<ProcessErrorContext>.Descriptor,
AttachWwwAuthenticateHeader<ProcessErrorContext>.Descriptor,
ProcessChallengeErrorResponse<ProcessErrorContext>.Descriptor
]);
];
/// <summary>
/// Contains the logic responsible for resolving the request URI from the OWIN environment.

5
src/OpenIddict.Validation.SystemNetHttp/OpenIddictValidationSystemNetHttpHandlers.Discovery.cs

@ -12,7 +12,8 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers
{
public static class Discovery
{
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; } = ImmutableArray.Create([
public static ImmutableArray<OpenIddictValidationHandlerDescriptor> DefaultHandlers { get; } =
[
/*
* Configuration request processing:
*/
@ -56,6 +57,6 @@ public static partial class OpenIddictValidationSystemNetHttpHandlers
ExtractWwwAuthenticateHeader<ExtractJsonWebKeySetResponseContext>.Descriptor,
ValidateHttpResponse<ExtractJsonWebKeySetResponseContext>.Descriptor,
DisposeHttpResponse<ExtractJsonWebKeySetResponseContext>.Descriptor
]);
];
}
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save