Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use URL-safe base64 encoding for X-Registry-Auth #941

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/941.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue authenticating against private registries where the `X-Registry-Auth` header would require URL-safe substitutions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Konstantin Valetov
Martin Koppehel
Nikolay Novik
Paul Tagliamonte
Robin Tweedie
Sanghun Lee
Tianon Gravi
Tommy Beadle
Expand Down
2 changes: 1 addition & 1 deletion aiodocker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,4 @@ def compose_auth_header(
auth_json = json.dumps(config).encode("utf-8")
else:
raise TypeError("auth must be base64 encoded string/bytes or a dictionary")
return base64.b64encode(auth_json).decode("ascii")
return base64.urlsafe_b64encode(auth_json).decode("ascii")
8 changes: 8 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,11 @@ def test_clean_filters() -> None:

with pytest.raises(TypeError):
assert utils.clean_filters(filters=())


def test_compose_auth_header():
auth = {"username": "alice", "password": "~"}
assert (
utils.compose_auth_header(auth)
== "eyJ1c2VybmFtZSI6ICJhbGljZSIsICJwYXNzd29yZCI6ICJ-In0="
)
Loading