Forward Authorization header to known HuggingFace CDN hosts on redirect - #133
Open
mmustafasenoglu wants to merge 1 commit into
Open
Forward Authorization header to known HuggingFace CDN hosts on redirect#133mmustafasenoglu wants to merge 1 commit into
mmustafasenoglu wants to merge 1 commit into
Conversation
The installer drops the Bearer token when HuggingFace redirects LFS downloads from huggingface.co to cdn-lfs.huggingface.co. The cross-host redirect policies unconditionally strip Authorization for any host change, which causes 403 Forbidden on gated repositories. Add an allowedForwardHosts set to both RemoteRedirectPolicy and RemoteMetadataRedirectPolicy. Redirects to hosts in this set (currently cdn-lfs.huggingface.co) now keep the original Authorization header. Redirects to unknown hosts continue to be stripped. Two new tests verify that authorization is forwarded to the known CDN host and stripped for unrecognized hosts. Closes drumih#109
rexmhall09
referenced
this pull request
in rexmhall09/TUFF
Aug 16, 2026
RemoteRedirectPolicy.request returns a URLRequest, not an optional; the merged tests were written against the older optional return. Assertions are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The installer drops the Bearer token when HuggingFace redirects LFS downloads from huggingface.co to cdn-lfs.huggingface.co. The cross-host redirect policies unconditionally strip Authorization for any host change, which causes 403 Forbidden on gated repositories.
This change adds an
allowedForwardHostsset to bothRemoteRedirectPolicyandRemoteMetadataRedirectPolicy. Redirects to hosts in this set (currentlycdn-lfs.huggingface.co) now keep the original Authorization header. Redirects to unknown hosts continue to be stripped, preserving the existing security posture.Two new tests verify that authorization is forwarded to the known CDN host and stripped for unrecognized hosts.
Closes #109