Skip to content

make type claim optional #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fastapi_jwt_auth/auth_jwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ def _verify_jwt_in_request(
issuer = self._decode_issuer if type_token == 'access' else None
self._verifying_token(token,issuer)

if self.get_raw_jwt(token)['type'] != type_token:
if 'type' in token and self.get_raw_jwt(token)['type'] != type_token:
msg = "Only {} tokens are allowed".format(type_token)
if type_token == 'access':
raise AccessTokenRequired(status_code=422,message=msg)
Expand All @@ -632,7 +632,7 @@ def _verifying_token(self,encoded_token: str, issuer: Optional[str] = None) -> N
:param issuer: expected issuer in the JWT
"""
raw_token = self._verified_token(encoded_token,issuer)
if raw_token['type'] in self._denylist_token_checks:
if 'type' in raw_token and raw_token['type'] in self._denylist_token_checks:
self._check_token_is_revoked(raw_token)

def _verified_token(self,encoded_token: str, issuer: Optional[str] = None) -> Dict[str,Union[str,int,bool]]:
Expand Down