From 3052253d33df885b67268ad46c538b680ef12ded Mon Sep 17 00:00:00 2001 From: piquel Date: Thu, 29 Oct 2026 00:21:22 +0100 Subject: [PATCH 1/3] fix(auth): show email addresses again, blurred until clicked Cloudflare's Email Address Obfuscation replaced addresses on auth's pages with "[email protected]" links whose decoding script the Content-Security-Policy blocks. Every Cache-Control value now carries no-transform, so the edge never rewrites a body. Addresses on the settings and admin pages are blurred until clicked, so a shared screen does not show them, without a script. Co-Authored-By: Claude Opus 5.5 --- apps/auth-service/src/security/mod.rs | 15 +++++++---- apps/auth-service/src/security/tests.rs | 17 +++++++++--- apps/auth-service/src/web/developers/tests.rs | 5 +++- crates/ui/assets/style.css | 26 +++++++++++++++++++ crates/ui/src/admin/users.rs | 7 +++-- crates/ui/src/layout.rs | 13 ++++++++++ crates/ui/src/settings/emails.rs | 4 +-- infra/README.md | 10 ++++--- tests/browser/developers.spec.ts | 2 +- 9 files changed, 80 insertions(+), 19 deletions(-) diff --git a/apps/auth-service/src/security/mod.rs b/apps/auth-service/src/security/mod.rs index ed94318cb..39b9687d1 100644 --- a/apps/auth-service/src/security/mod.rs +++ b/apps/auth-service/src/security/mod.rs @@ -1000,15 +1000,20 @@ impl CacheClass { } } - /// The `Cache-Control` value of this class. + /// The `Cache-Control` value of this class. Every value forbids transforming the + /// body: Cloudflare's edge would otherwise rewrite pages, hiding email addresses + /// behind a decoding script the Content-Security-Policy blocks. fn cache_control(self) -> HeaderValue { HeaderValue::from_static(match self { - Self::NoStore => "no-store", - Self::Immutable => "public, max-age=31536000, immutable", + Self::NoStore => "no-store, no-transform", + Self::Immutable => "public, max-age=31536000, immutable, no-transform", Self::Public { max_age } => { // Digits and fixed text always form a valid header value. - return HeaderValue::try_from(format!("public, max-age={}", max_age.as_secs())) - .unwrap_or(HeaderValue::from_static("no-store")); + return HeaderValue::try_from(format!( + "public, max-age={}, no-transform", + max_age.as_secs() + )) + .unwrap_or(HeaderValue::from_static("no-store, no-transform")); } }) } diff --git a/apps/auth-service/src/security/tests.rs b/apps/auth-service/src/security/tests.rs index d30477719..44c1a07a5 100644 --- a/apps/auth-service/src/security/tests.rs +++ b/apps/auth-service/src/security/tests.rs @@ -179,7 +179,10 @@ impl SecurityFixture { .get(header::ACCESS_CONTROL_ALLOW_ORIGIN) .is_none() ); - assert_eq!(response.headers()[header::CACHE_CONTROL], "no-store"); + assert_eq!( + response.headers()[header::CACHE_CONTROL], + "no-store, no-transform" + ); assert_eq!( response.headers()[header::X_CONTENT_TYPE_OPTIONS], "nosniff" @@ -977,12 +980,15 @@ fn client() -> CorsGrant { #[test] fn cached_responses_carry_their_class() { for (class, cache_control) in [ - (CacheClass::Immutable, "public, max-age=31536000, immutable"), + ( + CacheClass::Immutable, + "public, max-age=31536000, immutable, no-transform", + ), ( CacheClass::Public { max_age: std::time::Duration::from_secs(3600), }, - "public, max-age=3600", + "public, max-age=3600, no-transform", ), ] { let response = decorated(Cached(class, StatusCode::OK), None); @@ -1008,7 +1014,10 @@ fn unclassed_errors_and_cookie_responses_are_not_stored() { decorated(Cached(class, StatusCode::TOO_MANY_REQUESTS), None), decorated([(header::CACHE_CONTROL, "public, max-age=60")], None), ] { - assert_eq!(response.headers()[header::CACHE_CONTROL], "no-store"); + assert_eq!( + response.headers()[header::CACHE_CONTROL], + "no-store, no-transform" + ); } } diff --git a/apps/auth-service/src/web/developers/tests.rs b/apps/auth-service/src/web/developers/tests.rs index b8e9f3b7a..add3f39d1 100644 --- a/apps/auth-service/src/web/developers/tests.rs +++ b/apps/auth-service/src/web/developers/tests.rs @@ -60,7 +60,10 @@ async fn assert_missing(response: Response) { /// redirect, no cookie, and no copy in any cache. fn assert_unstored(response: &Response) { assert_eq!(response.status(), StatusCode::OK); - assert_eq!(response.headers()[header::CACHE_CONTROL], "no-store"); + assert_eq!( + response.headers()[header::CACHE_CONTROL], + "no-store, no-transform" + ); assert!(response.headers().get(header::LOCATION).is_none()); assert!(response.headers().get(header::SET_COOKIE).is_none()); } diff --git a/crates/ui/assets/style.css b/crates/ui/assets/style.css index b3c3cf843..2b8960bc5 100644 --- a/crates/ui/assets/style.css +++ b/crates/ui/assets/style.css @@ -445,6 +445,32 @@ tbody tr:last-child td { margin-top: 2rem; } } +/* An email address, blurred until its visually hidden checkbox is checked. */ +.private-address { + display: inline; + position: relative; + font: inherit; + cursor: pointer; +} +.private-address input { + position: absolute; + width: 1px; + height: 1px; + min-height: 0; + padding: 0; + opacity: 0; +} +.private-address span { + filter: blur(5px); + transition: filter 0.15s; +} +.private-address input:checked + span { + filter: none; +} +.private-address:has(input:focus-visible) span { + outline: 3px solid #ab7900; + outline-offset: 4px; +} /* Author display rules would otherwise show what a page or its script hides. */ [hidden] { display: none !important; diff --git a/crates/ui/src/admin/users.rs b/crates/ui/src/admin/users.rs index a01ed30a5..897a9d45a 100644 --- a/crates/ui/src/admin/users.rs +++ b/crates/ui/src/admin/users.rs @@ -1,6 +1,7 @@ //! Account search and one account's page. use super::{EventRow, account_status, event_rows, heading, moment, refused_action}; +use crate::layout::private_address; use piquel_common::{ AccountStatus, AuthenticationMethod, admin::{Session, User, UserDetail}, @@ -237,7 +238,7 @@ async fn credentials<'a>(detail: &'a UserDetail) -> Result {
    for email in &detail.emails {
  • - (email.address.as_str()) + private_address(address: email.address.as_str()) if email.primary { "Primary" } match email.verified_at { @@ -272,7 +273,9 @@ async fn credentials<'a>(detail: &'a UserDetail) -> Result { for identity in &detail.identities {
  • (identity.provider.to_string()) - (identity.linked_email.clone().unwrap_or_default()) + if let Some(email) = &identity.linked_email { + private_address(address: email.as_str()) + }
  • }
diff --git a/crates/ui/src/layout.rs b/crates/ui/src/layout.rs index 37db2a6cc..ced10e73e 100644 --- a/crates/ui/src/layout.rs +++ b/crates/ui/src/layout.rs @@ -217,6 +217,19 @@ pub async fn intro<'a>( }) } +/// An email `address`, blurred until clicked so a shared screen does not show it; +/// clicking again blurs it. A checkbox, visually hidden, holds whether it shows: +/// the admin dashboard allows no script. +#[component] +pub(crate) async fn private_address<'a>(address: &'a str) -> Result { + Ok(view! { + + }) +} + /// The navigation named `label`, of `class`, linking each of `links` to its URL, /// `current` among them, whose link is marked [`Label::CURRENT`]. #[component] diff --git a/crates/ui/src/settings/emails.rs b/crates/ui/src/settings/emails.rs index 4aab91a98..1d1855e62 100644 --- a/crates/ui/src/settings/emails.rs +++ b/crates/ui/src/settings/emails.rs @@ -4,7 +4,7 @@ use super::Audience; use crate::{ Section, Title, form::{Query, change_form, fragment_form, open}, - layout::frame, + layout::{frame, private_address}, }; use piquel_common::EmailId; use serde::{Deserialize, Serialize}; @@ -153,7 +153,7 @@ async fn address_row<'a>( Ok(view! {
- (address) + private_address(address: address)

(if blocked { "Primary: receives security notices. Make another address primary to remove it." diff --git a/infra/README.md b/infra/README.md index 5592e04be..849e7ffd3 100644 --- a/infra/README.md +++ b/infra/README.md @@ -181,13 +181,15 @@ the gateway ranges in `PIQUELD_INGRESS_PROXIES` to trust ingress's overwritten Auth decides every response's `Cache-Control` itself; the edge needs no rule. Handlers mark a response cacheable with `Cached` (`apps/auth-service/src/security`), and anything else, including any error and any response that sets a cookie, is -`no-store`: +`no-store`. Every value also carries `no-transform`, so Cloudflare never rewrites +a body: its Email Address Obfuscation would replace addresses with a link to a +decoding script the pages' Content-Security-Policy blocks. | Class | `Cache-Control` | Responses | | --- | --- | --- | -| `NoStore` | `no-store` | APIs, OAuth, server-rendered pages, errors, everything not below | -| `Immutable` | `public, max-age=31536000, immutable` | the pages' content-hashed stylesheet and script, under `/assets/` | -| `Public` | `public, max-age=N` | discovery and JWKS, for an hour | +| `NoStore` | `no-store, no-transform` | APIs, OAuth, server-rendered pages, errors, everything not below | +| `Immutable` | `public, max-age=31536000, immutable, no-transform` | the pages' content-hashed stylesheet and script, under `/assets/` | +| `Public` | `public, max-age=N, no-transform` | discovery and JWKS, for an hour | Every page is server-rendered and `no-store`, so a deploy never leaves a cached page pointing at a stylesheet or script the new binary no longer serves. The Cloudflare Tunnel diff --git a/tests/browser/developers.spec.ts b/tests/browser/developers.spec.ts index 10e87f2c0..213af5a8c 100644 --- a/tests/browser/developers.spec.ts +++ b/tests/browser/developers.spec.ts @@ -53,7 +53,7 @@ test('the developer console registers an app, shows its secret once, and the app await page.getByRole('button', { name: 'Register app', exact: true }).click(); const answer = await registered; expect(answer.status()).toBe(200); - expect(answer.headers()['cache-control']).toBe('no-store'); + expect(answer.headers()['cache-control']).toBe('no-store, no-transform'); await expect(page.getByRole('heading', { name: 'Your client secret' })).toBeVisible(); const secret = (await page.locator('#client-secret').textContent()) ?? ''; expect(secret).toMatch(/^pqcs_/); From 458e7143e3be8b40cb46d3ee4c49a3b82bf6cab8 Mon Sep 17 00:00:00 2001 From: piquel Date: Thu, 29 Oct 2026 00:29:14 +0100 Subject: [PATCH 2/3] test(auth): match the blurred address markup on the settings page Co-Authored-By: Claude Opus 5.5 --- apps/auth-service/src/web/settings/tests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/auth-service/src/web/settings/tests.rs b/apps/auth-service/src/web/settings/tests.rs index 19749a3fc..f5c39a4f0 100644 --- a/apps/auth-service/src/web/settings/tests.rs +++ b/apps/auth-service/src/web/settings/tests.rs @@ -168,7 +168,7 @@ async fn confirmed_changes_ask_for_a_passkey_first() { assert_eq!(cookie(&added, BrowserCookie::Notice).0, "email_added"); let page = html(confirmed.visit(&replicas.a, settings::EMAILS).await).await; assert!( - page.contains(&format!("{address}")), + page.contains(&format!("{address}")), "{page}" ); assert!(page.contains("Waiting for confirmation"), "{page}"); @@ -236,7 +236,7 @@ async fn addresses_change_their_primary_and_are_removed() { let page = html(browser.visit(&replicas.a, settings::EMAILS).await).await; assert!(!page.contains(&first), "{page}"); assert!( - page.contains(&format!("{second}")), + page.contains(&format!("{second}")), "{page}" ); assert!( From 47c87cf5e7d7b11e989746b90cb1363f0d6cb721 Mon Sep 17 00:00:00 2001 From: piquel Date: Thu, 29 Oct 2026 00:30:15 +0100 Subject: [PATCH 3/3] style(auth): format the settings test assertions Co-Authored-By: Claude Opus 5.5 --- apps/auth-service/src/web/settings/tests.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/apps/auth-service/src/web/settings/tests.rs b/apps/auth-service/src/web/settings/tests.rs index f5c39a4f0..129995632 100644 --- a/apps/auth-service/src/web/settings/tests.rs +++ b/apps/auth-service/src/web/settings/tests.rs @@ -167,10 +167,7 @@ async fn confirmed_changes_ask_for_a_passkey_first() { let added = confirmed.post(&replicas, settings::EMAILS, &add).await; assert_eq!(cookie(&added, BrowserCookie::Notice).0, "email_added"); let page = html(confirmed.visit(&replicas.a, settings::EMAILS).await).await; - assert!( - page.contains(&format!("{address}")), - "{page}" - ); + assert!(page.contains(&format!("{address}")), "{page}"); assert!(page.contains("Waiting for confirmation"), "{page}"); let id = value_after(&page, r#"name="remove" value=""#) @@ -235,10 +232,7 @@ async fn addresses_change_their_primary_and_are_removed() { assert_eq!(cookie(&removed, BrowserCookie::Notice).0, "email_removed"); let page = html(browser.visit(&replicas.a, settings::EMAILS).await).await; assert!(!page.contains(&first), "{page}"); - assert!( - page.contains(&format!("{second}")), - "{page}" - ); + assert!(page.contains(&format!("{second}")), "{page}"); assert!( page.contains("Primary: receives security notices"), "{page}"