Add public access mode (public=1) to forward auth
/auth/api/forward?public=1 passes requests through with a Remote-Public header (anonymous/forbidden/authenticated) instead of 401/403, so routes can allow anonymous visitors while still identifying logged-in users. Reauth (max_age) still requires the auth flow. Documented in Headers.md, api/forward.md, Integration.md and all proxy guides.
This commit is contained in:
@@ -85,6 +85,7 @@ authResponseHeaders:
|
||||
- Remote-Role-Name
|
||||
- Remote-Session-Expires
|
||||
- Remote-Credential
|
||||
- Remote-Public
|
||||
```
|
||||
|
||||
## Proxying `/auth/` to Paskia
|
||||
@@ -119,6 +120,17 @@ labels:
|
||||
- "traefik.http.middlewares.paskia-auth.forwardauth.authRequestHeaders=Host,Cookie,Accept,X-Forwarded-Method,X-Forwarded-Uri"
|
||||
```
|
||||
|
||||
## Public access
|
||||
|
||||
For routes where anonymous visitors are allowed but logged-in users should still be identified, add `public=1` to the middleware `address`:
|
||||
|
||||
```yaml
|
||||
address: "http://localhost:4401/auth/api/forward?public=1"
|
||||
address: "http://localhost:4401/auth/api/forward?public=1&perm=myapp:reports"
|
||||
```
|
||||
|
||||
The auth check then always returns 204 (except reauth with `max_age`, which still returns the 401 auth flow), and the `Remote-Public` header — copied by `authResponseHeadersRegex: "^Remote-"` — marks each request as `anonymous`, `forbidden` or `authenticated`. The backend always runs and must check `Remote-Public` before treating the request as authorized. See [public access](../api/forward.md#public-access) and [trusted headers](../Headers.md#public-access).
|
||||
|
||||
## Notes
|
||||
|
||||
- By default ForwardAuth sends a request without the original body. If you need to forward the body for logging/validation, set `forwardBody: true` and a sensible `maxBodySize`, but for Paskia this is not required.
|
||||
|
||||
Reference in New Issue
Block a user