Spaces:
Running
Running
Commit History
-
harden: strict Bearer-only, sampled deprecation, CORS fix, tests
Review follow-ups on 71fa426: 1. Bearer-only Authorization. The previous "tolerate a bare token for leniency" branch accepted any non-empty Authorization value — Basic dXNlcjpwdw==, Digest ..., a raw string — and forwarded it to validate_hf_token. Garbage values never validated but did pollute token_cache as cache misses, and there were no real clients sending a bare header. Strict Bearer now: scheme must be "bearer" (case-insensitive per RFC 7235), token must be non-empty after trimming; anything else returns 401. 2. 401 moved into the dependency. Previously every endpoint re-checked `if not token: raise HTTPException(401)` after _resolve_hf_token. That was copy-paste waiting to drift. Dependency raises itself now. 3. Stopped logging token prefix. "SSE connection request with token: {token[:20]}..." exposed ~half a 37-char hf_ token to logs — the whole point of this PR is to keep tokens out of logs. Log username after validate_hf_token instead. …f30c099