From 267526f8902a9af7863fc26a2b717bb541d776d3 Mon Sep 17 00:00:00 2001 From: Coko <91132775+coko7@users.noreply.github.com> Date: Fri, 13 Nov 2026 19:48:37 +0100 Subject: [PATCH] feat(auth): make Home page public, keep app pages behind SSO Watari can now be browsed without logging in: /home and /decrypt are public, and / redirects anonymous visitors to /home instead of the SSO login (signed-in users still get the dashboard there, so URLs are unchanged). Upload, paste, shorten, dashboard, admin and every /api/* route still require a session. Anonymous visitors get a reduced sidebar (Home, Decrypt) with a "Log in" button, and the Home page shows a "Log in with SSO" call to action. Public handlers take Option through a shared pages::public_layout helper, so signed-in users keep their full sidebar on those pages. Co-Authored-By: lazytrek <352825308+lazytrek@users.noreply.github.com> --- CLAUDE.md | 1 + src/routes/decrypt.rs | 9 +-------- src/routes/mod.rs | 14 +++++++++----- src/routes/pages.rs | 32 +++++++++++++++++++++++++++----- static/app.css | 15 +++++++++++++++ templates/base.html | 8 ++++++++ templates/home.html | 6 ++++++ 7 files changed, 67 insertions(+), 18 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index e1e5d50..dc6a9f5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -42,6 +42,7 @@ Watari is a Rust/Axum web GUI that sits in front of [rustypaste](https://github. - "Admin" (for gating `/admin/tokens`) is defined as *the resolved token binding has the `delete` permission* — the spec doesn't define it more precisely. - Encrypted URL-shortening: rustypaste's `url` field is a redirect target, so it can't hold ciphertext. When password-protection is on, `/api/shorten` uploads the encrypted URL as a `.enc` **file** instead of calling rustypaste's shorten endpoint (still logged with `kind: "url"` in `upload_log` for display purposes). - Text paste has no filename/extension field (§8): only the content matters. `/api/paste` ignores any `filename` field and sends rustypaste a generated unique `paste-<8 hex>.txt` (unique so deployments without `random_url` don't 409 on name collisions). The dashboard label (`display_name`) is the paste's first non-blank line, or rustypaste's resulting filename for encrypted pastes, whose content the server can't read. +- Public pages beyond `/decrypt` (§8): `/home` is public too, and `/` (the dashboard) redirects anonymous visitors to `/home` instead of `/auth/login`. Both live in `routes::public_router()` and take `Option`; anonymous visitors get a reduced sidebar (Home, Decrypt, "Log in"). Every other page and `/api/*` route still takes `UserSession` and requires SSO. - CSP has no nonce — every template ended up with zero inline `