Skip to content

Commit

Permalink
fix: show audience_type_custom
Browse files Browse the repository at this point in the history
  • Loading branch information
dnplkndll committed Jan 18, 2025
1 parent 5da46e0 commit b6cec16
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions auth_jwt/models/auth_jwt_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 207 in auth_jwt/models/auth_jwt_validator.py

View check run for this annotation

Codecov / codecov/patch

auth_jwt/models/auth_jwt_validator.py#L201-L207

Added lines #L201 - L207 were not covered by tests
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,
Expand All @@ -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()

Check warning on line 231 in auth_jwt/models/auth_jwt_validator.py

View check run for this annotation

Codecov / codecov/patch

auth_jwt/models/auth_jwt_validator.py#L231

Added line #L231 was not covered by tests
except Exception as e:
Expand Down
4 changes: 4 additions & 0 deletions auth_jwt/views/auth_jwt_validator_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
</group>
<group colspan="2" string="Token validation">
<field name="audience_type" />
<field
name="audience_type_custom"
modifiers="{'invisible': [('audience_type', '!=', 'custom')]}"
/>
<field name="audience" />
<field name="signature_type" />
<field
Expand Down

0 comments on commit b6cec16

Please sign in to comment.