Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. Pages changed in this PR: |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Lucain <lucainp@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 19c20e5. Configure here.
| if not tokens: | ||
| raise ValueError("No token to revoke.") | ||
| headers = build_hf_headers() | ||
| headers.pop("authorization", None) |
There was a problem hiding this comment.
Revoke still resolves user token
Medium Severity
revoke_tokens builds headers with build_hf_headers() and only then drops authorization. That still runs full token resolution, so an unauthenticated revoke can fail or block: HF_OIDC_RESOURCE can raise OIDCError, an OAuth token can be refreshed, and Colab can prompt for HF_TOKEN. build_hf_headers(token=False) skips that lookup and still provides the user-agent.
Reviewed by Cursor Bugbot for commit 19c20e5. Configure here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


Fixes #5387. Server: huggingface-internal/moon-landing#19370, huggingface-internal/moon-landing#19443
Summary
hf auth revoke TOKEN...: revokes one or more tokens, e.g. leaked ones. No login needed: anyone holding the raw value can revoke it, and the token owner gets an email.revoke_tokens(tokens: list[str]): same in Python, exported at top level.{"accessKeyId", "secretAccessKey"}). Easy to add later if asked.No breaking change.
Example
Decisions taken
Authorizationheader: the server answers 403 when one is sent, so headers come frombuild_hf_headers()(user agent included) withauthorizationpopped. Nice side effect: the user's own token can never be revoked by mistake.Validation:
make styleandmake qualitypass,tests/test_auth.pypasses. Ran the command against hub-ci (human / json / agent output, plus 1500 tokens to exercise batching). New test hits hub-ci withHF_TOKENset and a fake token: it would 403 if the user's token leaked into the request (checked by sending the header by hand: 403). Not tested against production with a real token.Written by Hubert.py Bot via Launchpad, posted automatically
Note
Medium Risk
Touches credential lifecycle (new unauthenticated revoke path to Hub), but behavior is intentionally narrow and avoids using the caller's stored token on the request.
Overview
Adds
hf auth revoke TOKEN...and a top-level Pythonrevoke_tokensAPI so anyone who has a raw token value can request revocation without logging in; token owners are notified by email.Revocation hits
POST /api/credentials/revokewith headers frombuild_hf_headers(token=False)(noAuthorization), batches up to 1000 tokens per request, and surfaces CLI output as “revocation requested” because the Hub does not confirm whether each token existed.Docs are updated in the CLI guide, authentication package reference, and regenerated CLI reference;
revoke_tokensis exported fromhuggingface_hub.Reviewed by Cursor Bugbot for commit 77676b0. Bugbot is set up for automated code reviews on this repo. Configure here.
Written by Hubert.py Bot via Launchpad, posted automatically