Skip to content

Commit

Permalink
feat(auth): add defensive code for missing token build_image
Browse files Browse the repository at this point in the history
  • Loading branch information
brucetony committed Oct 17, 2024
1 parent 71f3030 commit aee09a3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hub_adapter/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ async def get_hub_public_key() -> dict:

async def verify_idp_token(token: str = Security(idp_oauth2_scheme)) -> dict:
"""Decode the auth token using keycloak's public key."""
if not token:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=str("Missing or invalid token"),
headers={"WWW-Authenticate": "Bearer"},
)

try:
return jwt.decode(
token,
Expand Down

0 comments on commit aee09a3

Please sign in to comment.