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 private repository authentication regression in 2.6 #219

Merged
merged 1 commit into from
Aug 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 22 additions & 5 deletions coursier.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,8 @@ def _coursier_fetch_impl(repository_ctx):
# The repository for the primary_url has to be one of the repositories provided through
# maven_install. Since Maven artifact URLs are standardized, we can make the `http_file`
# targets more robust by replicating the primary url for each specified repository url.
#
# It does not matter if the artifact is on a repository or not, since http_file takes
#
# It does not matter if the artifact is on a repository or not, since http_file takes
# care of 404s.
#
# If the artifact does exist, Bazel's HttpConnectorMultiplexer enforces the SHA-256 checksum
Expand All @@ -724,9 +724,26 @@ def _coursier_fetch_impl(repository_ctx):
repository_urls = [r["repo_url"] for r in repositories]
for url in repository_urls:
if primary_url.find(url) != -1:
primary_repository_url = url
primary_artifact_path = primary_url[len(primary_repository_url):]
mirror_urls = [url + primary_artifact_path for url in repository_urls]
primary_artifact_path = primary_url[len(url):]
elif url.find("@") != -1 and primary_url.find(url[url.rindex("@"):]) != -1:
# Maybe this is a url-encoded private repository url.
#
# A private repository url looks like this:
# http://admin:passw@rd@localhost/artifactory/jcenter
#
# Or, in its URL encoded form:
# http://admin:passw%40rd@localhost/artifactory/jcenter
#
# However, in the primary_url we've reconstructed using the
# downloaded relative file path earlier on, the password is
# removed by Coursier (as it should). So we end up working
# with: http://admin@localhost/artifactory/jcenter
#
# So, we use rfind to get the index of the final '@' in the
# repository url instead.
primary_artifact_path = primary_url[len(url):]

mirror_urls = [url + primary_artifact_path for url in repository_urls]
artifact.update({"mirror_urls": mirror_urls})

# Compute the sha256 of the file.
Expand Down