- Add isSafeRedirectUrl utility to prevent open-redirect vulnerabilities. - Update GET /logout to handle ?redirect=, clear cookies safely, and log audit events. - Create AppLaunchpadPage.tsx using pure Hono SSR JSX for application visibility and SSO launching. - Update GET /dashboard and AuthenticatedLayout.tsx to mount the Launchpad as the default authenticated view with Zero-Knowledge querying. - Add HYBRID_INGRESS_PLAYBOOK.md documentation for Traefik ForwardAuth routing. - Implement exhaustive unit tests in server/main.test.ts for redirect preservation, anomaly logging, and Zero-Knowledge role filtering. Co-authored-by: mrteye <1945243+mrteye@users.noreply.github.com>
3.6 KiB
Hybrid Ingress Routing Playbook
This playbook outlines the recommended architecture for deploying consumer applications that require a combination of public-facing endpoints (like splash pages or APIs) and private, authenticated endpoints (like control panels or user dashboards), while integrating with Auth-Yes.
Context
Many applications are not entirely public or entirely private. They utilize a hybrid approach where certain paths are accessible to anyone, while others are strictly protected. To achieve Zero-Trust security and streamline authentication, we use a dual-routing pattern leveraging Traefik and application-level SSR hydration.
The Dual-Routing Pattern
The dual-routing pattern separates responsibilities between the edge proxy (Traefik) and the application itself.
1. Edge Proxy Authentication (Traefik ForwardAuth)
For paths that must be strictly private and require a valid user session (or
machine identity), we use Traefik's ForwardAuth middleware. This delegates the
authentication decision to the Auth-Yes edge node.
Protected Paths:
/control-panel/*/dashboard/*/ws/*(WebSockets)/api/private/*
How it works:
- A request arrives at Traefik for a protected path (e.g.,
/control-panel/settings). - Traefik intercepts the request and sends a sub-request to the Auth-Yes
ForwardAuthendpoint (/api/forward-auth). - Auth-Yes validates the
session_idcookie or RFC 9421 HTTP Message Signature. - If valid, Auth-Yes returns HTTP 200 OK, injecting context headers like
X-Forwarded-UserandX-Forwarded-Scopes. - Traefik allows the original request to proceed to the application.
- If invalid, Auth-Yes intercepts with a redirect (for browsers) or 403 Forbidden (for APIs/daemons).
Example Traefik Configuration (Labels):
labels:
- "traefik.http.routers.myapp-private.rule=Host(`myapp.atyg.org`) && (PathPrefix(`/control-panel`) || PathPrefix(`/api/private`))"
- "traefik.http.routers.myapp-private.middlewares=auth-yes-forwardauth"
- "traefik.http.middlewares.auth-yes-forwardauth.forwardauth.address=http://auth-api:8000/api/forward-auth"
- "traefik.http.middlewares.auth-yes-forwardauth.forwardauth.trustForwardHeader=true"
- "traefik.http.middlewares.auth-yes-forwardauth.forwardauth.authResponseHeaders=X-Forwarded-User,X-Forwarded-Scopes"
2. Application-Level Authentication (SSR Hydration)
For paths that are public or require custom application logic to handle unauthenticated users gracefully, the application itself handles the authentication state via SDKs or custom logic.
Public/Hybrid Paths:
/(Splash page, landing page)/about/api/public/*/.well-known/*
How it works:
- A request arrives at Traefik for a public path (e.g.,
/). - Traefik routes the request directly to the application (no
ForwardAuthmiddleware applied). - The application receives the request. It can check for the presence of a
session_idcookie if it wants to render personalized content (e.g., replacing "Login" with "Go to Control Panel"). - If no session exists, it renders the public splash page.
Example Traefik Configuration (Labels):
labels:
- "traefik.http.routers.myapp-public.rule=Host(`myapp.atyg.org`)"
# No ForwardAuth middleware here
Summary
By combining Traefik ForwardAuth for strict edge-level protection of critical
paths with application-level handling for public paths, we achieve a robust,
flexible, and secure ingress architecture. This ensures that sensitive routes
are never accidentally exposed, while public routes remain performant and
accessible.