-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add support for installing packages from authenticated repositories, with keyring
support
#729
Comments
My thoughts about this, initially a brain dump, to be edited and extended, here or elsewhere. Must have
Nice to have
UI for usersI am not a big fan of the renv UI where the user needs to set an option to a function for a couple of reasons:
I like the idea of having utility functions to get/set credentials:
I would not store the username in the repo URL, or at least that should not be required. If the username is not there, then the admin can configure repo URLs for all users easier. Again, we could follow what git does here when it looks up credentials (including usernames) from the credential store. Issues with the keyring and oskeyring packagesWe need to solve these at some point, some seem urgent, some not.
ImplementationA significant part of this should go into the pkgcache package. pkgcache handles all HTTP for downloading metadata and packages. So I think the first step would be to implement everything in pkgcache, and then solve the issues with embedding the new pkgcache into pak. The HTTP client functions in https://github.com/r-lib/pkgcache/blob/main/R/async-http.R have a |
This commit updates both the metadata and package caches to support downloading packages and package indexes from repositories that require HTTP basic authentication to access. Initial support for these authenticated repositories is very narrow: the repository URL must contain a username, no password, and have an entry in the system keyring. We also don't make any attempt to prompt users for credentials when requests fail. Unit tests are included for the new authentication header helpers, but there are currently no tests of end-to-end workflows with an authenticated repository, and I may have missed something. Part of r-lib/pak#729. Signed-off-by: Aaron Jacobs <[email protected]>
This commit updates both the metadata and package caches to support downloading packages and package indexes from repositories that require HTTP basic authentication to access. Initial support for these authenticated repositories is very narrow: the repository URL must contain a username, no password, and have an entry in the system keyring. We also don't make any attempt to prompt users for credentials when requests fail. Unit tests are included for the new authentication header helpers, but there are currently no tests of end-to-end workflows with an authenticated repository, and I may have missed something. Part of r-lib/pak#729. Signed-off-by: Aaron Jacobs <[email protected]>
We're expecting to add an authenticated repositories feature to Posit Package Manager soon. Because we're hoping to support both Python and R, we're limited by the fact that
pip
and friends only support HTTP Basic Auth. So we know there won't be e.g. complex OAuth flows involved.Now, it's technically possible to install packages from repos that use basic authentication today, e.g. with
but I'm really not a fan of this approach because I think it will lead users to copy around and embed plaintext credentials in configuration files. We've also found that it can cause issues on Windows if the password is too long -- which it will be in the case of a JWT.
Instead, I think we should follow the example of tools like
pip
anduv
here, too, by checking the system keyring for passwords automatically.(
renv
also has a very flexible mechanism for configuring auth headers that could be wired up to the system keyring, too.)For example, when
pak
is installing packages from a repository URL likehttps://[email protected]/cran/latest
, we could automatically check whether there is a corresponding "password" (or more likely, a token or API key or some kind) in the system keyring and use that to construct anAuthorization
header:the above should work with
renv
, too, viaoptions(renv.download.headers = repo_auth)
.To help users out, we could also have a utility function to set this "password". I'm imagining an API something like the following:
This would call the equivalent of
under the hood.
A more advanced implementation might also prompt the user for credentials when a repo returns a
HTTP 401
in an interactive session, and offer to save them in the system keyring. (This is impossible withinstall.packages()
because that function swallows401
responses.)Note: one could test basic auth support in
pak
by running a local NGINX with basic auth enabled proxying tohttps://p3m.dev
.I'm happy to help out with this, but I need some pointers on where the relevant changes would need to be made.
The text was updated successfully, but these errors were encountered: