-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
Support private repository requiring authentication with Authorization http header in a more secure manner #80
Comments
Thanks for reporting this issue -- this is one of the areas that we want to tackle as soon as possible. @dkelmer is looking into a better HTTP downloader mechanism in Bazel that works with more auth approaches, including the ones you've mentioned. Currently, we rely on Coursier CLI's API, which only supports the URL scheme approach. To work around directly checking in usernames and passwords in your WORKSPACE, I thought of a few approaches:
load("//secrets:maven.bzl", "USERNAME", "PASSWORD")
maven_install(
# ...
repositories = [
"http://%s:%s@localhost:8081/artifactory/my-repository" % (USERNAME, PASSWORD),
],
)
git_repository(
name = "secrets_repository",
remote = "git@githost.com:secrets/secrets.git",
tag = "...",
)
load("@secrets_repository//secrets:maven.bzl", "USERNAME", "PASSWORD")
maven_install(
# ...
repositories = [
"http://%s:%s@localhost:8081/artifactory/my-repository" % (USERNAME, PASSWORD),
],
) I don't think http_archive supports authentication yet, but the
local_repository(
name = "secrets_repository",
path = "/path/to/secrets/",
)
load("@secrets_repository//secrets:maven.bzl", "USERNAME", "PASSWORD")
maven_install(
# ...
repositories = [
"http://%s:%s@localhost:8081/artifactory/my-repository" % (USERNAME, PASSWORD),
],
) Do any of these approaches work for you? |
Thanks for the feedback. I already thought of something like approach 1 as a workaround, i.e. have a Bazel file in Can you think of a solution that would work with Thanks for the update on the HTTP downloader feature request. Really appreciate it. I believe this will be the key because we really need http header auth for our repo servers. |
We can do something with environment variables.
and in the WORKSPACE file: maven_install(
# ...
repositories = [
"http://{MAVEN_USERNAME}:{MAVEN_PASSWORD}@localhost:8081/artifactory/my-repository",
],
) Just before we invoke Coursier, we call This approach also works with
Note that the What do you think about this approach? |
Looks like Coursier is reworking its credential handling upstream, with support for environment variables and reading from a properties file: coursier/coursier#1102 |
Would either or both be a required dependency for fixing this one?
|
cc @dkelmer Both |
FWIW, I've created a local little proxy to deal with authenticated Maven repositories. It also supports streaming from the local |
I have a Coursier properties file in: |
@KaoruDev I think that may be due to coursier/coursier#1319 |
I had to add this:
Now my build seems to be getting closer to working. |
Seems coursier/coursier#1350 fixed the issue, looks like bumping to version |
I got them to fully publish that version yesterday, it should be possible to bump it now. |
😭 Sorry doesn't seem to have fix the issue. I've tried:
|
Mine is being found via |
Maybe this is a MacOSx problem, I have a config file in |
Reopening as issue is still reported on macOS. |
I've tried on macOS with credentials in ~/Library/Preferences/Coursier/credentials.properties with ERROR: An error occurred during the fetch of repository 'maven': |
@whs, @puffnfresh provided a fix in #248. Could you please try pulling rules_jvm_external from the latest commit and give it a shot? |
Seems to be working for me. (with |
sorry, I'm missing where to put |
In credentials.properties, #80 (comment) |
Thanks for verifying, folks. |
@jin sorry I was too quick to declare this fixed and I now believe this is a What changed?When I confirmed things were working, I just ran Now that I'm bringing in a project that is using a private version, I encountered an Authentication issue when running sync via Intellij. I verified pulling down the artifact using the Coursier CLI works. |
Ok I was wrong ^ the issue I'm facing is not related to auth but rather the fact that the JAR i'm trying to pull down has additional letters to it. As an example: |
I have a similar error, take a look please:
I'm fighting with this.
-> But i still get the above error. |
I describe a path to a workaround using a private fork in #414 but my fix was for / not @ case so my private fork workaround wouldn't work for you. |
Good job ! |
The current support for HTTP basic authentication relies on
username:password@
URL schema.There are few flaws with this approach:
username:password@
URL scheme. Some admins disable it intentionally for security reasons.username:password@
URL scheme requires persisting username and passwords in clear text in Bazel files, which are committed to SCM. This is almost impossible to deploy in any corporate environment.Bonus points:
~/.m2/settings.xml
~/.m2/settings.xml
The text was updated successfully, but these errors were encountered: