Skip to content

Forward Authorization header to known HuggingFace CDN hosts on redirect - #133

Open
mmustafasenoglu wants to merge 1 commit into
drumih:mainfrom
mmustafasenoglu:fix/hf-403-auth-on-cdn-redirect
Open

Forward Authorization header to known HuggingFace CDN hosts on redirect#133
mmustafasenoglu wants to merge 1 commit into
drumih:mainfrom
mmustafasenoglu:fix/hf-403-auth-on-cdn-redirect

Conversation

@mmustafasenoglu

Copy link
Copy Markdown

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 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, 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

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
Copilot AI lite review requested due to automatic review settings August 13, 2026 19:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

rexmhall09 referenced this pull request in rexmhall09/TUFF Aug 16, 2026
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.
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.

[Bug]: HTTP 403 while trying to download the model

2 participants