Skip to content

Add the credential broker: workers reach Hugging Face without the real token; release 0.19.0 - #101

Merged
nielsrolf merged 1 commit into
mainfrom
hf-broker
Nov 20, 2026
Merged

nielsrolf merged 1 commit into
mainfrom
hf-broker

Conversation

@nielsrolf

Copy link
Copy Markdown
Collaborator

Third of four steps towards a worker environment without any organization credential (TODO.md). Details in docs/release-0.19.0.md. The design follows the credential broker in r-docs.

What changes

A worker's environment held the organization's real HF_TOKEN, readable by the code of any job. With a broker deployed, the worker gets instead:

HF_ENDPOINT = <broker url>/hf
HF_TOKEN    = hf_<the worker's own token>

ow broker (openweights/broker) receives every Hub request of the worker and:

  1. checks the worker token with the OpenWeights database (valid now, and a worker's token: a personal API key is refused); the answer is cached for 60 s;
  2. reads the organization's real HF_TOKEN from the secret store (cached 5 min, re-read after the Hub answers 401);
  3. forwards the request to huggingface.co with the real token.

Secret flow

Before After
Real HF_TOKEN secret store → manager → pod environment secret store → broker, in memory only
In the pod the real token hf_ + worker token: works only through the broker, dies with the worker
File bytes Hub → pod unchanged: signed storage URLs and Xet tokens, directly, not through the broker

The broker holds no database credential and no RunPod key; it needs read access to the organization secrets in the store. It never follows a redirect itself and rewrites only URLs that lead back to the Hub (Location, Link, LFS batch hrefs, x-xet-refresh-route).

When a worker is brokered

Only if the manager has OW_BROKER_URL, the organization's HF_TOKEN is in the secret store, and the worker has its own token. Otherwise nothing changes, so merging and releasing this is inert until OW_BROKER_URL is set, and self-managed clusters are unaffected.

What breaks once it is switched on

  • Worker images older than v0.15.2 call https://huggingface.co directly in places; those calls carry the stand-in and fail with 401.
  • Job code that hard-codes https://huggingface.co for an authenticated call, and git clone https://huggingface.co/... with the token.

What a release requires

Publish 0.19.0 and upgrade the manager (no effect yet); deploy the broker and test it from a job with the job's own worker token; then set OW_BROKER_URL on the manager. No migration, no worker image change.

Tests

tests/test_broker.py (21 tests): the proxy against a stand-in for the Hub, the token check against a stand-in for the database, and the manager's choice. Full suite: 267 passed. ow broker started locally: /healthz answers, a request without a token and one with an invalid worker token (checked against the real database) get 401.

Not verified: the broker against the real Hub with real client libraries (hf_xet / hf_transfer downloads, uploads, gated models). That needs a deployed broker and is the second step of the release.

🤖 Generated with Claude Code

…l token; release 0.19.0

`ow broker` is a small HTTP service that accepts a worker's own token as the
Hugging Face token, checks it with the database, reads the organization's
real HF_TOKEN from the secret store and forwards the request to the Hub.
File bytes do not pass through it. With OW_BROKER_URL set, the cluster
manager gives workers HF_ENDPOINT and a stand-in token instead of the real
one, for organizations whose token is in the secret store.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@nielsrolf
nielsrolf merged commit f06214d into main Nov 20, 2026
1 check passed
@nielsrolf
nielsrolf deleted the hf-broker branch November 20, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant