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

Handle not-logged-in public repos with credsStore #731

Merged
merged 3 commits into from
Jan 25, 2025
Merged
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
11 changes: 11 additions & 0 deletions e2e/assertion/credential-helper/docker-credential-devpod-esque
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
read -r URL


if [[ "$URL" != "localhost:1447" ]]; then
echo "expected registry url to be localhost:1447";
exit 1
fi

echo "{\"ServerURL\": \"$URL\", \"Username\": \"\", \"Secret\": \"\"}"

15 changes: 14 additions & 1 deletion e2e/assertion/oci_pull_auth_tests.bats
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,17 @@ EOF
update_assert '{"Authorization": ["Basic not_match"]}'
run bazel build @empty_image//... $BAZEL_FLAGS
assert_failure
}
}

@test "empty username and password succeeds" {
cat > "$DOCKER_CONFIG/config.json" <<EOF
{
"credHelpers": {
"localhost:1447": "devpod-esque"
}
}
EOF
update_assert ''
run bazel build @empty_image//... $BAZEL_FLAGS
assert_success
}
2 changes: 1 addition & 1 deletion oci/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _digest(name, **kwargs):
jq(
name = name + ".digest",
args = ["--raw-output"],
srcs = ["_{}_index.json".format(name)],
srcs = ["{}_index.json".format(name)],
filter = """.manifests[0].digest""",
out = name + ".json.sha256", # path chosen to match rules_docker for easy migration
**kwargs
Expand Down
5 changes: 5 additions & 0 deletions oci/private/authn.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ exec "docker-credential-{}" get <<< "$1" """.format(helper_name),

response = json.decode(result.stdout)

# If the username and secret are empty, the user does not have a login.
# Returning {} avoids sending invalid Basic auth headers that result in 401's
if response["Username"] == "" and response["Secret"] == "":
return {}

return {
"type": "basic",
"login": response["Username"],
Expand Down
Loading