Skip to content

Commit

Permalink
fix: support http basic auth for curl downloader (#268)
Browse files Browse the repository at this point in the history
Co-authored-by: João Guerra <[email protected]>
  • Loading branch information
joca-bt and joca-bt authored Jun 14, 2023
1 parent 5ba2ace commit 7fd951a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions oci/private/download.bzl
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
"Downloader functions "

load("@aspect_bazel_lib//lib:base64.bzl", "base64")

def _auth_to_header(url, auth):
for auth_url in auth:
if auth_url == url:
auth_val = auth[auth_url]

# TODO: basic type
if auth_val["type"] == "pattern":
if auth_val["type"] == "basic":
credentials = base64.encode("{}:{}".format(auth_val["login"], auth_val["password"]))
return [
"--header",
"Authorization: Basic {}".format(credentials),
]
elif auth_val["type"] == "pattern":
token = auth_val["pattern"].replace("<password>", auth_val["password"])
return [
"--header",
Expand Down

0 comments on commit 7fd951a

Please sign in to comment.