Skip to content

Commit

Permalink
fix: better error handling on malformed tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
nampereira committed Aug 8, 2024
1 parent 28944e2 commit 0dd7a62
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions arena/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,14 @@ def _remove_credentials(cred_dir, expire=False):
print(f"{err}, {test_mqtt_path}")
os.remove(test_mqtt_path)
return
mqtt_claims = jwt.decode(mqtt_token["token"], options={
"verify_signature": False})
try:
mqtt_claims = jwt.decode(mqtt_token["token"], options={
"verify_signature": False})
except Exception as err:
print(f"{err}, {test_mqtt_path}")
os.remove(test_mqtt_path)
return

exp = float(mqtt_claims["exp"])
now = time.time()
if expire and now < exp:
Expand Down

0 comments on commit 0dd7a62

Please # to comment.