-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Allow http_archive and http_file to use a credential-helper executable #15013
Comments
I think this support is fundamental from a security perspective because it allows to avoid storing security credentials in a file. I'd appreciate if this can be prioritized a bit higher and become part of the roadmap. FWIW, any solution should be deeply integrated into Bazel so that other functionality such as #13709 doesn't require additional work to enable it. |
To be a little bit more clear about my feature request, I wasn't suggesting that arbitrary shell snippets should be supported necessarily (because that might be complicated) - more complicated stuff like I was showing for API can be a little tricky to work out the ideal form. My first idea would be simply some executable path (either absolute or workspace-relative like
|
FWIW, I would be happy if Bazel just implements the same protocol that git credentials helper is using. That would open the door for a lot of secure storage options. |
I wrote a design doc for this: /~https://github.com/bazelbuild/proposals/blob/main/designs/2022-06-07-bazel-credential-helpers.md PTAL |
I think there's some tweaks that can make it work, but I'm not sure it makes sense to have a single "jack of all trades"
Ideally, the protocol should be
|
I would also probably drop the part about non-absolute paths |
In an enterprise environment it should never be a rule author deciding if something is put behind a protected URL or not. It needs to be at the discretion of the enterprise users/customers deciding whether to protect URLs or not. That's why I'm a big supporter for a central solution in Bazel without any opt-in/opt-out from rules. I was thinking of the credential helpers to be more globally scoped (eg., an Mac OS Keychain credential helper) rather than being target scoped (AWS vs. GitHub). But I can see the benefit of allowing multiple for different domains. +1 on keeping the protocol simple and allowing for re-use of existing credential helpers. |
To be more clear, my assumption would be that rules would pass that parameter in from an attribute, e.g. http_archive(
name = "foo",
requires_auth = True,
urls = ["https://secret.example.com"],
) So not the rule author's decision, but the decision of whomever is selecting the URL from which to download, which is the appropriate place to be making such a decision. My note about making it a parameter to While in an enterprise context (like the one I'm operating in) there will certainly be a significant number of private dependencies, I'd expect most organizations would either use public archives where possible (e.g. for anything under /~https://github.com/bazelbuild, protocolbuffers, grpc, etc) or would simply vendor everything in. I can't see many organizations maintaining private forks of e.g. I wouldn't want to limit scoping to just being by domain. For example with github you'd probably want to scope credentials to orgs your enterprise manages, while not consuming your account API rate limits for public repos. Likewise for s3/gcs, you'd only need auth on private buckets. Also worth noting for the record, |
Adjusted the proposal to allow workspace-relative credential helpers and specifying which domains to apply a helper to. PTAL (bazelbuild/proposals#264). While I agree that re-using the protocol of an existing credential helper like |
I don't think that's feasible or desirable. There are companies that require that all dependencies are downloaded from an internal mirror, and that requires authentication. Requiring auth to be opt-in per-target seems very much counter-productive for that use case (not that it's easy to achieve today, but we shouldn't make it harder). |
If you try to download from somewhere other than that internal mirror, you definitely wouldn't want bazel to send your authentication credentials there. Also I'm not suggesting require opt-in per target. I'm suggesting that if you really do want a helper to match everything, you need to be explicit about that by providing an empty or wildcard url match for that helper. If we're imagining a situation where some proxy server does url rewriting along the way to redirect things to the internal mirror, then the worst case scenario is your build fails because you didn't provide authentication headers and you have to fix your flags appropriately, which is a much less bad scenario than accidentally sending your credentials to some unexpected URL. |
Ok, I think we can call that resolved then? The proposal now allows to specify helpers that only match certain domains (optionally including all subdomains). |
@Yannic Bazel has built in support for downloader rewriter config. Should there be a word in the spec that this is supported and the credential helper applies to the rewritten (final) URL target? |
Recently, for our internal use cases, I implemented a Implementation of
|
@Yannic have the |
maybe this comment answers my question #15856 (comment) |
To state it clearly: credential helpers aren't wired up to repository fetching yet. We are working on adding it in time for 6.0.0. |
@tjgq is there any update on this? I am assuming this hasn’t made it into 6.0.0 given the status of the issue? |
Coincidentally, I'm working on this as we speak. I'm planning to submit #18173 or something close to it today or early next week. |
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), taking precedence over a .netrc file or an `auth` parameter provided from Starlark. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used to fetch credentials for repository fetching (rctx.download and rctx.download_and_extract), which take precedence over the `auth` parameter. Tests that need a credential helper are skipped on Windows for now, as otherwise the credential helper would have to be reimplemented in Batch or Powershell. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used when available to obtain credentials for repository fetching, taking precedence over the `auth` parameter to rctx.download and rctx.download_and_extract. Tests that need a credential helper are skipped on Windows for now, as otherwise the credential helper would have to be reimplemented in Batch or Powershell. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used when available to obtain credentials for repository fetching, taking precedence over the `auth` parameter to rctx.download and rctx.download_and_extract. Tests that need a credential helper are skipped on Windows for now, as otherwise the credential helper would have to be reimplemented in Batch or Powershell. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013.
After this change, credential helpers will be used when available to obtain credentials for repository fetching, taking precedence over the `auth` parameter to rctx.download and rctx.download_and_extract. Tests that need a credential helper are skipped on Windows for now, as otherwise the credential helper would have to be reimplemented in Batch or Powershell. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013. Closes bazelbuild#18173. PiperOrigin-RevId: 532454935 Change-Id: Ia3be8c21e001a36160f3d1df858593f8fb846055
After this change, credential helpers will be used when available to obtain credentials for repository fetching, taking precedence over the `auth` parameter to rctx.download and rctx.download_and_extract. Tests that need a credential helper are skipped on Windows for now, as otherwise the credential helper would have to be reimplemented in Batch or Powershell. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013. Closes bazelbuild#18173. PiperOrigin-RevId: 532454935 Change-Id: Ia3be8c21e001a36160f3d1df858593f8fb846055
After this change, credential helpers will be used when available to obtain credentials for repository fetching, taking precedence over the `auth` parameter to rctx.download and rctx.download_and_extract. Tests that need a credential helper are skipped on Windows for now, as otherwise the credential helper would have to be reimplemented in Batch or Powershell. Also improve the documentation for credential helper related flags. Fixes #15013. Closes #18173. PiperOrigin-RevId: 532454935 Change-Id: Ia3be8c21e001a36160f3d1df858593f8fb846055
After this change, credential helpers will be used when available to obtain credentials for repository fetching, taking precedence over the `auth` parameter to rctx.download and rctx.download_and_extract. Tests that need a credential helper are skipped on Windows for now, as otherwise the credential helper would have to be reimplemented in Batch or Powershell. Also improve the documentation for credential helper related flags. Fixes bazelbuild#15013. Closes bazelbuild#18173. PiperOrigin-RevId: 532454935 Change-Id: Ia3be8c21e001a36160f3d1df858593f8fb846055
Description of the problem / feature request:
It would be very useful if, in addition to the existing
.netrc
support, thehttp_archive
andhttp_file
repository rules could be configured to use a credential helper executable.Feature requests: what underlying problem are you trying to solve with this feature?
The most important use case for this, at least for our team, but I suspect for others as well, would be downloading release artifacts from private git repositories.
Assuming one has
git
credentials set up properly, one can run e.g.to get the required authorization token (which may be a PAT, or an oauth token, depending on configuration; either will work).
Alternatively, if one is using the
gh
cli tool,Other examples of tools which might be useful for this sort of thing:
access token -app=foo.net
aws ecr get-authorization-token
In most of these cases it's possible to take the provided token and put it in one's
.netrc
, but that's neither convenient nor particularly secure.What operating system are you running Bazel on?
linux
What's the output of
bazel info release
?release 5.0.0
Have you found anything relevant by searching the web?
This is maybe tangentially related to #14372
The text was updated successfully, but these errors were encountered: