From 296e008c8d0c6b9459ce99105a2cca3d53cabe23 Mon Sep 17 00:00:00 2001 From: Jvst Me Date: Tue, 15 Oct 2024 12:54:15 +0200 Subject: [PATCH] Fix token auth when `service` is missing Make the `service` parameter optional when fetching a bearer token, since some registries do not use it. The same logic can be found in containerd: https://github.com/containerd/containerd/blob/61f91b963ef244daec1bda6700fe3f0b1aee50c6/core/remotes/docker/auth/fetch.go#L187 --- dxf/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dxf/__init__.py b/dxf/__init__.py index 60dd8b7..3a0cd93 100644 --- a/dxf/__init__.py +++ b/dxf/__init__.py @@ -302,7 +302,8 @@ def authenticate(self, scope = '' url_parts = list(urlparse.urlparse(info['realm'])) query = urlparse.parse_qsl(url_parts[4]) - query.append(('service', info['service'])) + if 'service' in info: + query.append(('service', info['service'])) query.extend(('scope', s) for s in scope.split()) url_parts[4] = urlencode(query, True) url_parts[0] = 'https'