Skip to content

Commit 3d0c056

Browse files
committed
Guard UUID parsing to avoid 500s on malformed tokens
1 parent ca6fe12 commit 3d0c056

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

api/core/security.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,13 @@ async def _validate_token_uncached(
200200
}
201201

202202
r = UserInfo()
203+
204+
try:
205+
r.user_uuid = UUID(user_id)
206+
except ValueError:
207+
raise credentials_exception from None
208+
203209
r.credentials = token
204-
r.user_uuid = UUID(user_id)
205210
r.user_name = payload.get("preferred_username", "unknown")
206211

207212
# get user's project groups and roles from TDEI

0 commit comments

Comments
 (0)