Set up safe, scoped Hugging Face authentication for agents: propose-only tokens, verification, and profiles.
Project description
hf-auth-helper
Set up safe, scoped Hugging Face authentication for agents.
Coding agents that read untrusted content (web pages, issues, datasets) can be
prompt-injected. If such an agent holds a normal write token, one injection
can delete your datasets, Spaces, and buckets. hf-auth-helper sets up
propose-only access instead: the agent can read and open pull requests,
but a human has to merge — nothing the agent does is irreversible.
What the agent can do with a token set up this way:
- Read the models, datasets, Spaces, and buckets in its scope (plus whatever optional reads you grant: collections, gated models, …).
- Propose changes to any git-based repo — models, datasets, Spaces — as pull requests with real commits, ready for your review.
- Open and comment on discussions, and manage its own pull requests.
What it cannot do, no matter how it is prompted:
- Merge pull requests (even its own), push to branches, or change any repository settings.
- Write to buckets at all: buckets have no pull-request mechanism and no version history, so any write would be unreviewable and unrecoverable — bucket write access is never part of any selection. Buckets stay read-only for the agent.
- Delete or overwrite anything, anywhere.
The trade-off to know about: the token can still read everything you scope it to, so exfiltration of readable data remains your residual risk — see the threat model in the spec.
Usage
uvx hf-auth-helper agent login
One interactive command:
- Recommended or customize — accept the field-tested access settings, or answer plain-language yes/no questions ("Read gated models?", "Read your billing usage?", …) to narrow them. Reading repo contents and opening pull requests are always included; write access never is.
- Organizations — if you're already logged into the
hfCLI, your orgs are detected and offered as a checklist; otherwise enter names manually. - Token form — a summary of what the token will be able to do, then the Hugging Face token page URL with your scopes preselected. Open it on any device (the tool assumes you may be SSH'd into a remote box and only opens a local browser if you say yes); name the token and click create.
- Verification — paste the token (input stays hidden) and it is checked against the Hub: if its scopes allow anything beyond reading and opening pull requests, it is refused with the violating permissions named, and nothing is stored. Differences from what you configured are reported.
- Storage — keep it as a named
hfCLI profile (activate withhf auth switch), make it the primary token (your current login is preserved as a named profile, never destroyed), or write anHF_TOKEN=line into an env file for a single agent process.
Scripting (no prompts when not a TTY; flags select resources and destinations, never scopes):
uvx hf-auth-helper agent login --org my-org --profile my-agent
uvx hf-auth-helper agent login --env /path/to/agent/.env
uvx hf-auth-helper agent login --url-only # just print the prefill URL
Whatever you select, write capability is limited to opening PRs and discussions. A token created this way cannot push to main, merge PRs, modify buckets, change settings, or delete anything. What it can still do is read everything you granted it — see the threat model in docs/SPECIFICATION.md for why "nothing irreversible" is the guarantee, not "nothing leaks".
The full behavior contract, threat model, and design rationale live in docs/SPECIFICATION.md.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hf_auth_helper-0.1.1.tar.gz.
File metadata
- Download URL: hf_auth_helper-0.1.1.tar.gz
- Upload date:
- Size: 689.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6691510498f273c721e058dfa569283a617d2de76879a8806220070c280bdfb9
|
|
| MD5 |
b3c1e67807088fa382e0544babba4b65
|
|
| BLAKE2b-256 |
617e57a97beea7512552a26ff026abd79cbae2cc99197696f068907f02d11feb
|
File details
Details for the file hf_auth_helper-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hf_auth_helper-0.1.1-py3-none-any.whl
- Upload date:
- Size: 794.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1a55ca7e3d61173a8bf1c15909897b88591e14e04c6e2e6325fa6e926016136
|
|
| MD5 |
238fceffde218efad75ff1e0c30c46a4
|
|
| BLAKE2b-256 |
42e406b3544ae980ef8a54f000ff227b9fa88c493f8ddcf920aa376746e7cbc0
|