#3814·pangolin

Forward-auth redirects requests carrying Authorization: Bearer even with a valid session cookie, breaking any Bearer-token API behind an SSO-gated resource

Author: gchahcgCreated Sep 25, 2026Updated Sep 25, 2026

Describe the Bug

A request to an SSO-gated public resource that carries the backend application's own Authorization: Bearer <token> header gets redirected (302) to Pangolin's own login page instead of being passed through — even when the browser holds a valid Pangolin session cookie for that exact resource. The identical request without the Authorization header succeeds cleanly. Since real clients that need this (any Bearer-token API, e.g. Matrix, or the OpenAI-compatible-API case in Discussion #2590) issue these calls via fetch()/XHR, the browser can't follow Pangolin's cross-origin login redirect (no Access-Control-Allow-Origin), so the request fails outright with a CORS error in the console. This matches independent reports in Discussion #2590 and #1604 (Bearer headers apparently stripped/mishandled).

Environment

  • OS Type & Version: unknown (no shell access to the Pangolin host)
  • Pangolin Version: 1.17.0
  • Edition (Community or Enterprise): Community (self-hosted, no license)
  • Gerbil Version: unknown — no shell access to the Pangolin host to check
  • Traefik Version: unknown — no shell access to the Pangolin host to check
  • Newt Version: 1.16.0
  • Client Version: reproduced via curl (no browser involved) and independently via Chrome/Brave

To Reproduce

  1. Create a Pangolin public resource with auth.sso-enabled=true in front of a backend whose own API requires Authorization: Bearer <token>.
  2. Log into Pangolin's SSO for that resource in a browser, or grab the session cookie value.
  3. curl a path under that resource with the valid Pangolin session cookie and no Authorization header → succeeds, 200.
  4. Repeat the identical request, same cookie, adding -H 'Authorization: Bearer <any-token>' → gets redirected, 302 to https://<pangolin-domain>/auth/resource/<id>?redirect=..., instead of reaching the backend.
  5. Concrete case we hit: self-hosted Element Web + Matrix Synapse + Matrix Authentication Service behind a Pangolin SSO resource. Login itself worked fine (MAS pages are plain page loads with no Authorization header). But every authenticated Matrix API call after login (/sync, /capabilities, /pushrules, etc. — all carrying Authorization: Bearer <matrix-token>) hit the same redirect-then-CORS-failure, while an identical unauthenticated call to the same URL succeeded. We ruled out stale cookies, service worker interference, credentials mode, other headers, concurrency, and timing — presence of the Authorization header was the only variable that correlated with failure.

AI Disclosure

Investigated and this report drafted with Claude Code (Anthropic) during a live debugging session against our own self-hosted deployment; reviewed and filed by me.

Expected Behavior

If a valid Pangolin session cookie is present, the request should reach the backend regardless of whether it also carries the backend's own Authorization header — that header is orthogonal to Pangolin's own session and shouldn't be treated as "this request needs its own login." At minimum this should be documented, since the only current workaround is bypassing Pangolin auth entirely for the whole affected path (defeating the purpose of gating it), which is what our own resource's rules[] had to do.