fix(sites): support CORS preflight on booking intake and protect admin routes
- Add OPTIONS preflight support to public booking intake and services routers - Scope public services routing to safe read methods (GET, HEAD, OPTIONS) - Remove /api/packages from public router to preserve Authelia headers for admin dashboard - Remove non-existent /api/payments/methods router rule - Reconcile ARCHITECTURE.md, README.md, and ADR-0001 to reflect updated routing rules
This commit is contained in:
1 parent
60551802ac
commit
8b53fca7b7
4 files changed
+7
-7
No files matched your search
+2
-2
@@ -32,7 +32,7 @@ flowchart TD
|
|||||||
TursoCloud[("Turso Cloud libSQL<br/>(Optional Remote DB)")]
|
TursoCloud[("Turso Cloud libSQL<br/>(Optional Remote DB)")]
|
||||||
end
|
end
|
||||||
|
|
||||||
Visitor -->|"GET /api/{health,availability,services,packages,payments/methods}<br/>POST /api/bookings"| Traefik
|
Visitor -->|"GET /api/{health,availability,services}<br/>POST /api/bookings (with CORS OPTIONS)"| Traefik
|
||||||
Operator -->|"Browser HTTPS"| Traefik
|
Operator -->|"Browser HTTPS"| Traefik
|
||||||
|
|
||||||
Traefik -->|"Check Session & Role Headers"| Authelia
|
Traefik -->|"Check Session & Role Headers"| Authelia
|
||||||
@@ -114,7 +114,7 @@ sequenceDiagram
|
|||||||
### Traefik Routers Specification
|
### Traefik Routers Specification
|
||||||
|
|
||||||
1. **`armonia-api-public` (Priority 30, Public)**:
|
1. **`armonia-api-public` (Priority 30, Public)**:
|
||||||
- **Rule**: `Host(SERVICE_DOMAIN) && (PathPrefix('/api/health') || PathPrefix('/api/availability') || PathPrefix('/api/services') || PathPrefix('/api/packages') || PathPrefix('/api/payments/methods') || (Method('POST') && PathPrefix('/api/bookings')))`
|
- **Rule**: `Host(SERVICE_DOMAIN) && (PathPrefix('/api/health') || PathPrefix('/api/availability') || (Method('GET', 'HEAD', 'OPTIONS') && PathPrefix('/api/services')) || (Method('POST', 'OPTIONS') && PathPrefix('/api/bookings')))`
|
||||||
- **Middleware**: `armonia-api-strip@docker` (strips `/api`).
|
- **Middleware**: `armonia-api-strip@docker` (strips `/api`).
|
||||||
- **Target**: `armonia-api:8000`.
|
- **Target**: `armonia-api:8000`.
|
||||||
- **Authentication**: None (Bypasses Authelia).
|
- **Authentication**: None (Bypasses Authelia).
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ In the platform's multi-environment topology, this deployment serves as the **au
|
|||||||
|
|
||||||
| Route Pattern | Method | Target Service | Access Level | Description |
|
| Route Pattern | Method | Target Service | Access Level | Description |
|
||||||
| :--- | :--- | :--- | :--- | :--- |
|
| :--- | :--- | :--- | :--- | :--- |
|
||||||
| `/api/health`, `/api/availability`, `/api/services`, `/api/packages`, `/api/payments/methods` | `GET` | `armonia-api:8000` | **Public** | Public service catalog, business hours, and payment instructions. |
|
| `/api/health`, `/api/availability`, `/api/services` | `GET`, `OPTIONS` | `armonia-api:8000` | **Public** | Public service catalog and real-time appointment availability. |
|
||||||
| `/api/bookings` | `POST` | `armonia-api:8000` | **Public** | Client self-service appointment reservation intake. |
|
| `/api/bookings` | `POST`, `OPTIONS` | `armonia-api:8000` | **Public** | Client self-service appointment reservation intake with CORS preflight support. |
|
||||||
| `/api/*` | `ANY` | `armonia-api:8000` | **Protected** (Authelia) | Administrative operations: 48h follow-up queue, client CRM, booking lifecycle, and session notes. |
|
| `/api/*` | `ANY` | `armonia-api:8000` | **Protected** (Authelia) | Administrative operations: 48h follow-up queue, client CRM, booking lifecycle, therapy packages, and session notes. |
|
||||||
| `/*` | `GET` | `armonia-dashboard:80` | **Protected** (Authelia) | Mobile-first administrative Vite SPA served via Nginx. |
|
| `/*` | `GET` | `armonia-dashboard:80` | **Protected** (Authelia) | Mobile-first administrative Vite SPA served via Nginx. |
|
||||||
|
|
||||||
> Detailed routing diagrams, middleware execution order, and security boundaries are documented in [**`ARCHITECTURE.md`**](./ARCHITECTURE.md).
|
> Detailed routing diagrams, middleware execution order, and security boundaries are documented in [**`ARCHITECTURE.md`**](./ARCHITECTURE.md).
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ services:
|
|||||||
- "traefik.http.middlewares.armonia-api-strip.stripprefix.prefixes=/api"
|
- "traefik.http.middlewares.armonia-api-strip.stripprefix.prefixes=/api"
|
||||||
|
|
||||||
# 1. Public API & Health Router (Priority 30 — bypasses Authelia forward-auth)
|
# 1. Public API & Health Router (Priority 30 — bypasses Authelia forward-auth)
|
||||||
- "traefik.http.routers.armonia-api-public.rule=Host(`${SERVICE_DOMAIN:-armonia.roadtotech.me}`) && (PathPrefix(`/api/health`) || PathPrefix(`/api/availability`) || PathPrefix(`/api/services`) || PathPrefix(`/api/packages`) || PathPrefix(`/api/payments/methods`) || (Method(`POST`) && PathPrefix(`/api/bookings`)))"
|
- "traefik.http.routers.armonia-api-public.rule=Host(`${SERVICE_DOMAIN:-armonia.roadtotech.me}`) && (PathPrefix(`/api/health`) || PathPrefix(`/api/availability`) || (Method(`GET`, `HEAD`, `OPTIONS`) && PathPrefix(`/api/services`)) || (Method(`POST`, `OPTIONS`) && PathPrefix(`/api/bookings`)))"
|
||||||
- "traefik.http.routers.armonia-api-public.entrypoints=websecure"
|
- "traefik.http.routers.armonia-api-public.entrypoints=websecure"
|
||||||
- "traefik.http.routers.armonia-api-public.tls=true"
|
- "traefik.http.routers.armonia-api-public.tls=true"
|
||||||
- "traefik.http.routers.armonia-api-public.priority=30"
|
- "traefik.http.routers.armonia-api-public.priority=30"
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ Chosen option: **Containerized Homelab Sites orchestration using Traefik dual-pr
|
|||||||
|
|
||||||
Specifically:
|
Specifically:
|
||||||
1. **Traefik Dual-Router Architecture**:
|
1. **Traefik Dual-Router Architecture**:
|
||||||
- Router 1 (`Priority 30`): Whitelists public intake endpoints (`/api/health`, `/api/availability`, `/api/services`, `/api/packages`, `/api/payments/methods`, and `POST /api/bookings`) with prefix stripping (`/api`), bypassing Authelia authentication.
|
- Router 1 (`Priority 30`): Whitelists public intake endpoints (`/api/health`, `/api/availability`, safe read methods for `/api/services`, and `POST /api/bookings` with CORS preflight `OPTIONS`) with prefix stripping (`/api`), bypassing Authelia authentication. Sensitive operations (`/api/packages`, `POST /api/services`, administrative booking and CRM actions) fall through to Router 2.
|
||||||
- Router 2 (`Priority 20`): Protects administrative `/api` endpoints, enforcing Authelia ForwardAuth and forwarding authenticated identity headers (`Remote-Email`, `Remote-Groups`, `Remote-Name`, `Remote-User`).
|
- Router 2 (`Priority 20`): Protects administrative `/api` endpoints, enforcing Authelia ForwardAuth and forwarding authenticated identity headers (`Remote-Email`, `Remote-Groups`, `Remote-Name`, `Remote-User`).
|
||||||
- Router 3 (`Priority 10`): Serves the dashboard Vite SPA behind Authelia ForwardAuth.
|
- Router 3 (`Priority 10`): Serves the dashboard Vite SPA behind Authelia ForwardAuth.
|
||||||
2. **Decoupled Identity via `AUTH_PROVIDER=proxy_headers`**:
|
2. **Decoupled Identity via `AUTH_PROVIDER=proxy_headers`**:
|
||||||
|
|||||||
Reference in new issue
Block a user