bazel icon indicating copy to clipboard operation
bazel copied to clipboard

bzlmod doesn't use credentials stored in .netrc files

Open ferraith opened this issue 3 years ago • 0 comments

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

ferraith avatar Apr 19 '22 12:04 ferraith