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

Look for secrets in keyring too #620

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Look for secrets in keyring too #620

wants to merge 1 commit into from

Conversation

hadley
Copy link
Member

@hadley hadley commented Dec 24, 2024

  • Update vignette

Fixes #346

@gaborcsardi when you get back from break, I'd appreciate your feedback on this. Do you think this is a reasonable way to add keyring support to httr2 so folks can use it instead of env vars? Should httr2 use its own keyring instead of the system default? Or add some prefix to the service name? I think the root cause of my uncertainty is that I don't understand how namespacing is supposed to work with keyrings.

* [ ] Update vignette

Fixes #346
@hadley hadley requested a review from gaborcsardi December 24, 2024 17:17
@@ -134,7 +134,7 @@ test_that("can translate data", {

expect_snapshot({
curl_translate("curl http://example.com --data abcdef")
curl_translate("curl http://example.com --data abcdef -H Content-Type:text/plain")
curl_translate("curl http://example.com --data abcdef -H Content-Type:text/plain") |>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo?

@gaborcsardi
Copy link
Member

General thoughts wrt keyring

There are a couple of things to work out wrt keyring usage in general.

One is that it might "freeze" in a headless setup, because it starts an interactive password dialog. This is how pip deals with this: https://pip.pypa.io/en/stable/topics/authentication/#here-be-dragons
We could possibly do better. E.g. we could start a subprocess to get the password from the keyring, with a 1-2 minute (?) timeout in non-interactive sessions. We should probably also use a different keyring backend on GHA, which is the place where this happens most often (at least for us). We should probably also cache the passwords in the session, at least in interactive sessions (?), because starting up a subprocess is relatively expensive. This should all go into the keyring package, probably.

Another thing is to make sure that all packages look for the same key when looking up the password for a URL. This includes keys across languages, e.g. if there is a password for PPM in the keyring, both R (pak, httr2?, etc.) and pip should find it and use it.

A third thing to work out is to make everything smooth with gitcreds and git passwords in general. This is probably up to the R package. For some packages it makes sense to look at both the git credential store and also keyring natively (pak?), for others probably not.

About this PR

As for this PR, maybe it would make sense to make this opt-in until we figure out some of the details?

Should httr2 message the user about getting the password from the keyring? Or maybe only for 403 responses?

I also wonder it we should give some advice to the user. E.g. if the HTTP response is a 403, and the keyring package was not installed, or there is no password for the site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mention keyring package in Wrapping APIs vignette?
2 participants