Skip to content

Commit

Permalink
Catch and log errors when an old/invalid JWT token is parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Dec 21, 2024
1 parent e843bbf commit 6f862c8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions neon_hana/auth/client_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from jwt import DecodeError, ExpiredSignatureError
from ovos_utils import LOG
from pydantic import ValidationError
from token_throttler import TokenThrottler, TokenBucket
from token_throttler.storage import RuntimeStorage

Expand Down Expand Up @@ -363,6 +364,8 @@ def validate_auth(self, token: str, origin_ip: str) -> bool:
username=auth.sub, client_id=auth.client_id, access_token=token,
refresh_token="", expiration=auth.exp)
return True
except ValidationError:
LOG.error(f"Invalid token data received from {origin_ip}.")
except DecodeError:
# Invalid token supplied
pass
Expand Down

0 comments on commit 6f862c8

Please sign in to comment.