Skip to content

Commit

Permalink
fix: Wrong approach to auth
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Aug 1, 2024
1 parent f2f02d1 commit 2d06389
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/ai/backend/common/docker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

import base64
import enum
import functools
import ipaddress
Expand Down Expand Up @@ -235,18 +234,6 @@ async def login(
"""
basic_auth: Optional[aiohttp.BasicAuth]

if "public.ecr" in str(registry_url) or "dkr.ecr" in str(registry_url):
auth_token = base64.b64encode(
f"{credentials["username"]}:{credentials["password"]}".encode()
).decode()

return {
"auth": None,
"headers": {
"Authorization": f"Bearer {auth_token}",
},
}

if credentials.get("username") and credentials.get("password"):
basic_auth = aiohttp.BasicAuth(
credentials["username"],
Expand All @@ -271,7 +258,7 @@ async def login(
return {"auth": basic_auth, "headers": {}}
elif ping_status == 404:
raise RuntimeError(f"Unsupported docker registry: {registry_url}! (API v2 not implemented)")
elif ping_status == 401:
elif ping_status in [400, 401]:
params = {
"scope": scope,
"offline_token": "true",
Expand Down

0 comments on commit 2d06389

Please sign in to comment.