Skip to content

fix(frontend): forward X-Pangolin-Token zum Backend (Browser-User 503-Fix)#130

Merged
strausmann merged 1 commit into
mainfrom
fix/forward-pangolin-token
Jun 23, 2026
Merged

fix(frontend): forward X-Pangolin-Token zum Backend (Browser-User 503-Fix)#130
strausmann merged 1 commit into
mainfrom
fix/forward-pangolin-token

Conversation

@strausmann

Copy link
Copy Markdown
Owner

Bug

Browser-User ohne aktive Pangolin SSO-Session sahen 503 auf jeder UI-Route die Backend-Daten lädt — / (Dashboard), /printers, /jobs, /templates, /admin/*. Nur /healthz funktionierte (kein Backend-Call).

Root Cause

Pangolin Resource labels.strausmann.cloud (#123) ist mit Header-Auth konfiguriert die X-Pangolin-Token: <trust-token> als Custom Upstream-Header an Frontend injectet. Das Backend akzeptiert diesen Token über sso_trust_header als SSO-equivalentes Signal.

Aber: WithAuthFrom in frontend/internal/api/client.go:130 forwarded nur diese Headers ans Backend:

  • X-Label-Hub-Key
  • X-Pangolin-User
  • Authorization
  • X-Pangolin-Token fehlt

Konsequenz: Backend bekommt keinen Auth-Header → 401 → Frontend wirft 503.

Live-Beweis (vor Fix)

Request Status
Frontend GET /healthz 200 OK ✅
Frontend GET / (Browser) 503 ❌
Frontend GET / mit X-Pangolin-User: strausmann 200 OK ✅
Frontend GET / mit X-Pangolin-Token: <token> 503 ❌
Backend GET /api/printers mit X-Pangolin-User 200 OK + JSON ✅

Fix

1-Zeilen-Change: X-Pangolin-Token zur Forwarding-Liste in WithAuthFrom hinzugefügt + Docstring präzisiert.

Test

Neuer Test TestWithAuthFromForwardsPangolinTokenHeader — RED vor Fix, GREEN danach.

=== RUN   TestWithAuthFromForwardsPangolinTokenHeader
--- PASS: TestWithAuthFromForwardsPangolinTokenHeader (0.00s)

Volle Suite + race: alle 4 Packages grün.

Test Plan

  • CI grün (test + lint + privacy + oapi-codegen-drift)
  • Nach Merge: Image-Build + Stack-Update auf hhdocker03
  • Browser-Test: https://labels.strausmann.cloud/ liefert Dashboard

…-Fix)

Pangolin Resources koennen via Header-Auth einen statischen Trust-Token als
Custom Upstream-Header injecten (X-Pangolin-Token). Das Backend akzeptiert
ihn ueber den sso_trust_header Mechanismus als SSO-equivalentes Signal.

Bisher hat WithAuthFrom in client.go diesen Header NICHT an Backend-Calls
weitergereicht, sondern nur X-Pangolin-User, X-Label-Hub-Key und Authorization.

Konsequenz: Browser-User ohne aktive Pangolin-SSO-Session konnten KEINE
UI-Route nutzen die Backend-Daten holt - Dashboard (/), /printers, /jobs,
/templates, /admin/* gaben alle 503 zurueck. Nur /healthz funktionierte
weil der nicht zum Backend ruft.

Fix: X-Pangolin-Token zur Forwarding-Liste hinzugefuegt.

Test: TestWithAuthFromForwardsPangolinTokenHeader prueft via httptest-Backend
dass der Header beim Backend ankommt. Test war RED vor Fix, GREEN danach.

Live-Verifikation (vor Fix):
- /healthz: 200 OK
- /: 503 (Frontend forwarded X-Pangolin-Token nicht)
- Direkter Backend-Call mit X-Pangolin-User: 200 OK + JSON
- Direkter Frontend-Call mit X-Pangolin-User: 200 OK + UI

Refs Issue-Tracker (kein eigenes Issue, akut entdeckt 2026-06-23)
Copilot AI review requested due to automatic review settings June 23, 2026 10:32

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.

@strausmann strausmann merged commit 5fb2038 into main Jun 23, 2026
13 checks passed
@strausmann strausmann deleted the fix/forward-pangolin-token branch June 23, 2026 10:33
@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.75%. Comparing base (41bef28) to head (1168e30).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #130      +/-   ##
==========================================
+ Coverage   87.71%   87.75%   +0.04%     
==========================================
  Files          94       94              
  Lines        4574     4574              
  Branches      400      400              
==========================================
+ Hits         4012     4014       +2     
+ Misses        459      457       -2     
  Partials      103      103              
Components Coverage Δ
Printer Backends (transport) 85.71% <ø> (ø)
Printer Models (drivers) 88.20% <ø> (ø)
Services 91.30% <ø> (ø)
REST API 83.31% <ø> (ø)
Pydantic Schemas 100.00% <ø> (ø)
Integration Plugins 100.00% <ø> (ø)
see 1 file with indirect coverage changes
Flag Coverage Δ
backend 87.75% <ø> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41bef28...1168e30. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Dieser Pull Request behebt einen 503-Fehler, der auftrat, wenn Browser-Benutzer ohne aktive Pangolin SSO-Session auf Backend-Daten zugreifen wollten. Durch das explizite Weiterleiten des 'X-Pangolin-Token'-Headers an das Backend wird sichergestellt, dass die Authentifizierung über den 'sso_trust_header'-Mechanismus korrekt funktioniert.

Highlights

  • Header Forwarding Fix: Added 'X-Pangolin-Token' to the list of headers forwarded by the frontend to the backend in 'WithAuthFrom', resolving 503 errors for users without an active SSO session.
  • Documentation Update: Updated the docstrings in 'client.go' to clarify the purpose of the 'X-Pangolin-Token' and its role as a trust-token for backend authentication.
  • Regression Testing: Added a new test case 'TestWithAuthFromForwardsPangolinTokenHeader' to ensure the token is correctly propagated to the backend.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds support for forwarding the X-Pangolin-Token header in WithAuthFrom to allow browser users without an active SSO session to reach the UI. A corresponding unit test has been added to verify this behavior. I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

strausmann added a commit that referenced this pull request Jun 23, 2026
…-Header) (#132)

PR #130 hatte X-Pangolin-Token zur Forwarding-Liste hinzugefuegt um Browser-
User ohne SSO-Session den Trust-Pfad zu ermoeglichen. Damit war der externe
Pangolin-Path mit Header-Auth Bypass abgedeckt — aber Browser-User MIT
aktiver Pangolin-SSO-Session bekommen weiterhin 503.

Grund: Pangolin Standard-SSO setzt Remote-User als User-Identity-Header
(sso_user_header). Das Backend erlaubt den SSO-Trust-Pfad nur wenn BEIDE
Header gesetzt sind — X-Pangolin-Token (Trust-Signal) UND Remote-User
(Identitaet). Forwarding nur eines davon → 401 → Frontend wirft 503.

Fix: Remote-User zur Forwarding-Liste in WithAuthFrom hinzugefuegt.

Test: TestWithAuthFromForwardsRemoteUserHeader prueft via httptest-Backend
dass Remote-User beim Backend ankommt. Race-Detector grün, alle 4 Header-
Forwarding-Tests passen.

Refs: PR #130 (X-Pangolin-Token), Issue #131 (vom ops-agent geoeffnet als
Followup zum unvollstaendigen PR #130)
strausmann added a commit that referenced this pull request Jun 23, 2026
…133)

In Phase 7c hatten wir SSO und Bypass auf "read scope only" beschraenkt,
um Leak-Defense fuer den claude-automation Bypass zu haben. Konsequenz:
das HTML-Admin-UI ist via SSO nicht nutzbar, weil Admin-Routen "admin"
Scope verlangen und SSO nur "read" liefert.

Diese Aenderung trusted SSO und Bypass fuer den jeweils verlangten Scope.
Die Defense-in-Depth ist:
- SSO: Pangolin Resource Policy gated, wer ueberhaupt auf labels.* kommt.
- Bypass: Secret liegt in Vault, rotiert via Vault bei Verdacht auf Leak.
  Production-Integrationen (Hangar, Snipe-IT, Grocy) sollen API-Keys mit
  spezifischem Scope nutzen, nicht den Bypass.

Multi-Scope-System auf X-Label-Hub-Key API-Keys bleibt unveraendert:
jeder Key hat weiterhin read/print/admin Scope-Liste und per-printer ACL.

Tests:
- test_pangolin_sso_blocked_on_print_scope ersetzt durch
  test_pangolin_sso_allows_print_and_admin_scopes (parametrisiert)
- 75/75 auth + admin tests gruen, inkl. Race-Detector

ADR 0014 dokumentiert die Entscheidung inkl. der zwei verworfenen Optionen
(SSO-Admin-User-Liste in ENV; Scope-System komplett entfernen).

Refs: Issue #78 (Phase 7c original), PR #130/#132 (Header-Forwarding),
ADR 0014
strausmann added a commit that referenced this pull request Jun 23, 2026
…min-Routes) (#134)

PR #130/#132 hatten WithAuthFrom im oapi-Client um X-Pangolin-Token und
Remote-User ergänzt. forwardAuth in admin_api_keys.go ist eine zweite,
parallele Implementierung für die Admin-Routes (/admin/printers,
/admin/api-keys) die raw http.DefaultClient verwendet — die Header-Liste
dort wurde nicht mitgezogen.

Konsequenz: SSO-User konnten Read-Routes nutzen, alle Admin-Routes gaben
weiterhin 503 weil das Backend mit "missing_credentials" 401 zurück lieferte.

Fix: dieselbe Header-Liste in forwardAuth. Plus Regression-Test
TestListPrintersPage_ForwardetPangolinSSOHeaders der httptest-Server-seitig
beide Header verifiziert.

Race-Detector grün, alle 4 Frontend-Packages grün.

Refs PR #130 (X-Pangolin-Token), PR #132 (Remote-User), PR #133 (ADR 0014
Backend-Seite)
github-actions Bot pushed a commit that referenced this pull request Jun 24, 2026
## 0.11.0 (2026-06-24)

* feat(auth): Pangolin-SSO + Bypass für alle Scopes trusted (ADR 0014) (#133) ([4fe1a91](4fe1a91)), closes [#133](#133) [#78](#78) [130/#132](#132)
* feat(nav): "Drucker" Link für Admin-Drucker-Verwaltung + getrennte ActiveNav-Werte (#135) ([1e982b0](1e982b0)), closes [#135](#135) [#104](#104) [#104](#104) [#104](#104)
* fix(frontend): forward Remote-User zum Backend (Pangolin SSO-Standard-Header) (#132) ([38c0cc3](38c0cc3)), closes [#132](#132) [#130](#130) [#130](#130) [#131](#131) [#130](#130)
* fix(frontend): forward X-Pangolin-Token zum Backend (Browser-User 503-Fix) (#130) ([5fb2038](5fb2038)), closes [#130](#130)
* fix(frontend): forwardAuth ergänzt X-Pangolin-Token + Remote-User (Admin-Routes) (#134) ([af9ee28](af9ee28)), closes [#134](#134) [130/#132](#132) [#130](#130) [#132](#132) [#133](#133)
* chore(deps): bump the go-minor-and-patch group across 1 directory with 2 updates (#128) ([a72dd90](a72dd90)), closes [#128](#128)
* ci(deps): bump lewagon/wait-on-check-action in the actions-all group (#127) ([e4139ab](e4139ab)), closes [#127](#127)
* docs(api): printers.yaml weg, Drucker in DB + /admin/printers Admin-UI (#124) [DRAFT] (#125) ([41bef28](41bef28)), closes [#124](#124) [#125](#125) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#3099](https://github.com/strausmann/label-printer-hub/issues/3099) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#3099](https://github.com/strausmann/label-printer-hub/issues/3099) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [#124](#124) [compose-passthrou#Pflicht](https://github.com/compose-passthrou/issues/Pflicht)

[skip ci]
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.

2 participants