Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ“ Updates header auth docs for server-side user check

Alicia Sykese38d7826dee4
diff --git a/docs/authentication/cloudflare-tunnel.md b/docs/authentication/cloudflare-tunnel.md
index 016f5e2c..400e14f2 100644
--- a/docs/authentication/cloudflare-tunnel.md
+++ b/docs/authentication/cloudflare-tunnel.md
@@ -231,7 +231,7 @@ Solution: In the Access application, add a Service Token, then create a Bypass p
When Dashy has `enableHeaderAuth: true`, [`services/app.js`](https://github.com/lissy93/dashy/blob/4.1.5/services/app.js) installs a small middleware in front of every API and asset route. The middleware does two things per request:
- Check `req.socket.remoteAddress` against `proxyWhitelist`. If the source IP isn't in the list, return 401 immediately. The header is never even inspected
-- Read the header named by `userHeader` (case-insensitive). If empty, return 401. Otherwise set `req.auth = { user: <email> }` and let the request through
+- Read the header named by `userHeader` (case-insensitive). If empty, return 401. If the email is in `users[]`, set `req.auth = { user: <email> }`. Otherwise the request continues as signed out
The IP check is the security boundary. Cloudflare adds `Cf-Access-Authenticated-User-Email` only after a successful Access policy match, and `cloudflared` is the only thing that can talk to Dashy (no exposed port). So the only way that header can be set on a request reaching Dashy is via the Cloudflare to cloudflared to dashy path, after a real Cloudflare Access authentication.
@@ -245,10 +245,13 @@ flowchart LR
IP -- No --> R401a[/401 Unauthorized<br/>not from trusted proxy/]:::err
IP -- Yes --> Hdr{User header<br/>present?}
Hdr -- No --> R401b[/401 Unauthorized<br/>missing user header/]:::err
- Hdr -- Yes --> Pass[/Set req.auth = email<br/>continue to route handler/]:::ok
+ Hdr -- Yes --> Listed{Email in<br/>users?}
+ Listed -- Yes --> Pass[/Set req.auth = email<br/>continue to route handler/]:::ok
+ Listed -- No --> Anon[/Continue signed out/]:::neutral
classDef ok fill:#bbf7d0,stroke:#16a34a,color:#14532d
classDef err fill:#fecaca,stroke:#dc2626,color:#7f1d1d
+ classDef neutral fill:#dbeafe,stroke:#2563eb,color:#1e3a8a
```
diff --git a/docs/authentication/header-auth.md b/docs/authentication/header-auth.md
index a6df4c7d..332a907f 100644
--- a/docs/authentication/header-auth.md
+++ b/docs/authentication/header-auth.md
@@ -191,7 +191,7 @@ The request reached Dashy from an IP that isn't in `proxyWhitelist`. The check i
#### 401 "Unauthorized - missing user header"
The request came from a trusted IP but had no username header. Either the proxy isn't forwarding it, or `userHeader` doesn't match the header name the proxy actually sends. Check the exact header in your proxy config.
-#### "User '...' from upstream proxy was not found in conf.yml"
+#### "Authentication failed (Header Auth)"
The proxy sent a username with no matching entry in `auth.users`. Add a user whose `user` matches it (case doesn't matter).
#### Logged in but can't save the config
diff --git a/docs/authentication/tailscale.md b/docs/authentication/tailscale.md
index 8420e340..a66de559 100644
--- a/docs/authentication/tailscale.md
+++ b/docs/authentication/tailscale.md
@@ -291,7 +291,7 @@ Solution: The server reads the auth config only at boot. Restart the Dashy conta
- `Tailscale-User-Name` - the display name
- `Tailscale-User-Profile-Pic` - a URL to their avatar
-Dashy's [header auth middleware](https://github.com/lissy93/dashy/blob/4.1.5/services/app.js) checks `req.socket.remoteAddress` against `proxyWhitelist` (which is `127.0.0.1` because of the shared namespace), reads `Tailscale-User-Login`, and sets `req.auth = { user: <email> }`. The SPA's `HeaderAuth.js` then fetches `/get-user`, matches the email to `users[]`, and sets the session cookie. Same code path as the Cloudflare Tunnel guide, just a different proxy and a different header name.
+Dashy's [header auth middleware](https://github.com/lissy93/dashy/blob/4.1.5/services/app.js) checks `req.socket.remoteAddress` against `proxyWhitelist` (which is `127.0.0.1` because of the shared namespace), reads `Tailscale-User-Login`, and sets `req.auth = { user: <email> }` if that email is in `users[]`. The SPA's `HeaderAuth.js` then fetches `/get-user`, matches the email to `users[]`, and sets the session cookie. Same code path as the Cloudflare Tunnel guide, just a different proxy and a different header name.
Identity flows from the user's tailnet membership all the way to Dashy's role-based UI without the user ever entering a password.
@@ -301,10 +301,13 @@ flowchart LR
IP -- No --> R401a[/401 Unauthorized<br/>not from trusted proxy/]:::err
IP -- Yes --> Hdr{Tailscale-User-Login<br/>present?}
Hdr -- No --> R401b[/401 Unauthorized<br/>missing user header/]:::err
- Hdr -- Yes --> Pass[/Set req.auth = email<br/>continue to route handler/]:::ok
+ Hdr -- Yes --> Listed{Email in<br/>users?}
+ Listed -- Yes --> Pass[/Set req.auth = email<br/>continue to route handler/]:::ok
+ Listed -- No --> Anon[/Continue signed out/]:::neutral
classDef ok fill:#bbf7d0,stroke:#16a34a,color:#14532d
classDef err fill:#fecaca,stroke:#dc2626,color:#7f1d1d
+ classDef neutral fill:#dbeafe,stroke:#2563eb,color:#1e3a8a
```
<details>