@@ -28,7 +28,7 @@ class NoopAccessResolver(AccessResolver): # pylint: disable=too-few-public-meth
2828 """No-op access resolver that does not perform any access checks."""
2929
3030 async def check_access (self , action : Action , user_roles : UserRoles ) -> bool :
31- """Always return True, indicating access is granted."""
31+ """Return True always , indicating access is granted."""
3232 _ = action # Unused
3333 _ = user_roles # Unused
3434 return True
@@ -68,22 +68,19 @@ def __init__(self, role_rules: list[JwtRoleRule]):
6868
6969 async def resolve_roles (self , auth : AuthTuple ) -> UserRoles :
7070 """Extract roles from JWT claims using configured rules."""
71-
7271 jwt_claims = self ._get_claims (auth )
7372 return frozenset (
7473 role
7574 for rule in self .role_rules
76- for role in self ._evaluate_role_rules (rule , jwt_claims )
75+ for role in self .evaluate_role_rules (rule , jwt_claims )
7776 )
7877
7978 @staticmethod
80- def _evaluate_role_rules (
81- rule : JwtRoleRule , jwt_claims : dict [str , Any ]
82- ) -> UserRoles :
83- """Get roles from a JWT role rule if it matches the claims"""
79+ def evaluate_role_rules (rule : JwtRoleRule , jwt_claims : dict [str , Any ]) -> UserRoles :
80+ """Get roles from a JWT role rule if it matches the claims."""
8481 return (
8582 frozenset (rule .roles )
86- if __class__ ._evaluate_operator (
83+ if JwtRolesResolver ._evaluate_operator (
8784 rule .negate ,
8885 [match .value for match in parse (rule .jsonpath ).find (jwt_claims )],
8986 rule .operator ,
@@ -147,6 +144,7 @@ def __init__(self, access_rules: list[AccessRule]):
147144 self ._access_lookup [rule .role ].update (rule .actions )
148145
149146 async def check_access (self , action : Action , user_roles : UserRoles ) -> bool :
147+ """Check if the user has access to the specified action based on their roles."""
150148 if action != Action .ADMIN and self .check_access (action .ADMIN , user_roles ):
151149 # Recurse to check if the roles allow the user to perform the admin action,
152150 # if they do, then we allow any action
0 commit comments