From aacdaa5d69690714776c3860deb4e9b58c4f7ac9 Mon Sep 17 00:00:00 2001 From: Don Kendall Date: Sat, 18 Jan 2025 08:19:45 -0500 Subject: [PATCH] fix: show audience_type_custom fix: hide --- auth_jwt/models/auth_jwt_validator.py | 8 ++++---- auth_jwt/views/auth_jwt_validator_views.xml | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/auth_jwt/models/auth_jwt_validator.py b/auth_jwt/models/auth_jwt_validator.py index b78683a1fa..687e8e34a3 100644 --- a/auth_jwt/models/auth_jwt_validator.py +++ b/auth_jwt/models/auth_jwt_validator.py @@ -205,7 +205,7 @@ def _decode(self, token, secret=None): raise UnauthorizedInvalidToken() from e key = self._get_key(header.get("kid")) algorithm = self.public_key_algorithm - aud = self.audience.split(",") if self.audience_type == "aud" else None + aud = (self.audience or "").split(",") if self.audience_type == "aud" else None try: payload = jwt.decode( token, @@ -224,9 +224,9 @@ def _decode(self, token, secret=None): if self.audience_type == "custom" else self.audience_type ) - if len((self.audience).split(",") or []) > 0: - for key_value in (self.audience).split(","): - if key_value in (payload.get(payload_key)).split(" "): + if len((self.audience or "").split(",") or []) > 0: + for key_value in (self.audience or "").split(","): + if key_value in (payload.get(payload_key) or "").split(" "): return payload raise UnauthorizedInvalidToken() except Exception as e: diff --git a/auth_jwt/views/auth_jwt_validator_views.xml b/auth_jwt/views/auth_jwt_validator_views.xml index fcdcac1846..1a6f054ee2 100644 --- a/auth_jwt/views/auth_jwt_validator_views.xml +++ b/auth_jwt/views/auth_jwt_validator_views.xml @@ -13,6 +13,10 @@ +