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

bzlmod doesn't use credentials stored in .netrc files #15286

Closed
ferraith opened this issue Apr 19, 2022 · 0 comments
Closed

bzlmod doesn't use credentials stored in .netrc files #15286

ferraith opened this issue Apr 19, 2022 · 0 comments
Assignees
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests help wanted Someone outside the Bazel team could own this P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@ferraith
Copy link

ferraith commented Apr 19, 2022

Description of the bug:

bzlmod supports to store modules in private registries. These reqistries can be pass with the --registry parameter to bazel. In corporate environments there could be a use case that for security reasons access to a private registry must be limited, e.g. by basic authentication with a username and password. Often these credentials are stored in a .netrc file.

It looks like that bzlmod doesn't check if credentials for a private registry are available in a .netrc file. Bazel just throws a 401 error:
ERROR: Error accessing registry https://my.local-registry.com/bazel-central-registry: GET returned 401

I also tried to pass the username within the URI:
https://<username>:<password>@my.local-registry.com/bazel-central-registry
But also this credentials aren't used by bzlmod.

To ensure that basically the credentials are correct and used by Bazel I tried to download a single file from the private registry with http_file. This works out of the box. The credentials of the .netrc file are used.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  • Setup a private registry and enable basic authentication
  • Set the private registry e.g. in .bazelrc file: common --registry <my-registry-url>
  • Call some bazel command

Which operating system are you running Bazel on?

Ubuntu 20.04

What is the output of bazel info release?

release 5.1.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

not relevant

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@Wyverald Wyverald added type: bug P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. help wanted Someone outside the Bazel team could own this area-Bzlmod Bzlmod-specific PRs, issues, and feature requests labels Apr 19, 2022
@andyrinne12 andyrinne12 self-assigned this Aug 3, 2022
@Wyverald Wyverald added this to the 6.0.0 release blockers milestone Aug 24, 2022
aiuto pushed a commit to aiuto/bazel that referenced this issue Oct 12, 2022
- Refactored `IndexRegistry` to also use `DownloadManager` when downloading  `MODULE.bazel`, `bazel_registry.json` and `source.json` files, which includes passing all URLs through the download configuration file (if present) and using credentials from  .netrc.

- Allow `http_{...}` rules to also use the `machine default` credentials from .netrc if no entry for the specific host is present.

bazelbuild#15286

Closes bazelbuild#15286.

PiperOrigin-RevId: 471745600
Change-Id: I2e49d44c88c7ba6b7ff2148a3b653dee4a814899
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Bzlmod Bzlmod-specific PRs, issues, and feature requests help wanted Someone outside the Bazel team could own this P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

No branches or pull requests

3 participants