forge
Explore
Log in

Don't you dare go Hollow

the dizey family joins the chrome: a services config names the siblings, the signed-in pages wear the in·im·iz wordmark trio with the current app inked, and the landing opens with a directory of cards above the account sections; logout grows a GET face for the relying parties' exit walk, its back admitted only as a local path or exactly one of the configured services' origins, and both faces revoke the central session so a sign-out anywhere ends the session everywhere

Browse files at this commit

b230307f8c239cd0817ba99fefc105080bb288a0Ahmet Kaan GümüşParent: fbf69ca
config/im.tomlmodified+18 -0
@@ -2,6 +2,24 @@ database = "im.db"
2 listen = "127.0.0.1:7650"2 listen = "127.0.0.1:7650"
3 issuer = "http://127.0.0.1:7650"3 issuer = "http://127.0.0.1:7650"
4 4
5+# The sibling apps of the switcher and the landing's services home, in
6+# wordmark order. Prod uses https://<key>.dizey.sh — deploy-side config,
7+# not committed here.
8+[[services]]
9+key = "in"
10+name = "Files"
11+url = "http://127.0.0.1:7655"
12+
13+[[services]]
14+key = "im"
15+name = "Account"
16+url = "http://127.0.0.1:7650"
17+
18+[[services]]
19+key = "iz"
20+name = "Board"
21+url = "http://127.0.0.1:7654"
22+
5 # Without an [smtp] table the server runs in dev mode: invite links are23 # Without an [smtp] table the server runs in dev mode: invite links are
6 # printed to stdout instead of mailed.24 # printed to stdout instead of mailed.
7 # [smtp]25 # [smtp]
crates/im-web/assets/main.cssmodified+65 -0
@@ -319,11 +319,76 @@ body:has(.auth-stage) > .auth-stage::-webkit-scrollbar {
319 padding: 4px 0 10px;319 padding: 4px 0 10px;
320 }320 }
321 321
322+.service-trio {
323+ display: flex;
324+ justify-content: center;
325+ align-items: baseline;
326+ gap: 10px;
327+ padding: 0 0 2px;
328+}
329+
330+.trio-mark {
331+ font-family: var(--font-mono);
332+ font-size: 13px;
333+ font-weight: 500;
334+ letter-spacing: 0.02em;
335+ text-decoration: none;
336+ color: var(--muted);
337+}
338+.trio-mark:hover {
339+ color: var(--ink);
340+}
341+.trio-mark-on {
342+ color: var(--ink);
343+ box-shadow: inset 0 -2px 0 var(--accent);
344+}
345+
346+.trio-sep {
347+ color: var(--muted-soft);
348+}
349+
322 .landing-stage .auth-column {350 .landing-stage .auth-column {
323 margin-top: max(24px, (100dvh - 640px) / 2);351 margin-top: max(24px, (100dvh - 640px) / 2);
324 margin-bottom: 24px;352 margin-bottom: 24px;
325 }353 }
326 354
355+.service-grid {
356+ display: flex;
357+ flex-wrap: wrap;
358+ gap: 10px;
359+}
360+
361+.service-card {
362+ flex: 1 1 140px;
363+ display: flex;
364+ align-items: center;
365+ gap: 10px;
366+ padding: 10px 14px;
367+ border: 1px solid var(--border);
368+ border-radius: var(--radius);
369+ text-decoration: none;
370+ color: inherit;
371+}
372+.service-card:hover {
373+ border-color: var(--accent);
374+ color: inherit;
375+}
376+.service-card-on {
377+ border-color: var(--accent);
378+ background: var(--accent-tint);
379+}
380+
381+.service-mark {
382+ font-family: var(--font-mono);
383+ font-size: 15px;
384+ font-weight: 500;
385+}
386+
387+.service-name {
388+ font-size: 13px;
389+ color: var(--muted);
390+}
391+
327 .auth-card {392 .auth-card {
328 background: var(--surface);393 background: var(--surface);
329 border: 1px solid var(--border);394 border: 1px solid var(--border);
crates/im-web/src/auth.rsmodified+68 -1
@@ -43,6 +43,47 @@ fn safe_back(raw: &str) -> &str {
43 }43 }
44 }44 }
45 45
46+/// Where a logout sends the browser. A local absolute path always
47+/// qualifies — the login `back` rule. An absolute URL qualifies when its
48+/// origin is exactly one of the configured services': the sibling app that
49+/// sent the browser here gets it handed back. A foreign origin — and
50+/// anything unparseable — is refused to the front door.
51+fn logout_target(raw: Option<&str>, services: &[crate::config::Service]) -> String {
52+ let Some(raw) = raw else {
53+ return "/".to_string();
54+ };
55+ if raw.starts_with('/') && !raw.starts_with("//") {
56+ return raw.to_string();
57+ }
58+ if let Some(origin) = url_origin(raw) {
59+ if services
60+ .iter()
61+ .any(|s| url_origin(&s.url).is_some_and(|known| known == origin))
62+ {
63+ return raw.to_string();
64+ }
65+ }
66+ "/".to_string()
67+}
68+
69+/// The `scheme://authority` of an absolute http(s) URL, lowercased — the
70+/// whole of what an origin match compares. `None` for anything else.
71+fn url_origin(raw: &str) -> Option<String> {
72+ let (scheme, rest) = raw.split_once("://")?;
73+ if !scheme.eq_ignore_ascii_case("http") && !scheme.eq_ignore_ascii_case("https") {
74+ return None;
75+ }
76+ let authority = rest.split(['/', '?', '#']).next()?;
77+ if authority.is_empty() {
78+ return None;
79+ }
80+ Some(format!(
81+ "{}://{}",
82+ scheme.to_ascii_lowercase(),
83+ authority.to_ascii_lowercase()
84+ ))
85+}
86+
46 /// Creation-time facts for the session row: the address the browser came87 /// Creation-time facts for the session row: the address the browser came
47 /// through and the agent it claims to be. The accept loop discards the peer88 /// through and the agent it claims to be. The accept loop discards the peer
48 /// address, so the proxy headers are the only source — the first89 /// address, so the proxy headers are the only source — the first
@@ -248,6 +289,14 @@ async fn enroll(cx: &Cx, Form(input): Form<TotpForm>) -> Redirect {
248 /// refresh token any app is still holding — see `sessions::revoke_session`.289 /// refresh token any app is still holding — see `sessions::revoke_session`.
249 #[route(POST "/logout")]290 #[route(POST "/logout")]
250 async fn logout(cx: &Cx) -> Redirect {291 async fn logout(cx: &Cx) -> Redirect {
292+ sign_out_everywhere(cx).await?;
293+ see("/".to_string())
294+}
295+
296+/// The shared half of both logouts: the central session dies — with it
297+/// every refresh token and app session bound to it — and the cookie is
298+/// tidied. Where the browser goes next is each route's own business.
299+async fn sign_out_everywhere(cx: &Cx) -> Result<()> {
251 if let Some(token) = server::presented_session(cx) {300 if let Some(token) = server::presented_session(cx) {
252 let email = im_core::sessions::resolve_session(&server::app(cx).store, &token)301 let email = im_core::sessions::resolve_session(&server::app(cx).store, &token)
253 .await?302 .await?
@@ -256,7 +305,25 @@ async fn logout(cx: &Cx) -> Redirect {
256 server::log_event(cx, "logout", email.as_deref(), None).await;305 server::log_event(cx, "logout", email.as_deref(), None).await;
257 }306 }
258 server::clear_session_cookie(cx);307 server::clear_session_cookie(cx);
259- see("/".to_string())308+ Ok(())
309+}
310+
311+/// The RP-initiated exit: a sibling app has cleared its own cookie and
312+/// sent the browser here as a top-level navigation. `back` names the
313+/// return address, judged by [`logout_target`] — and the central session
314+/// dies whatever the answer is.
315+#[route(GET "/logout")]
316+async fn logout_return(cx: &Cx) -> Redirect {
317+ let query = topcoat::router::request::uri(cx)
318+ .query()
319+ .unwrap_or("")
320+ .to_string();
321+ let back = crate::pages::query_value(&query, "back");
322+ sign_out_everywhere(cx).await?;
323+ see(logout_target(
324+ back.as_deref(),
325+ &server::app(cx).config.services,
326+ ))
260 }327 }
261 328
262 #[derive(Deserialize)]329 #[derive(Deserialize)]
crates/im-web/src/config.rsmodified+41 -0
@@ -25,6 +25,24 @@ pub struct Config {
25 /// The OIDC issuer — the public base URL every endpoint address and every25 /// The OIDC issuer — the public base URL every endpoint address and every
26 /// `iss` claim derives from.26 /// `iss` claim derives from.
27 pub issuer: String,27 pub issuer: String,
28+ pub services: Vec<Service>,
29+}
30+
31+/// One sibling app in the switcher and on the landing's services home:
32+/// the wordmark `key` ("in", "im", "iz" — im's own), a human `name`, and
33+/// the absolute base `url` without a trailing slash.
34+#[derive(Clone)]
35+pub struct Service {
36+ pub key: String,
37+ pub name: String,
38+ pub url: String,
39+}
40+
41+#[derive(Deserialize)]
42+struct RawService {
43+ key: String,
44+ name: String,
45+ url: String,
28 }46 }
29 47
30 #[derive(Deserialize)]48 #[derive(Deserialize)]
@@ -32,6 +50,8 @@ struct Raw {
32 database: Option<String>,50 database: Option<String>,
33 listen: Option<String>,51 listen: Option<String>,
34 issuer: Option<String>,52 issuer: Option<String>,
53+ #[serde(default)]
54+ services: Vec<RawService>,
35 }55 }
36 56
37 impl Config {57 impl Config {
@@ -52,6 +72,26 @@ impl Config {
52 if !issuer.starts_with("http://") && !issuer.starts_with("https://") {72 if !issuer.starts_with("http://") && !issuer.starts_with("https://") {
53 return Err(format!("{PATH}: issuer {issuer:?} must be an http(s) URL"));73 return Err(format!("{PATH}: issuer {issuer:?} must be an http(s) URL"));
54 }74 }
75+ let mut services = Vec::new();
76+ for service in raw.services {
77+ if !matches!(service.key.as_str(), "in" | "im" | "iz") {
78+ return Err(format!(
79+ "{PATH}: services: key {:?} must be in, im, or iz",
80+ service.key
81+ ));
82+ }
83+ if !service.url.starts_with("http://") && !service.url.starts_with("https://") {
84+ return Err(format!(
85+ "{PATH}: services.{}.url {:?} must be an http(s) URL",
86+ service.key, service.url
87+ ));
88+ }
89+ services.push(Service {
90+ key: service.key,
91+ name: service.name,
92+ url: service.url.trim_end_matches('/').to_string(),
93+ });
94+ }
55 Ok(Config {95 Ok(Config {
56 database: PathBuf::from(raw.database.unwrap_or_else(|| "im.db".to_string())),96 database: PathBuf::from(raw.database.unwrap_or_else(|| "im.db".to_string())),
57 listen: raw97 listen: raw
@@ -60,6 +100,7 @@ impl Config {
60 .parse()100 .parse()
61 .map_err(|e| format!("{PATH}: listen: {e}"))?,101 .map_err(|e| format!("{PATH}: listen: {e}"))?,
62 issuer: issuer.trim_end_matches('/').to_string(),102 issuer: issuer.trim_end_matches('/').to_string(),
103+ services,
63 })104 })
64 }105 }
65 106
crates/im-web/src/directory.rsmodified+154 -3
@@ -53,21 +53,23 @@ mod tests {
53 53
54 use im_core::accounts::{create_invite, create_user_from_invite};54 use im_core::accounts::{create_invite, create_user_from_invite};
55 use im_core::oidc::create_client;55 use im_core::oidc::create_client;
56+ use im_core::model::ClientId;
56 use im_core::store::Store;57 use im_core::store::Store;
57 use topcoat::cookie::RouterBuilderCookieExt as _;58 use topcoat::cookie::RouterBuilderCookieExt as _;
58 use topcoat::router::{Body, Router, RouterBuilderDiscoverExt as _, StatusCode, header, to_bytes};59 use topcoat::router::{Body, Router, RouterBuilderDiscoverExt as _, StatusCode, header, to_bytes};
59 60
60 use crate::config::Config;61 use crate::config::Config;
61- use crate::server;62+ use crate::server::{self, SESSION_COOKIE};
62 63
63 struct Setup {64 struct Setup {
64 router: Router,65 router: Router,
65 client_id: String,66 client_id: String,
66 secret: String,67 secret: String,
68+ store: Arc<Store>,
67 }69 }
68 70
69 async fn setup() -> Setup {71 async fn setup() -> Setup {
70- let store = Store::open(Path::new(":memory:")).await.unwrap();72+ let store = Arc::new(Store::open(Path::new(":memory:")).await.unwrap());
71 let (client_id, secret) = create_client(&store, "tasks", vec!["http://app/callback".into()])73 let (client_id, secret) = create_client(&store, "tasks", vec!["http://app/callback".into()])
72 .await74 .await
73 .unwrap();75 .unwrap();
@@ -94,11 +96,28 @@ mod tests {
94 .unwrap();96 .unwrap();
95 let (live, _) = tokio::sync::broadcast::channel(64);97 let (live, _) = tokio::sync::broadcast::channel(64);
96 let app = server::App {98 let app = server::App {
97- store: Arc::new(store),99+ store: store.clone(),
98 config: Config {100 config: Config {
99 database: ":memory:".into(),101 database: ":memory:".into(),
100 listen: "127.0.0.1:7650".parse().unwrap(),102 listen: "127.0.0.1:7650".parse().unwrap(),
101 issuer: "http://127.0.0.1:7650".into(),103 issuer: "http://127.0.0.1:7650".into(),
104+ services: vec![
105+ crate::config::Service {
106+ key: "in".into(),
107+ name: "Files".into(),
108+ url: "http://127.0.0.1:7655".into(),
109+ },
110+ crate::config::Service {
111+ key: "im".into(),
112+ name: "Account".into(),
113+ url: "http://127.0.0.1:7650".into(),
114+ },
115+ crate::config::Service {
116+ key: "iz".into(),
117+ name: "Board".into(),
118+ url: "http://127.0.0.1:7654".into(),
119+ },
120+ ],
102 },121 },
103 live,122 live,
104 };123 };
@@ -111,6 +130,7 @@ mod tests {
111 router,130 router,
112 client_id: client_id.to_string(),131 client_id: client_id.to_string(),
113 secret: secret.expose().to_string(),132 secret: secret.expose().to_string(),
133+ store,
114 }134 }
115 }135 }
116 136
@@ -133,12 +153,60 @@ mod tests {
133 (parts.status, String::from_utf8(bytes).unwrap())153 (parts.status, String::from_utf8(bytes).unwrap())
134 }154 }
135 155
156+ /// A form post through the router, answered as (status, Location, body).
157+ async fn post_form(
158+ router: &Router,
159+ uri: &str,
160+ body: &str,
161+ cookie: Option<&str>,
162+ ) -> (StatusCode, Option<String>, String) {
163+ let mut builder = http::Request::builder()
164+ .method(http::Method::POST)
165+ .uri(uri)
166+ .header(header::CONTENT_TYPE, "application/x-www-form-urlencoded");
167+ if let Some(cookie) = cookie {
168+ builder = builder.header(header::COOKIE, cookie);
169+ }
170+ let response = router
171+ .handle(builder.body(Body::from(body.to_string())).unwrap())
172+ .await;
173+ let (parts, body) = response.into_parts();
174+ let location = parts
175+ .headers
176+ .get(header::LOCATION)
177+ .and_then(|v| v.to_str().ok())
178+ .map(str::to_string);
179+ let bytes = to_bytes(body, usize::MAX).await.unwrap().to_vec();
180+ (parts.status, location, String::from_utf8(bytes).unwrap())
181+ }
182+
183+ /// A top-level GET (the RP-initiated logout's shape), same answer triple.
184+ async fn get_location(router: &Router, uri: &str, cookie: &str) -> (StatusCode, Option<String>) {
185+ let response = router
186+ .handle(
187+ http::Request::builder()
188+ .uri(uri)
189+ .header(header::COOKIE, cookie)
190+ .body(Body::empty())
191+ .unwrap(),
192+ )
193+ .await;
194+ let (parts, _) = response.into_parts();
195+ let location = parts
196+ .headers
197+ .get(header::LOCATION)
198+ .and_then(|v| v.to_str().ok())
199+ .map(str::to_string);
200+ (parts.status, location)
201+ }
202+
136 #[tokio::test]203 #[tokio::test]
137 async fn the_directory_names_every_non_disabled_user_with_its_admin_flag() {204 async fn the_directory_names_every_non_disabled_user_with_its_admin_flag() {
138 let Setup {205 let Setup {
139 router,206 router,
140 client_id,207 client_id,
141 secret,208 secret,
209+ ..
142 } = setup().await;210 } = setup().await;
143 let (status, body) = get(&router, Some(basic(&client_id, &secret))).await;211 let (status, body) = get(&router, Some(basic(&client_id, &secret))).await;
144 assert_eq!(status, StatusCode::OK);212 assert_eq!(status, StatusCode::OK);
@@ -173,4 +241,87 @@ mod tests {
173 let (status, _) = get(&router, Some(basic("no-such-client", "wrong"))).await;241 let (status, _) = get(&router, Some(basic("no-such-client", "wrong"))).await;
174 assert_eq!(status, StatusCode::UNAUTHORIZED);242 assert_eq!(status, StatusCode::UNAUTHORIZED);
175 }243 }
244+
245+ #[tokio::test]
246+ async fn logout_revokes_the_central_session_and_only_returns_known_origins() {
247+ let Setup {
248+ router,
249+ client_id,
250+ secret,
251+ store,
252+ } = setup().await;
253+ let ada = im_core::accounts::user_by_email(&store, "ada@example.com")
254+ .await
255+ .unwrap()
256+ .unwrap();
257+
258+ // The RP-initiated exit: `back` naming a configured service's own
259+ // origin is honored verbatim — the sibling gets its browser back.
260+ let one = im_core::sessions::create_session(&store, &ada.id, &Default::default())
261+ .await
262+ .unwrap();
263+ let (status, location) = get_location(
264+ &router,
265+ "/logout?back=http%3A%2F%2F127.0.0.1%3A7655%2F",
266+ &format!("{SESSION_COOKIE}={}", one.expose()),
267+ )
268+ .await;
269+ assert_eq!(status, StatusCode::SEE_OTHER);
270+ assert_eq!(location.as_deref(), Some("http://127.0.0.1:7655/"));
271+
272+ // A live app session bound to a second central session introspects
273+ // active — until a logout with a foreign `back` lands. The refusal
274+ // itself goes to the front door, and the revocation still lands:
275+ // the very next introspection is inactive.
276+ let two = im_core::sessions::create_session(&store, &ada.id, &Default::default())
277+ .await
278+ .unwrap();
279+ let app_token = im_core::oidc::issue_app_session(
280+ &store,
281+ &ada.id,
282+ &ClientId::from(client_id.clone()),
283+ &im_core::accounts::hash_token(two.expose()),
284+ )
285+ .await
286+ .unwrap();
287+ let probe = format!(
288+ "token={}&client_id={client_id}&client_secret={secret}",
289+ app_token.expose()
290+ );
291+ let (status, _, body) = post_form(&router, "/introspect", &probe, None).await;
292+ assert_eq!(status, StatusCode::OK);
293+ assert_eq!(
294+ serde_json::from_str::<serde_json::Value>(&body).unwrap()["active"],
295+ true
296+ );
297+
298+ let (status, location) = get_location(
299+ &router,
300+ "/logout?back=https%3A%2F%2Fevil.example%2F",
301+ &format!("{SESSION_COOKIE}={}", two.expose()),
302+ )
303+ .await;
304+ assert_eq!(status, StatusCode::SEE_OTHER);
305+ assert_eq!(location.as_deref(), Some("/"));
306+ let (status, _, body) = post_form(&router, "/introspect", &probe, None).await;
307+ assert_eq!(status, StatusCode::OK);
308+ assert_eq!(
309+ serde_json::from_str::<serde_json::Value>(&body).unwrap()["active"],
310+ false
311+ );
312+
313+ // im's own form logout is untouched: front door, no `back` at all.
314+ let three = im_core::sessions::create_session(&store, &ada.id, &Default::default())
315+ .await
316+ .unwrap();
317+ let (status, location, _) = post_form(
318+ &router,
319+ "/logout",
320+ "",
321+ Some(&format!("{SESSION_COOKIE}={}", three.expose())),
322+ )
323+ .await;
324+ assert_eq!(status, StatusCode::SEE_OTHER);
325+ assert_eq!(location.as_deref(), Some("/"));
326+ }
176 }327 }
crates/im-web/src/i18n.rsmodified+3 -0
@@ -126,6 +126,7 @@ pub enum Key {
126 StatActiveSessions,126 StatActiveSessions,
127 StatConnectedApps,127 StatConnectedApps,
128 SessionsTitle,128 SessionsTitle,
129+ ServicesTitle,
129 SignOutEverywhere,130 SignOutEverywhere,
130 AdminPanelLink,131 AdminPanelLink,
131 ViewPhotoAria,132 ViewPhotoAria,
@@ -447,6 +448,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
447 (StatConnectedApps, Tr) => "Bağlı uygulamalar",448 (StatConnectedApps, Tr) => "Bağlı uygulamalar",
448 (SessionsTitle, En) => "Sessions",449 (SessionsTitle, En) => "Sessions",
449 (SessionsTitle, Tr) => "Oturumlar",450 (SessionsTitle, Tr) => "Oturumlar",
451+ (ServicesTitle, En) => "Services",
452+ (ServicesTitle, Tr) => "Hizmetler",
450 (SignOutEverywhere, En) => "Sign out everywhere",453 (SignOutEverywhere, En) => "Sign out everywhere",
451 (SignOutEverywhere, Tr) => "Her yerde oturumu kapat",454 (SignOutEverywhere, Tr) => "Her yerde oturumu kapat",
452 (AdminPanelLink, En) => "Admin panel",455 (AdminPanelLink, En) => "Admin panel",
crates/im-web/src/layout.rsmodified+32 -0
@@ -8,6 +8,7 @@ use topcoat::context::Cx;
8 use topcoat::view::view;8 use topcoat::view::view;
9 9
10 use crate::i18n::{Key, Lang, lang_of, t};10 use crate::i18n::{Key, Lang, lang_of, t};
11+use crate::server;
11 12
12 /// `style/main.scss`, compiled by `build.rs` into `assets/main.css`.13 /// `style/main.scss`, compiled by `build.rs` into `assets/main.css`.
13 const STYLE: Asset = asset!("assets/main.css");14 const STYLE: Asset = asset!("assets/main.css");
@@ -23,6 +24,37 @@ pub async fn wordmark(cx: &Cx) -> Result {
23 }24 }
24 }25 }
25 26
27+/// The signed-in chrome's app trio: every configured service's wordmark,
28+/// middots between, the home one (`im`) inked and marked current, its
29+/// siblings plain links. A deployment that names no services renders
30+/// nothing — the single mark above stays the whole chrome.
31+pub async fn service_trio(cx: &Cx) -> Result {
32+ let services = &server::app(cx).config.services;
33+ let marks = (!services.is_empty()).then(|| {
34+ services
35+ .iter()
36+ .map(|service| {
37+ let key = crate::pages::escape(&service.key);
38+ if service.key == "im" {
39+ format!(
40+ r#"<span class="trio-mark trio-mark-on" aria-current="page">{key}</span>"#
41+ )
42+ } else {
43+ let url = crate::pages::escape(&service.url);
44+ format!(r#"<a class="trio-mark" href="{url}">{key}</a>"#)
45+ }
46+ })
47+ .collect::<Vec<_>>()
48+ .join(r#"<span class="trio-sep">·</span>"#)
49+ });
50+ view! {
51+ cx =>
52+ if let Some(marks) = marks {
53+ <nav class="service-trio">(topcoat::view::Unescaped::new_unchecked(marks))</nav>
54+ }
55+ }
56+}
57+
26 /// The profile card's face: the photo when the account has one, the name's58 /// The profile card's face: the photo when the account has one, the name's
27 /// first letter on a quiet tile when it does not. The URL's stamp comes from59 /// first letter on a quiet tile when it does not. The URL's stamp comes from
28 /// `photo::PhotoStamps`, so a changed photo is a changed URL.60 /// `photo::PhotoStamps`, so a changed photo is a changed URL.
crates/im-web/src/pages.rsmodified+32 -2
@@ -12,7 +12,7 @@ use topcoat::router::{page, path_param, route};
12 use topcoat::view::view;12 use topcoat::view::view;
13 13
14 use crate::i18n::{Key, Lang, lang_of, t};14 use crate::i18n::{Key, Lang, lang_of, t};
15-use crate::layout::{avatar, shell, wordmark};15+use crate::layout::{avatar, service_trio, shell, wordmark};
16 use crate::server::{self, PendingPurpose};16 use crate::server::{self, PendingPurpose};
17 17
18 path_param!(token);18 path_param!(token);
@@ -429,7 +429,7 @@ async fn enroll(cx: &Cx) -> Result<Response> {
429 /// so its interpolations never pass through `view!`'s escaping. The429 /// so its interpolations never pass through `view!`'s escaping. The
430 /// discipline matches admin.rs's `escape`: everything user-controlled430 /// discipline matches admin.rs's `escape`: everything user-controlled
431 /// (agent, address) crosses it before it reaches the markup.431 /// (agent, address) crosses it before it reaches the markup.
432-fn escape(raw: &str) -> String {432+pub(crate) fn escape(raw: &str) -> String {
433 raw.replace('&', "&amp;")433 raw.replace('&', "&amp;")
434 .replace('<', "&lt;")434 .replace('<', "&lt;")
435 .replace('>', "&gt;")435 .replace('>', "&gt;")
@@ -601,12 +601,42 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
601 )601 )
602 })602 })
603 .collect::<String>();603 .collect::<String>();
604+ // The services home: one card per configured app — wordmark and name,
605+ // the whole card the link. im's own card reads current. Above the
606+ // profile sections: im is the account center, and its landing is the
607+ // door to the rest.
608+ let services_html = server::app(cx)
609+ .config
610+ .services
611+ .iter()
612+ .map(|service| {
613+ let current = service.key == "im";
614+ let open = if current {
615+ r#"<span class="service-card service-card-on" aria-current="page">"#.to_string()
616+ } else {
617+ format!(r#"<a class="service-card" href="{}">"#, escape(&service.url))
618+ };
619+ format!(
620+ r#"{open}<span class="service-mark">{}</span><span class="service-name">{}</span></{}>"#,
621+ escape(&service.key),
622+ escape(&service.name),
623+ if current { "span" } else { "a" },
624+ )
625+ })
626+ .collect::<String>();
604 let stage = view! {627 let stage = view! {
605 cx =>628 cx =>
606 <main class="auth-stage landing-stage">629 <main class="auth-stage landing-stage">
607 <div class="auth-column">630 <div class="auth-column">
608 (wordmark(cx).await?)631 (wordmark(cx).await?)
632+ (service_trio(cx).await?)
609 <nav class="admin-tabs landing-nav">(topcoat::view::Unescaped::new_unchecked(nav))</nav>633 <nav class="admin-tabs landing-nav">(topcoat::view::Unescaped::new_unchecked(nav))</nav>
634+ if !services_html.is_empty() {
635+ <div class="auth-card">
636+ <div class="auth-title">(t(lang, Key::ServicesTitle))</div>
637+ <div class="service-grid">(topcoat::view::Unescaped::new_unchecked(services_html))</div>
638+ </div>
639+ }
610 if let Some(code) = ok {640 if let Some(code) = ok {
611 <div class="auth-ok">(ok_text(&code, lang))</div>641 <div class="auth-ok">(ok_text(&code, lang))</div>
612 }642 }
crates/im-web/src/people.rsmodified+2 -1
@@ -14,7 +14,7 @@ use topcoat::view::view;
14 use im_core::accounts;14 use im_core::accounts;
15 15
16 use crate::i18n::{Key, lang_of, t};16 use crate::i18n::{Key, lang_of, t};
17-use crate::layout::{avatar, shell, wordmark};17+use crate::layout::{avatar, service_trio, shell, wordmark};
18 use crate::server;18 use crate::server;
19 19
20 path_param!(user_id);20 path_param!(user_id);
@@ -40,6 +40,7 @@ async fn people_page(cx: &Cx) -> Result {
40 <main class="auth-stage">40 <main class="auth-stage">
41 <div class="auth-column">41 <div class="auth-column">
42 (wordmark(cx).await?)42 (wordmark(cx).await?)
43+ (service_trio(cx).await?)
43 <div class="auth-card">44 <div class="auth-card">
44 <div class="profile-head">45 <div class="profile-head">
45 if person.has_photo {46 if person.has_photo {
crates/im-web/src/photo.rsmodified+1 -0
@@ -326,6 +326,7 @@ mod tests {
326 database: ":memory:".into(),326 database: ":memory:".into(),
327 listen: "127.0.0.1:7650".parse().unwrap(),327 listen: "127.0.0.1:7650".parse().unwrap(),
328 issuer: "http://127.0.0.1:7650".into(),328 issuer: "http://127.0.0.1:7650".into(),
329+ services: Vec::new(),
329 },330 },
330 live,331 live,
331 };332 };
style/main.scssmodified+71 -0
@@ -279,6 +279,35 @@ body:has(.auth-stage) {
279 padding: 4px 0 10px;279 padding: 4px 0 10px;
280 }280 }
281 281
282+// The app trio under the signed-in wordmark: lower-case marks in the
283+// wordmark's mono, the home one inked, its siblings quiet links. The
284+// middots are part of the mark, not decoration between cards.
285+.service-trio {
286+ display: flex;
287+ justify-content: center;
288+ align-items: baseline;
289+ gap: 10px;
290+ padding: 0 0 2px;
291+}
292+
293+.trio-mark {
294+ font-family: var(--font-mono);
295+ font-size: 13px;
296+ font-weight: 500;
297+ letter-spacing: 0.02em;
298+ text-decoration: none;
299+ color: var(--muted);
300+
301+ &:hover { color: var(--ink); }
302+
303+ &-on {
304+ color: var(--ink);
305+ box-shadow: inset 0 -2px 0 var(--accent);
306+ }
307+}
308+
309+.trio-sep { color: var(--muted-soft); }
310+
282 // The landing's column tops out where it would sit if the TALLEST section311 // The landing's column tops out where it would sit if the TALLEST section
283 // were the one being centred: the wordmark and tab row hold that line on312 // were the one being centred: the wordmark and tab row hold that line on
284 // every section, and shorter sections simply end sooner below it. 640px313 // every section, and shorter sections simply end sooner below it. 640px
@@ -290,6 +319,48 @@ body:has(.auth-stage) {
290 margin-bottom: 24px;319 margin-bottom: 24px;
291 }320 }
292 321
322+// The landing's services home: one card per configured app — wordmark and
323+// name on one line, the whole card the link. im's own card reads current:
324+// accent border, tinted, no pointer.
325+.service-grid {
326+ display: flex;
327+ flex-wrap: wrap;
328+ gap: 10px;
329+}
330+
331+.service-card {
332+ flex: 1 1 140px;
333+ display: flex;
334+ align-items: center;
335+ gap: 10px;
336+ padding: 10px 14px;
337+ border: 1px solid var(--border);
338+ border-radius: var(--radius);
339+ text-decoration: none;
340+ color: inherit;
341+
342+ &:hover {
343+ border-color: var(--accent);
344+ color: inherit;
345+ }
346+
347+ &-on {
348+ border-color: var(--accent);
349+ background: var(--accent-tint);
350+ }
351+}
352+
353+.service-mark {
354+ font-family: var(--font-mono);
355+ font-size: 15px;
356+ font-weight: 500;
357+}
358+
359+.service-name {
360+ font-size: 13px;
361+ color: var(--muted);
362+}
363+
293 364
294 365
295 .auth-card {366 .auth-card {