diff --git a/src/Ocelot/Authorization/ClaimsAuthorizer.cs b/src/Ocelot/Authorization/ClaimsAuthorizer.cs
index 7f1f150a8..a9d43cb0d 100644
--- a/src/Ocelot/Authorization/ClaimsAuthorizer.cs
+++ b/src/Ocelot/Authorization/ClaimsAuthorizer.cs
@@ -5,6 +5,8 @@
namespace Ocelot.Authorization
{
+ /// Authorizer which is implemented using Claims-based authorization.
+ /// Microsoft Learn: Claims-based authorization in ASP.NET Core.
public class ClaimsAuthorizer : IClaimsAuthorizer
{
private readonly IClaimsParser _claimsParser;
@@ -22,8 +24,12 @@ List urlPathPlaceholderNameAndValues
{
foreach (var required in routeClaimsRequirement)
{
- var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, required.Key);
+ if (string.IsNullOrEmpty(required.Value) || string.IsNullOrWhiteSpace(required.Value))
+ {
+ continue; // if required value is not specified
+ }
+ var values = _claimsParser.GetValuesByClaimType(claimsPrincipal.Claims, required.Key);
if (values.IsError)
{
return new ErrorResponse(values.Errors);
@@ -66,6 +72,11 @@ List urlPathPlaceholderNameAndValues
}
else
{
+ //// if required value is not specified
+ //if (string.IsNullOrEmpty(required.Value))
+ //{
+ // continue;
+ //}
// static claim
var authorized = values.Data.Contains(required.Value);
if (!authorized)