Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Feature request: Respect GH_PAT, GITHUB_TOKEN, or GH_TOKEN in addition to GITHUB_PAT #1937

Closed
dvg-p4 opened this issue Jul 1, 2024 · 5 comments

Comments

@dvg-p4
Copy link

dvg-p4 commented Jul 1, 2024

I believe the gh utility will use any of these environment variable as a PAT; pretty sure GITHUB_TOKEN is the recommended one (though the docs are a bit unclear).

@kevinushey
Copy link
Collaborator

We do try to use gitcreds already here:

renv/R/download.R

Lines 547 to 550 in 65ac9cb

# if gitcreds is available, try to use it
gitcreds <-
getOption("renv.gitcreds.enabled", default = TRUE) &&
requireNamespace("gitcreds", quietly = TRUE)

Does gh do something that gitcreds does not? Are there other places where we need to use this?

@kevinushey
Copy link
Collaborator

There's quite a few places where we use "GITHUB_PAT", so we'll probably need to audit all of these.

@dvg-p4
Copy link
Author

dvg-p4 commented Jul 3, 2024

On the other hand, looking through the link recommended by the error message (https://usethis.r-lib.org/articles/git-credentials.html)...

Allow tools to store and retrieve your credentials from the Git credential store. If you have previously set your GitHub PAT in .Renviron, stop doing that.

and gitcreds says:

However, we still suggest that you add your token to the git credential
store with gitcreds_set() and remove GITHUB_PAT from your
.Renviron file. The credential store is more secure than storing
tokens in files

So maybe the whole envar thing is an antipattern.

On the other other hand, man git-credential-store says:

Using this helper will store your passwords unencrypted on disk, protected only by filesystem permissions.

so at the end of the day I'm not sure that introducing the extra dependency here actually does all that much for security.

@dvg-p4
Copy link
Author

dvg-p4 commented Jul 3, 2024

It looks like gh actually just respects GITHUB_TOKEN and GH_TOKEN (but not *_PAT).

While gitcreds respects GITHUB_TOKEN and GITHUB_PAT (but not GH_*).

@kevinushey
Copy link
Collaborator

Should be resolved in 37f5b31 -- let me know if all seems well on your side.

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

No branches or pull requests

2 participants