Skip to content

Commit

Permalink
feat: allow Bearer as valid token type on model service authenticat…
Browse files Browse the repository at this point in the history
…ion (#2583)
  • Loading branch information
kyujin-cho authored Jul 31, 2024
1 parent 8adbc7c commit fb196c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions changes/2583.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow `Bearer` as valid token type on model service authentication
4 changes: 2 additions & 2 deletions src/ai/backend/wsproxy/proxy/frontend/http/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def ensure_credential(self, request: web.Request, circuit: Circuit) -> None:
if not auth_header:
raise InvalidCredentials("E20006: Authorization header not provided")
auth_type, auth_key = auth_header.split(" ", maxsplit=2)
if auth_type == "BackendAI":
if auth_type in ("BackendAI", "Bearer"):
token = auth_key
else:
raise InvalidCredentials(
Expand All @@ -64,7 +64,7 @@ def ensure_credential(self, request: web.Request, circuit: Circuit) -> None:
except jwt.PyJWTError as e:
raise InvalidCredentials from e

if decoded.get("id") != circuit.id:
if decoded.get("id") != str(circuit.id):
raise InvalidCredentials("E20008: Authorization token mismatch")

async def initialize_backend(self, circuit: Circuit, routes: list[RouteInfo]) -> HTTPBackend:
Expand Down

0 comments on commit fb196c8

Please sign in to comment.