Git: find a "better" way to handle tokens than git credential store
See original GitHub issueMentioned in https://github.com/huggingface/huggingface_hub/issues/1043#issuecomment-1246009544.
Currently we store the user token for git commands in the git-credential-store. This is the default git storage that stores creds in plain text in a file. huggingface_hub
warns the user to use it by default to avoid problems (by running git config --global credential.helper store
). In a perfect world, it would be good to use the default credential helper from the user. In particular, macos users have a macosxkeychain tool by default to securely handle credentials.
Another possibility is to not store the credential in git and automatically fill the values (from python) when git requires them (in the Repository
module).
Note: I am no expert on that topic so any addition is welcomed here 😃
Useful links:
- git credentials doc
- git-credential-store doc (the one we use, stores the password in plain in a file)
- git credential doc (higher-level API to abstract the store helper)
(Edit: also to mention that when a user do huggingface-cli login
or notebook_login()
, the token is also stored locally in plain text in the home directory ~/.huggingface/token
to be reused in API calls. Changing this is out of topic for this issue)
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:22 (22 by maintainers)
Top GitHub Comments
I just made some tests with the abstract level that git uses (
git credential [fill|approve|reject]
)If I run:
It will store the credentials in the default helper defined on the user’s machine.
So what we could do is to simply change the current command (from
write_to_credential_store
)with its abstract version. Same for deleting the token (currently using
git credential-store erase)
.Using the default git helper on the machine instead of
store
will be cleaner:store
(doesn’t change for them compared to the current situation)And for users without any git helper configured (e.g. me until 1 week ago 👋), we either show a warning or help them configure a git helper though a CLI. This is already the case anyway.
EDIT: implemented workflow slightly differs from the one below (see description in https://github.com/huggingface/huggingface_hub/pull/1138#issue-1427111831)
Side note from @julien-c: we need to think about the case where a token is already stored in the user helper (as we do not want to overwrite an existing value).
To summarize, here is a workflow I see:
huggingface-cli login
:git credential approve
notebook_login()
in a google colabmain
branch (since this recent PR https://github.com/huggingface/huggingface_hub/pull/1053)notebook_login()
not in a colab: we assume this is a machine owned by the user so same ashuggingface-cli login
git credential approve
huggingface-cli
but if it starts to be complicated (menu/prompt something), just put a warning “hey, please use the CLI”Does that cover every possible use case?
Thanks for reminding this here @LysandreJik ! TBH I completely forgot about this aspect. Dunno yet how to tackle the issue but good to know that the solution has to be through git credential.