forge
Explore
Log in

Don't you dare go Hollow

Services and clients merge into one admin section

Browse files at this commit

b163bda9de2cab7fb5e8cd5c366d79802717a10cAhmet Kaan GümüşParent: 1abf241
As concepts they were one thing wearing two tables: the family
wordmarks and the relying-party credentials that sign in as them.

services gains client_id (migration-guarded ALTER over the owner
precedent): POST /family/register stamps the client id it authenticated
beside the row — insert and refresh alike — so the panel can join the
wordmark to its credential; im's own boot row stays NULL, the IdP is
not its own client. Existing rows heal the next time their app
re-registers; no code backfill. register grew the client_id parameter
(register_self passes None), and the Service struct carries the field
without serializing it — /family's wire shape is untouched.

The panel's Services section is now the merged table: key/name/address
half, client id/redirect URIs/registered half, Rotate/Revoke on any
client-bearing row (linked or stray), wordmark controls where they
apply, the dash where a half is missing, and both add lines — a
service and a client — under the table. section=clients lands there
too, so the old address keeps working; the separate Clients section
and its nav tab are gone. The landing's services home and /family
readers are untouched.

Tests: the register stamp (append, claim, refresh) at the store level,
the route stamp across two registers, and the merged section's three
row shapes — linked, credential-only, client-less — plus the alias.
Browser-verified on a scratch server: section renders, a client made
in the panel links to its service row after a real /family/register
curl, and the confirm pop still overlays without growing scroll area.
cargo test -p im-core (63) and -p im-web (37) green; workspace check
with zero warnings.
crates/im-core/src/services.rsmodified+37 -13
@@ -29,6 +29,14 @@ pub struct Service {
2929 /// three public fields the siblings mirror, and nothing more.
3030 #[serde(skip)]
3131 pub owner: Option<String>,
32+ /// The relying-party credential this row answers for — the client id
33+ /// `POST /family/register` authenticated, stamped on every register,
34+ /// insert and refresh alike. im's own row stays `None`: the IdP is not
35+ /// its own client. This is the panel's join key between the wordmark
36+ /// and its Rotate/Revoke controls; a row the seed or the panel made
37+ /// carries `None` until its app registers.
38+ #[serde(skip)]
39+ pub client_id: Option<String>,
3240 }
3341
3442 /// The owner im writes on its own row, registered from `issuer` on every
@@ -84,7 +92,7 @@ pub async fn list(store: &Store) -> Result<Vec<Service>> {
8492 let conn = store.conn.lock().await;
8593 let mut rows = conn
8694 .query(
87- "SELECT key, name, url, owner FROM services ORDER BY position, key",
95+ "SELECT key, name, url, owner, client_id FROM services ORDER BY position, key",
8896 (),
8997 )
9098 .await
@@ -96,6 +104,7 @@ pub async fn list(store: &Store) -> Result<Vec<Service>> {
96104 name: store::text(&row, 1)?,
97105 url: store::text(&row, 2)?,
98106 owner: store::opt_text(&row, 3)?,
107+ client_id: store::opt_text(&row, 4)?,
99108 });
100109 }
101110 Ok(services)
@@ -281,6 +290,7 @@ pub async fn register(
281290 name: &str,
282291 url: &str,
283292 owner: &str,
293+ client_id: Option<&str>,
284294 ) -> Result<Service> {
285295 validate(key, name, url).map_err(StoreError::Invalid)?;
286296 let url = url.trim_end_matches('/').to_string();
@@ -292,11 +302,12 @@ pub async fn register(
292302 }
293303 Some(_) => {
294304 // Claiming an unowned row or refreshing our own: the address is
295- // the app's to say, the name stays whatever is stored.
305+ // the app's to say, the name stays whatever is stored, and the
306+ // credential stamp follows the caller on every register.
296307 let conn = store.conn.lock().await;
297308 conn.execute(
298- "UPDATE services SET url = ?2, owner = ?3 WHERE key = ?1",
299- turso::params![key, url.as_str(), owner],
309+ "UPDATE services SET url = ?2, owner = ?3, client_id = ?4 WHERE key = ?1",
310+ turso::params![key, url.as_str(), owner, client_id],
300311 )
301312 .await
302313 .map_err(backend)?;
@@ -304,9 +315,9 @@ pub async fn register(
304315 None => {
305316 let conn = store.conn.lock().await;
306317 conn.execute(
307- "INSERT INTO services (key, name, url, position, owner) \
308- VALUES (?1, ?2, ?3, (SELECT COALESCE(MAX(position), -1) + 1 FROM services), ?4)",
309- turso::params![key, name.trim(), url.as_str(), owner],
318+ "INSERT INTO services (key, name, url, position, owner, client_id) \
319+ VALUES (?1, ?2, ?3, (SELECT COALESCE(MAX(position), -1) + 1 FROM services), ?4, ?5)",
320+ turso::params![key, name.trim(), url.as_str(), owner, client_id],
310321 )
311322 .await
312323 .map_err(backend)?;
@@ -364,6 +375,7 @@ mod tests {
364375 name: name.to_string(),
365376 url: url.to_string(),
366377 owner: None,
378+ client_id: None,
367379 }
368380 }
369381
@@ -519,6 +531,7 @@ mod tests {
519531 "Account",
520532 "http://127.0.0.1:7650/",
521533 SELF_OWNER,
534+ None,
522535 )
523536 .await
524537 .unwrap();
@@ -527,25 +540,36 @@ mod tests {
527540 "the slash is normalized off"
528541 );
529542 assert_eq!(row.owner.as_deref(), Some(SELF_OWNER));
543+ assert_eq!(row.client_id, None, "im is not its own client");
530544
531545 // A seeded row belongs to nobody; the app that names it claims it,
532546 // keeping the name the seed (or a later rename) gave it.
533547 add(&store, &service("in", "Dosyalar", "http://127.0.0.1:7655"))
534548 .await
535549 .unwrap();
536- let row = register(&store, "in", "Files", "https://in.example", "in-client")
550+ let row = register(&store, "in", "Files", "https://in.example", "in-client", Some("in-client"))
537551 .await
538552 .unwrap();
539553 assert_eq!(row.name, "Dosyalar", "the name stays the admin's");
540554 assert_eq!(row.url, "https://in.example");
541555 assert_eq!(row.owner.as_deref(), Some("in-client"));
556+ assert_eq!(
557+ row.client_id.as_deref(),
558+ Some("in-client"),
559+ "the claim stamps the credential"
560+ );
542561
543562 // The same app's next boot moves the address only.
544- let row = register(&store, "in", "Whatever", "https://in.dizey.sh", "in-client")
563+ let row = register(&store, "in", "Whatever", "https://in.dizey.sh", "in-client", Some("in-client"))
545564 .await
546565 .unwrap();
547566 assert_eq!(row.name, "Dosyalar");
548567 assert_eq!(row.url, "https://in.dizey.sh");
568+ assert_eq!(
569+ row.client_id.as_deref(),
570+ Some("in-client"),
571+ "the refresh keeps the stamp current"
572+ );
549573 // And no row was duplicated by any of it.
550574 assert_eq!(keys(&store).await, vec!["im".to_string(), "in".to_string()]);
551575 }
@@ -553,11 +577,11 @@ mod tests {
553577 #[tokio::test]
554578 async fn a_key_another_app_keeps_is_a_conflict_and_the_row_is_untouched() {
555579 let store = store().await;
556- register(&store, "in", "Files", "https://in.example", "in-client")
580+ register(&store, "in", "Files", "https://in.example", "in-client", Some("in-client"))
557581 .await
558582 .unwrap();
559583 assert!(matches!(
560- register(&store, "in", "Files", "https://evil.example", "iz-client").await,
584+ register(&store, "in", "Files", "https://evil.example", "iz-client", None).await,
561585 Err(StoreError::Conflict(_))
562586 ));
563587 assert_eq!(list(&store).await.unwrap()[0].url, "https://in.example");
@@ -566,7 +590,7 @@ mod tests {
566590 #[tokio::test]
567591 async fn the_panel_cannot_remove_an_owned_row_or_move_its_address() {
568592 let store = store().await;
569- register(&store, "in", "Files", "https://in.example", "in-client")
593+ register(&store, "in", "Files", "https://in.example", "in-client", Some("in-client"))
570594 .await
571595 .unwrap();
572596 assert!(matches!(
@@ -595,7 +619,7 @@ mod tests {
595619 #[tokio::test]
596620 async fn the_family_json_never_carries_the_owner() {
597621 let store = store().await;
598- register(&store, "im", "Account", "http://127.0.0.1:7650", SELF_OWNER)
622+ register(&store, "im", "Account", "http://127.0.0.1:7650", SELF_OWNER, None)
599623 .await
600624 .unwrap();
601625 let json = serde_json::to_value(list(&store).await.unwrap()).unwrap();
crates/im-core/src/store.rsmodified+11 -8
@@ -153,7 +153,8 @@ CREATE TABLE IF NOT EXISTS services (
153153 name TEXT NOT NULL,
154154 url TEXT NOT NULL,
155155 position INTEGER NOT NULL,
156- owner TEXT
156+ owner TEXT,
157+ client_id TEXT
157158 );
158159 ";
159160
@@ -261,13 +262,15 @@ impl Store {
261262 .await
262263 .map_err(backend)?;
263264 }
264- // What a session remembers about its browser: the listing shows
265- // these, so old databases grow them the same guarded way.
266- // The app that keeps a service row: `im` for this app's own
267- // entry, a client id for a sibling that registers itself, NULL
268- // for the config seed's and the panel's own rows.
269- if !has_column(&conn, "services", "owner").await? {
270- conn.execute("ALTER TABLE services ADD COLUMN owner TEXT", ())
265+ // The family rows' client linkage (the merge of the panel's
266+ // services and clients sections): a `POST /family/register`
267+ // stamps the authenticated client's id beside its row, so the
268+ // panel can show the wordmark and its credential as one thing.
269+ // ALTER over the owner precedent: databases born before the
270+ // column get it here, and every existing row reads NULL until
271+ // its app re-registers.
272+ if !has_column(&conn, "services", "client_id").await? {
273+ conn.execute("ALTER TABLE services ADD COLUMN client_id TEXT", ())
271274 .await
272275 .map_err(backend)?;
273276 }
crates/im-web/assets/main.cssmodified+13 -3
@@ -984,6 +984,13 @@ body:has(.log-list) .admin-card:has(.log-list) {
984984 border-top: 1px solid var(--border-soft);
985985 vertical-align: middle;
986986 }
987+.admin-table td.mono {
988+ overflow-wrap: anywhere;
989+}
990+
991+.admin-clients td.muted {
992+ white-space: nowrap;
993+}
987994
988995 .mono {
989996 font-family: var(--font-mono);
@@ -995,6 +1002,7 @@ body:has(.log-list) .admin-card:has(.log-list) {
9951002
9961003 .actions {
9971004 display: flex;
1005+ flex-wrap: wrap;
9981006 gap: 8px;
9991007 justify-content: flex-end;
10001008 }
@@ -1129,15 +1137,17 @@ body:has(.log-list) .admin-card:has(.log-list) {
11291137 }
11301138
11311139 .admin-confirm-pop {
1132- position: absolute;
1133- right: 0;
1134- top: calc(100% + 6px);
1140+ position: fixed;
1141+ top: 50%;
1142+ left: 50%;
1143+ transform: translate(-50%, -50%);
11351144 z-index: 30;
11361145 width: 240px;
11371146 padding: 12px;
11381147 background: var(--surface);
11391148 border: 1px solid var(--border-strong);
11401149 border-radius: var(--radius);
1150+ box-shadow: var(--shadow-2);
11411151 display: flex;
11421152 flex-direction: column;
11431153 gap: 8px;
crates/im-web/src/admin.rsmodified+210 -107
@@ -132,7 +132,6 @@ async fn admin_page(cx: &Cx) -> Result<Response> {
132132 [
133133 ("users", t(lang, Key::NavUsers)),
134134 ("services", t(lang, Key::NavServices)),
135- ("clients", t(lang, Key::NavClients)),
136135 ("message", t(lang, Key::NavMessage)),
137136 ("settings", t(lang, Key::NavSettings)),
138137 ("logs", t(lang, Key::NavLogs)),
@@ -152,8 +151,9 @@ async fn admin_page(cx: &Cx) -> Result<Response> {
152151 "message" => message_section(cx, lang).await?,
153152 "settings" => settings_section(cx, lang).await?,
154153 "logs" => logs_section(cx, lang).await?,
155- "services" => services_section(cx, lang).await?,
156- "clients" => clients_section(cx, shown, lang).await?,
154+ // `section=clients` lands here too — the sections are one table
155+ // now, and the old address keeps working.
156+ "services" | "clients" => services_section(cx, shown, lang).await?,
157157 _ => users_section(cx, &me, invited.as_deref(), lang).await?,
158158 };
159159
@@ -438,13 +438,26 @@ async fn users_section(
438438 ))
439439 }
440440
441-/// The family registry: the wordmarks every topbar's trio and the landing's
442-/// services home render, and `/family` serves. One table in the panel's own
443-/// skins — edit and remove as the two-step disclosures, the up/down pair as
444-/// plain row buttons — and the add line under it wearing the invite form's
445-/// skin.
446-async fn services_section(cx: &Cx, lang: i18n::Lang) -> Result<String, topcoat::Error> {
441+/// The family registry, wordmarks and credentials as one table. Every
442+/// service row carries its client half beside it — client id, redirect
443+/// URIs, registered date, Rotate/Revoke — joined by the client id its
444+/// `POST /family/register` authenticated; a client with no service row (a
445+/// test or stray credential) renders as a credential-only row, and a row
446+/// with no client yet shows the dash. The wordmark controls stay the
447+/// panel's on rows no app keeps, and the two add lines — a service, a
448+/// client — sit under the table.
449+async fn services_section(
450+ cx: &Cx,
451+ shown: Option<(String, String)>,
452+ lang: i18n::Lang,
453+) -> Result<String, topcoat::Error> {
447454 let services = im_core::services::list(&app(cx).store).await?;
455+ let clients = im_core::oidc::list_clients(&app(cx).store).await?;
456+ // The join: a service row's client id names the client whose wordmark
457+ // half and credential half render as one.
458+ let linked = |id: Option<&String>| {
459+ id.and_then(|cid| clients.iter().find(|client| &client.client_id.to_string() == cid))
460+ };
448461 let mut rows = String::new();
449462 for service in &services {
450463 let key = escape(&service.key);
@@ -508,34 +521,141 @@ async fn services_section(cx: &Cx, lang: i18n::Lang) -> Result<String, topcoat::
508521 t(lang, Key::ConfirmRemove),
509522 )
510523 };
524+ let (client_cell, uris_cell, registered_cell, client_actions) =
525+ match linked(service.client_id.as_ref()) {
526+ Some(client) => {
527+ let id = escape(&client.client_id.to_string());
528+ let uris = client
529+ .redirect_uris
530+ .iter()
531+ .map(|uri| escape(uri))
532+ .collect::<Vec<_>>()
533+ .join("<br>");
534+ let registered = client
535+ .created_at
536+ .format(&time::macros::format_description!(
537+ "[year]-[month]-[day]"
538+ ))
539+ .unwrap_or_default();
540+ let controls = client_controls(
541+ &id,
542+ &escape(&client.name),
543+ lang,
544+ );
545+ (id, uris, registered, controls)
546+ }
547+ None => ("—".to_string(), "—".to_string(), "—".to_string(), String::new()),
548+ };
511549 rows.push_str(&format!(
512- r#"<tr><td class="mono">{key}</td><td>{name}</td><td class="mono">{url}</td><td class="actions">{edit}{up}{down}{remove}</td></tr>"#,
550+ r#"<tr><td class="mono">{key}</td><td>{name}</td><td class="mono">{url}</td><td class="mono">{client_cell}</td><td class="mono">{uris_cell}</td><td class="muted">{registered_cell}</td><td class="actions">{edit}{up}{down}{remove}{client_actions}</td></tr>"#,
513551 ));
514552 }
553+ // Clients no service row answers for — the CLI's or the panel's test
554+ // credentials — still sit in the table, their credential half alone.
555+ for client in &clients {
556+ let id = client.client_id.to_string();
557+ if services
558+ .iter()
559+ .any(|service| service.client_id.as_deref() == Some(id.as_str()))
560+ {
561+ continue;
562+ }
563+ let name = escape(&client.name);
564+ let uris = client
565+ .redirect_uris
566+ .iter()
567+ .map(|uri| escape(uri))
568+ .collect::<Vec<_>>()
569+ .join("<br>");
570+ let registered = client
571+ .created_at
572+ .format(&time::macros::format_description!("[year]-[month]-[day]"))
573+ .unwrap_or_default();
574+ let controls = client_controls(&id, &name, lang);
575+ rows.push_str(&format!(
576+ r#"<tr><td class="muted">—</td><td>{name}</td><td class="muted">—</td><td class="mono">{}</td><td class="mono">{uris}</td><td class="muted">{registered}</td><td class="actions">{controls}</td></tr>"#,
577+ escape(&id),
578+ ));
579+ }
580+ // The show-once banner: the note says what to do with it, the value is
581+ // click-to-copy, and the shelf behind it has already handed it over.
582+ let shown_html = shown
583+ .map(|(client_id, secret)| {
584+ format!(
585+ r#"<div class="auth-note">{note}<div class="admin-copy-row"><div class="muted">{id_label}: <span class="mono">{client_id}</span></div><div class="auth-secret admin-copy-value">{secret}</div><button class="admin-action admin-copy" type="button" data-copied-label="{copied}">{copy}</button></div></div>"#,
586+ note = t(lang, Key::SecretShownNote),
587+ id_label = t(lang, Key::ClientIdLabel),
588+ client_id = escape(&client_id),
589+ secret = escape(&secret),
590+ copied = t(lang, Key::CopiedWord),
591+ copy = t(lang, Key::CopyWord),
592+ )
593+ })
594+ .unwrap_or_default();
515595 Ok(format!(
516596 r#"<div class="admin-card">
517597 <div class="auth-title">{title}</div>
598+ {shown_html}
518599 <div class="admin-table-wrap">
519- <table class="admin-table">
520- <thead><tr><th>{key_label}</th><th>{name_label}</th><th>{url_label}</th><th></th></tr></thead>
600+ <table class="admin-table admin-clients">
601+ <thead><tr><th>{key_label}</th><th>{name_label}</th><th>{url_label}</th><th>{id_label}</th><th>{uris_label}</th><th>{registered_label}</th><th></th></tr></thead>
521602 <tbody>{rows}</tbody>
522603 </table>
523604 </div>
605+ <div class="muted">{service_add_label}</div>
524606 <form method="post" action="/admin/services_add" class="admin-invite">
525607 <input class="auth-input auth-input-mono" type="text" name="key" placeholder="in" aria-label="{key_label}" required>
526608 <input class="auth-input" type="text" name="name" placeholder="{name_label}" aria-label="{name_label}" required>
527609 <input class="auth-input auth-input-mono" type="text" name="url" placeholder="https://in.dizey.sh" aria-label="{url_label}" required>
528610 <button class="auth-submit admin-invite-go" type="submit"><span class="auth-submit-text">{add}</span></button>
529611 </form>
612+ <div class="muted">{client_add_label}</div>
613+ <form method="post" action="/admin/clients_add" class="admin-invite">
614+ <input class="auth-input" type="text" name="name" placeholder="drive" aria-label="{name_label}" required>
615+ <input class="auth-input auth-input-mono" type="text" name="redirect_uris" placeholder="http://127.0.0.1:9000/callback https://drive.dizey.sh/callback" aria-label="{uris_label}" required>
616+ <button class="auth-submit admin-invite-go" type="submit"><span class="auth-submit-text">{client_add}</span></button>
617+ </form>
530618 </div>"#,
531619 title = t(lang, Key::ServicesTitle),
532620 key_label = t(lang, Key::ServiceKeyLabel),
533621 name_label = t(lang, Key::NameCol),
534622 url_label = t(lang, Key::AddressLabel),
623+ id_label = t(lang, Key::ClientIdLabel),
624+ uris_label = t(lang, Key::RedirectUrisLabel),
625+ registered_label = t(lang, Key::RegisteredCol),
626+ service_add_label = t(lang, Key::ServiceAdd),
535627 add = t(lang, Key::ServiceAdd),
628+ client_add_label = t(lang, Key::ClientAdd),
629+ client_add = t(lang, Key::ClientAdd),
536630 ))
537631 }
538632
633+/// A client's Rotate/Revoke pair, as the two-step disclosures — the same
634+/// controls on a linked service row and on a credential-only row.
635+fn client_controls(client_id: &str, name_html: &str, lang: i18n::Lang) -> String {
636+ let rotate = confirm_action(
637+ "client",
638+ client_id,
639+ "/admin/clients_rotate",
640+ t(lang, Key::RotateWord),
641+ "",
642+ &i18n::rotate_client_title(lang, name_html),
643+ t(lang, Key::RotateCost),
644+ t(lang, Key::ConfirmRotate),
645+ );
646+ let revoke_action = confirm_action(
647+ "client",
648+ client_id,
649+ "/admin/clients_revoke",
650+ t(lang, Key::RevokeWord),
651+ " admin-danger",
652+ &i18n::revoke_client_title(lang, name_html),
653+ t(lang, Key::RevokeCost),
654+ t(lang, Key::ConfirmRevoke),
655+ );
656+ format!("{rotate}{revoke_action}")
657+}
658+
539659 /// One user of the services forms: key, name, address. The add form fills
540660 /// all three; the edit form carries the key in its hidden field.
541661 #[derive(Deserialize)]
@@ -558,6 +678,7 @@ async fn services_add(cx: &Cx, Form(input): Form<ServiceForm>) -> Result<Respons
558678 name: input.name,
559679 url: input.url,
560680 owner: None,
681+ client_id: None,
561682 },
562683 )
563684 .await;
@@ -633,99 +754,6 @@ async fn service_outcome(
633754 }
634755 }
635756
636-/// The relying parties: every client the family's apps sign in with. One
637-/// table in the panel's own skins — rotate and revoke as the two-step
638-/// disclosures — and the add line under it wearing the invite form's skin.
639-/// A create or rotate answers a 303 whose `shown` ticket picks the fresh
640-/// secret off the shelf for exactly one render; the page never learns a
641-/// secret twice.
642-async fn clients_section(
643- cx: &Cx,
644- shown: Option<(String, String)>,
645- lang: i18n::Lang,
646-) -> Result<String, topcoat::Error> {
647- let clients = im_core::oidc::list_clients(&app(cx).store).await?;
648- let mut rows = String::new();
649- for client in &clients {
650- let id = escape(&client.client_id.to_string());
651- let name = escape(&client.name);
652- let uris = client
653- .redirect_uris
654- .iter()
655- .map(|uri| escape(uri))
656- .collect::<Vec<_>>()
657- .join("<br>");
658- let registered = client
659- .created_at
660- .format(&time::macros::format_description!("[year]-[month]-[day]"))
661- .unwrap_or_default();
662- // Rotation kills the old pair the moment the new one exists, so it
663- // says what it costs before it does it — like every destructive row
664- // action here.
665- let rotate = confirm_action(
666- "client",
667- &id,
668- "/admin/clients_rotate",
669- t(lang, Key::RotateWord),
670- "",
671- &i18n::rotate_client_title(lang, &name),
672- t(lang, Key::RotateCost),
673- t(lang, Key::ConfirmRotate),
674- );
675- let revoke_action = confirm_action(
676- "client",
677- &id,
678- "/admin/clients_revoke",
679- t(lang, Key::RevokeWord),
680- " admin-danger",
681- &i18n::revoke_client_title(lang, &name),
682- t(lang, Key::RevokeCost),
683- t(lang, Key::ConfirmRevoke),
684- );
685- rows.push_str(&format!(
686- r#"<tr><td>{name}</td><td class="mono">{id}</td><td class="mono">{uris}</td><td class="muted">{registered}</td><td class="actions">{rotate}{revoke_action}</td></tr>"#,
687- ));
688- }
689- // The show-once banner: the note says what to do with it, the value is
690- // click-to-copy, and the shelf behind it has already handed it over.
691- let shown_html = shown
692- .map(|(client_id, secret)| {
693- format!(
694- r#"<div class="auth-note">{note}<div class="admin-copy-row"><div class="muted">{id_label}: <span class="mono">{client_id}</span></div><div class="auth-secret admin-copy-value">{secret}</div><button class="admin-action admin-copy" type="button" data-copied-label="{copied}">{copy}</button></div></div>"#,
695- note = t(lang, Key::SecretShownNote),
696- id_label = t(lang, Key::ClientIdLabel),
697- client_id = escape(&client_id),
698- secret = escape(&secret),
699- copied = t(lang, Key::CopiedWord),
700- copy = t(lang, Key::CopyWord),
701- )
702- })
703- .unwrap_or_default();
704- Ok(format!(
705- r#"<div class="admin-card">
706- <div class="auth-title">{title}</div>
707- {shown_html}
708- <div class="admin-table-wrap">
709- <table class="admin-table admin-clients">
710- <thead><tr><th>{name_label}</th><th>{id_label}</th><th>{uris_label}</th><th>{registered_label}</th><th></th></tr></thead>
711- <tbody>{rows}</tbody>
712- </table>
713- </div>
714- <form method="post" action="/admin/clients_add" class="admin-invite">
715- <input class="auth-input" type="text" name="name" placeholder="drive" aria-label="{name_label}" required>
716- <input class="auth-input auth-input-mono" type="text" name="redirect_uris" placeholder="http://127.0.0.1:9000/callback https://drive.dizey.sh/callback" aria-label="{uris_label}" required>
717- <button class="auth-submit admin-invite-go" type="submit"><span class="auth-submit-text">{add}</span></button>
718- </form>
719-</div>"#,
720- title = t(lang, Key::ClientsTitle),
721- name_label = t(lang, Key::NameCol),
722- id_label = t(lang, Key::ClientIdLabel),
723- uris_label = t(lang, Key::RedirectUrisLabel),
724- registered_label = t(lang, Key::RegisteredCol),
725- add = t(lang, Key::ClientAdd),
726- ))
727-}
728-
729757 /// One user of the clients forms: the name, and one or more redirect URIs
730758 /// — whitespace- or comma-separated, as loose as the CLI's argument list,
731759 /// because a family dev's `http://127.0.0.1` redirect is a legitimate row.
@@ -1916,8 +1944,12 @@ mod tests {
19161944 assert!(location.starts_with("/admin?section=clients&shown="));
19171945 let ticket = location.trim_start_matches("/admin?section=clients&shown=");
19181946 let (id, secret) = server::take_shown_secret(ticket).expect("the one showing");
1919- let row = list_clients(&setup.store).await.unwrap();
1920- assert_eq!(id, row[0].client_id.to_string());
1947+ let stored = list_clients(&setup.store).await.unwrap();
1948+ let row = stored
1949+ .iter()
1950+ .find(|client| client.name == name)
1951+ .expect("the fresh row");
1952+ assert_eq!(id, row.client_id.to_string());
19211953 (id, secret)
19221954 }
19231955
@@ -2182,4 +2214,75 @@ mod tests {
21822214 .await;
21832215 assert!(!forged.contains("<div class=\"auth-secret"));
21842216 }
2217+
2218+ #[tokio::test]
2219+ async fn merged_section_renders_linked_unlinked_and_bare_rows() {
2220+ let setup = setup().await;
2221+
2222+ // A client registered through the panel, then the service row its
2223+ // app writes with that pair: the two halves link.
2224+ let (id, _secret) = create_via_panel(&setup, "drive").await;
2225+ im_core::services::register(
2226+ &setup.store,
2227+ "drive",
2228+ "Drive",
2229+ "https://drive.dizey.sh",
2230+ &id,
2231+ Some(&id),
2232+ )
2233+ .await
2234+ .unwrap();
2235+ // A second client no service row answers for, and a service row
2236+ // with no client yet.
2237+ create_via_panel(&setup, "stray").await;
2238+ im_core::services::add(
2239+ &setup.store,
2240+ &im_core::services::Service {
2241+ key: "wiki".into(),
2242+ name: "Wiki".into(),
2243+ url: "https://wiki.dizey.sh".into(),
2244+ owner: None,
2245+ client_id: None,
2246+ },
2247+ )
2248+ .await
2249+ .unwrap();
2250+
2251+ // Rendering needs the built asset bundle; without it the render
2252+ // assertions stay skipped (the routes themselves are covered).
2253+ if !setup.assets {
2254+ return;
2255+ }
2256+ let (status, _, body) = get_full(
2257+ &setup.router,
2258+ "/admin?section=services",
2259+ Some(&setup.admin_cookie),
2260+ )
2261+ .await;
2262+ assert_eq!(status, StatusCode::OK);
2263+
2264+ // The linked row: wordmark half and credential half, one row.
2265+ assert!(body.contains(">Drive</td>"), "the service name renders");
2266+ assert!(body.contains(&id), "the linked client id renders");
2267+ assert!(body.contains("https://drive.dizey.sh"), "the url renders");
2268+ assert!(body.contains("http://127.0.0.1:9000/callback"), "uris render");
2269+ // The credential-only row: the stray client's name, no key or url.
2270+ assert!(body.contains(">stray</td>"), "the stray client renders");
2271+ // The bare service row and the unlinked client carry the dash.
2272+ assert!(body.contains(">Wiki</td>"), "the bare service renders");
2273+ assert!(
2274+ body.contains("<td class=\"muted\">—</td>"),
2275+ "client-less halves read as the dash"
2276+ );
2277+
2278+ // The old address lands on the merged section too.
2279+ let (status, _, alias) = get_full(
2280+ &setup.router,
2281+ "/admin?section=clients",
2282+ Some(&setup.admin_cookie),
2283+ )
2284+ .await;
2285+ assert_eq!(status, StatusCode::OK);
2286+ assert_eq!(alias.contains(">Drive</td>"), body.contains(">Drive</td>"));
2287+ }
21852288 }
crates/im-web/src/directory.rsmodified+49 -1
@@ -201,7 +201,15 @@ async fn family_register(
201201 .into_response(cx);
202202 };
203203 let store = server::app(cx).store.clone();
204- match im_core::services::register(&store, &input.key, &input.name, &input.url, &client_id).await
204+ match im_core::services::register(
205+ &store,
206+ &input.key,
207+ &input.name,
208+ &input.url,
209+ &client_id,
210+ Some(&client_id),
211+ )
212+ .await
205213 {
206214 Ok(service) => Json(serde_json::to_value(service).unwrap()).into_response(cx),
207215 Err(im_core::store::StoreError::Conflict(_)) => (
@@ -396,6 +404,7 @@ mod tests {
396404 name: service.name.clone(),
397405 url: service.url.clone(),
398406 owner: None,
407+ client_id: None,
399408 })
400409 .collect()
401410 }
@@ -853,6 +862,7 @@ mod tests {
853862 name: "Files".into(),
854863 url: "http://127.0.0.1:7655".into(),
855864 owner: None,
865+ client_id: None,
856866 }];
857867 assert!(!im_core::services::seed_from(&store, &reseed).await.unwrap());
858868 let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await;
@@ -1051,6 +1061,44 @@ mod tests {
10511061 );
10521062 }
10531063
1064+ #[tokio::test]
1065+ async fn family_register_stamps_the_authenticated_client_on_its_row() {
1066+ let Setup {
1067+ router,
1068+ client_id,
1069+ secret,
1070+ store,
1071+ ..
1072+ } = setup().await;
1073+
1074+ // First register: the row is appended with the caller's stamp.
1075+ let (status, _) = post_register(
1076+ &router,
1077+ Some(basic(&client_id, &secret)),
1078+ serde_json::json!({"key": "drive", "name": "Drive", "url": "https://drive.dizey.sh"}),
1079+ )
1080+ .await;
1081+ assert_eq!(status, StatusCode::OK);
1082+ let rows = im_core::services::list(&store).await.unwrap();
1083+ let row = rows.iter().find(|s| s.key == "drive").unwrap();
1084+ assert_eq!(row.client_id.as_deref(), Some(client_id.as_str()));
1085+
1086+ // The next boot's register refreshes the row and keeps the stamp
1087+ // current — one row, still the caller's.
1088+ let (status, _) = post_register(
1089+ &router,
1090+ Some(basic(&client_id, &secret)),
1091+ serde_json::json!({"key": "drive", "name": "Drive", "url": "https://drive2.dizey.sh"}),
1092+ )
1093+ .await;
1094+ assert_eq!(status, StatusCode::OK);
1095+ let rows = im_core::services::list(&store).await.unwrap();
1096+ assert_eq!(rows.iter().filter(|s| s.key == "drive").count(), 1);
1097+ let row = rows.iter().find(|s| s.key == "drive").unwrap();
1098+ assert_eq!(row.url, "https://drive2.dizey.sh");
1099+ assert_eq!(row.client_id.as_deref(), Some(client_id.as_str()));
1100+ }
1101+
10541102 #[tokio::test]
10551103 async fn the_landing_lists_connected_apps_and_an_empty_note_without_them() {
10561104 let Setup {
crates/im-web/src/i18n.rsmodified+0 -6
@@ -243,8 +243,6 @@ pub enum Key {
243243 InviteButton,
244244
245245 // Admin clients section: the family's relying parties.
246- NavClients,
247- ClientsTitle,
248246 RedirectUrisLabel,
249247 RegisteredCol,
250248 ClientAdd,
@@ -726,10 +724,6 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
726724 (InviteButton, En) => "Invite",
727725 (InviteButton, Tr) => "Davet et",
728726
729- (NavClients, En) => "Clients",
730- (NavClients, Tr) => "İstemciler",
731- (ClientsTitle, En) => "Clients",
732- (ClientsTitle, Tr) => "İstemciler",
733727 (RedirectUrisLabel, En) => "Redirect URIs",
734728 (RedirectUrisLabel, Tr) => "Yönlendirme adresleri",
735729 (RegisteredCol, En) => "Registered",
crates/im-web/src/main.rsmodified+3 -0
@@ -173,6 +173,7 @@ async fn seed_services(store: &Store, config: &Config) {
173173 name: service.name.clone(),
174174 url: service.url.clone(),
175175 owner: None,
176+ client_id: None,
176177 })
177178 .collect();
178179 match im_core::services::seed_from(store, &seed).await {
@@ -198,6 +199,8 @@ async fn register_self(store: &Store, config: &Config) {
198199 "Account",
199200 &config.issuer,
200201 im_core::services::SELF_OWNER,
202+ // im is nobody's client: its own row carries no credential stamp.
203+ None,
201204 )
202205 .await
203206 {
style/main.scssmodified+1 -0
@@ -1041,6 +1041,7 @@ body:has(.log-list) {
10411041
10421042 .actions {
10431043 display: flex;
1044+ flex-wrap: wrap;
10441045 gap: 8px;
10451046 justify-content: flex-end;
10461047