Skip to main content

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.

Usage

uvx hf-auth-helper agent login

One interactive command:

  1. 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.
  2. Organizations — if you're already logged into the hf CLI, your orgs are detected and offered as a checklist; otherwise enter names manually.
  3. 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.
  4. 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.
  5. Storage — keep it as a named hf CLI profile (activate with hf auth switch), make it the primary token (your current login is preserved as a named profile, never destroyed), or write an HF_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

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hf_auth_helper-0.1.0.tar.gz (689.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hf_auth_helper-0.1.0-py3-none-any.whl (794.3 kB view details)

Uploaded Python 3

File details

Details for the file hf_auth_helper-0.1.0.tar.gz.

File metadata

  • Download URL: hf_auth_helper-0.1.0.tar.gz
  • Upload date:
  • Size: 689.1 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

Hashes for hf_auth_helper-0.1.0.tar.gz
Algorithm Hash digest
SHA256 955fdf2a58d25c84dfeedcd92226dea24aa87fee1c257821fd040fe18409323d
MD5 7dc24fd85ed2a1d06e502ca3a4afa859
BLAKE2b-256 bfc85ac2fd0f47fcb6081f8f6d9d87e06184eee9dd88c4a5a287d2d48633f98d

See more details on using hashes here.

File details

Details for the file hf_auth_helper-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hf_auth_helper-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 794.3 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

Hashes for hf_auth_helper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 733cee40efc9ba2b06309fc13a03aefebd67b59a8701ebfb920f61fca9d10310
MD5 a84700a7eb07af4d4835232fa52bad86
BLAKE2b-256 434c260ed2e253461c051acb977760b40a046465529f28da304c64adea26508e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page