diff --git a/apps/auth-service/src/web/admin/clients.rs b/apps/auth-service/src/web/admin/clients.rs index 6dda2c462..5c275e763 100644 --- a/apps/auth-service/src/web/admin/clients.rs +++ b/apps/auth-service/src/web/admin/clients.rs @@ -305,7 +305,8 @@ pub(super) async fn rotate(cx: &Cx, form: Option>) -> ResultEmails for Announcements"# + ), + "{page}" + ); for email in [false, true] { let change = InboxChange::Email { category: EmailCategory::Announcements, diff --git a/crates/ui/assets/style/base.css b/crates/ui/assets/style/base.css index 3de48cb89..95cbeb907 100644 --- a/crates/ui/assets/style/base.css +++ b/crates/ui/assets/style/base.css @@ -344,14 +344,14 @@ legend { margin-bottom: 0.5rem; padding: 0; } -/* A checkbox or radio button beside its label, its help below the label. */ +/* A radio button beside its label, its help below the label. */ .choice { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 0.6rem; align-items: start; } -.choice input { +.choice input[type='radio'] { width: auto; min-height: 0; margin: 0.25rem 0 0; @@ -364,6 +364,88 @@ legend { grid-column: 2; margin: 0; } +/* A switch's row: a box with its label and help on the left, and the switch at + its right end. */ +.choice:has([role='switch']) { + position: relative; + grid-template-columns: 1fr auto; + column-gap: 1rem; + align-items: center; + padding: 0.65rem 0.8rem; + border: 1px solid var(--line); + border-radius: 6px; +} +.choice [role='switch'] { + grid-area: 1 / 2 / span 2; + z-index: 1; +} +.choice [role='switch'] ~ * { + grid-column: 1; +} +/* The label covers its row, so a click anywhere on it flips the switch. */ +.choice [role='switch'] + label::after { + content: ''; + position: absolute; + inset: 0; + cursor: pointer; +} +/* A name the app sends, such as a scope's, labels its switch at full size. */ +.choice label code { + font-size: 1em; +} +/* The switches of one group: the rows of one box, a line between them. */ +.choices { + border: 1px solid var(--line); + border-radius: 6px; +} +.choices > .choice { + border: 0; + border-radius: 0; +} +.choices > .choice + .choice { + border-top: 1px solid var(--line); +} +/* A switch: a setting on or off, drawn as a track whose thumb slides to its end + and fills with the accent when on. A checkbox with the role in a form, or a + button with it that posts the change at once. */ +[role='switch'] { + appearance: none; + position: relative; + flex: none; + width: 40px; + height: 22px; + min-height: 0; + margin: 0; + padding: 0; + border: 1px solid transparent; + border-radius: 999px; + background: var(--muted); + cursor: pointer; + transition: background-color 0.15s; +} +[role='switch']::before { + content: ''; + position: absolute; + top: 2px; + left: 2px; + width: 16px; + height: 16px; + border-radius: 50%; + background: #fff; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); + transition: transform 0.15s; +} +[role='switch']:checked, +[role='switch'][aria-checked='true'] { + background: var(--accent); +} +[role='switch']:checked::before, +[role='switch'][aria-checked='true']::before { + transform: translateX(18px); +} +[role='switch']:not(:disabled):hover { + filter: brightness(1.08); +} .search input, .search select { flex: 1; diff --git a/crates/ui/src/clients.rs b/crates/ui/src/clients.rs index b51ee9024..338e204dc 100644 --- a/crates/ui/src/clients.rs +++ b/crates/ui/src/clients.rs @@ -464,9 +464,12 @@ async fn refusal<'a>(of: &'a Described<'a>) -> Result { }) } -/// A checkbox sending `name`, or with a `value`, a radio button of the group -/// `name` choosing it, `checked` or not, which takes the focus if `autofocus`: -/// its `label` beside it, then its `detail` below, which describes it. +/// A switch sending `name` when on, or with a `value`, a radio button of the +/// group `name` choosing it, `checked` or not, which takes the focus if +/// `autofocus`: its `label` beside it, then its `detail` below, which describes +/// it. The switch is a checkbox with the `switch` role, which the stylesheet +/// draws as a sliding toggle at the right end of a boxed row; switches inside a +/// `choices` element share one box. #[component] pub(crate) async fn choice<'a>( name: &'a str, @@ -482,6 +485,7 @@ pub(crate) async fn choice<'a>(
Result { }) } -/// A checkbox for each standard scope, those of `chosen` checked, and why the +/// A switch for each standard scope, those of `chosen` checked, and why the /// service refused them, as `scopes` says, if it did. #[component] async fn scope_choices<'a>(chosen: ScopeChoice, scopes: &'a Described<'a>) -> Result { Ok(view! {
"Scopes" - for scope in Scope::ALL { - choice( - name: scope.as_str(), - checked: chosen.has(scope), - autofocus: scopes.refused() && scope == Scope::ALL[0], - label: view! { (scope.as_str()) }, - detail: view! { (scope_description(scope)) }, - ) - } +
+ for scope in Scope::ALL { + choice( + name: scope.as_str(), + checked: chosen.has(scope), + autofocus: scopes.refused() && scope == Scope::ALL[0], + label: view! { (scope.as_str()) }, + detail: view! { (scope_description(scope)) }, + ) + } +
refusal(of: scopes) }) @@ -633,22 +639,24 @@ pub(crate) async fn client_form<'a>( help(of: &logouts, "Optional, one per line: pages users may return to after signing out.") refusal(of: &logouts) scope_choices(chosen: draft.scopes, scopes: &scopes) - choice( - name: "allow_refresh", - checked: draft.allow_refresh.0, - label: view! { "Allow refresh tokens" }, - detail: view! { - "When your app requests " "offline_access" ", it can stay signed in without sending users back to Origin Auth." - }, - ) - choice( - name: "require_pushed_authorization_requests", - checked: draft.require_pushed_authorization_requests.0, - label: view! { "Require pushed authorization requests" }, - detail: view! { - "Your app must post its sign-in requests to " "/oauth/par" " (RFC 9126), so none of their parameters travel through the browser." - }, - ) +
+ choice( + name: "allow_refresh", + checked: draft.allow_refresh.0, + label: view! { "Allow refresh tokens" }, + detail: view! { + "When your app requests " "offline_access" ", it can stay signed in without sending users back to Origin Auth." + }, + ) + choice( + name: "require_pushed_authorization_requests", + checked: draft.require_pushed_authorization_requests.0, + label: view! { "Require pushed authorization requests" }, + detail: view! { + "Your app must post its sign-in requests to " "/oauth/par" " (RFC 9126), so none of their parameters travel through the browser." + }, + ) +
backchannel_input(uri: &draft.backchannel_logout_uri, of: &backchannel) (child) ) diff --git a/crates/ui/src/form.rs b/crates/ui/src/form.rs index a2f0178d5..8744252dc 100644 --- a/crates/ui/src/form.rs +++ b/crates/ui/src/form.rs @@ -418,13 +418,16 @@ pub(crate) async fn hidden(#[into] fields: Fields) -> Result { /// the user fills in as `child`, the reason an administrator gives when `reason` /// asks for one, holding what they typed last, and a button labelled `label`, of `class`, beside a link back to /// `cancel` when there is one. With `confirm`, the passkey script first confirms -/// the session with a passkey; a ceremony that fails says why in the form. +/// the session with a passkey; a ceremony that fails says why in the form. With +/// `on`, the button is instead a [`switch`] named `label`, showing whether the +/// setting `change` toggles is on. #[component] pub(crate) async fn change_form<'a>( action: &'a str, #[into] change: Fields, #[into] label: String, #[default] class: &'a str, + #[default] on: Option, #[into] #[default] aria_label: Option, @@ -456,7 +459,11 @@ pub(crate) async fn change_form<'a>( }
- + if let Some(on) = on { + switch(on: on, label: label.as_str()) + } else { + + } if let Some(cancel) = &cancel { "Cancel" } @@ -465,6 +472,22 @@ pub(crate) async fn change_form<'a>( }) } +/// A switch named `label`, showing whether its setting is `on`: a button the +/// stylesheet draws as a sliding toggle, which posts its form, or with +/// `disabled`, only shows the setting to whom cannot change it. +#[component] +pub(crate) async fn switch<'a>( + on: bool, + label: &'a str, + #[default] disabled: bool, +) -> Result { + Ok(view! { + + }) +} + /// A passkey ceremony the passkey script runs before posting a [`passkey_form`], /// named by the form's marker. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/ui/src/settings/notifications.rs b/crates/ui/src/settings/notifications.rs index 1081aa36c..e0ddfcf31 100644 --- a/crates/ui/src/settings/notifications.rs +++ b/crates/ui/src/settings/notifications.rs @@ -3,7 +3,7 @@ use super::{Audience, HistoryRow, Holdings, timeline::report_form}; use crate::{ - form::{Checkbox, Precision, Query, change_form, open, time}, + form::{Checkbox, Precision, Query, change_form, open, switch, time}, icons::{Icon, icon}, layout::{announcement_text, dialog, page_head}, }; @@ -232,14 +232,9 @@ async fn email_preferences<'a>(page: InboxPage<'a>) -> Result {
    for preference in page.preferences {
  • + let label = format!("Emails for {}", preference.category.label());
    (preference.category.label()) - " " - if preference.email { - "Emailed" - } else { - "Not emailed" - } (preference.category.description())
    if owner { @@ -249,14 +244,11 @@ async fn email_preferences<'a>(page: InboxPage<'a>) -> Result { category: preference.category, email: Checkbox(!preference.email), }, - label: if preference.email { "Turn off" } else { "Turn on" }, - class: "secondary small", - aria_label: format!( - "Turn {} emails for {}", - if preference.email { "off" } else { "on" }, - preference.category.label(), - ), + label: label, + on: Some(preference.email), ) + } else { + switch(on: preference.email, label: label.as_str(), disabled: true) }
  • } diff --git a/docs/dev/operations/administration.md b/docs/dev/operations/administration.md index 9430fded0..53da453b4 100644 --- a/docs/dev/operations/administration.md +++ b/docs/dev/operations/administration.md @@ -310,7 +310,7 @@ On the dashboard: accounts**: paste a list, one handle, verified email or account ID per line, or type into the search box and select **Find**, then **Add** beside each account. Finding and adding save nothing. -3. Check **Essential** if every recipient must receive it by email. +3. Turn on **Essential** if every recipient must receive it by email. 4. Select **Save draft** to check the email first, or **Send** to send it now. Saving a draft needs no passkey; sending asks for one. diff --git a/docs/images/account/notification-email.png b/docs/images/account/notification-email.png index bed7cc698..385ab32ed 100644 Binary files a/docs/images/account/notification-email.png and b/docs/images/account/notification-email.png differ diff --git a/docs/images/apps/app-settings.png b/docs/images/apps/app-settings.png index ac791fc7a..f32b100ba 100644 Binary files a/docs/images/apps/app-settings.png and b/docs/images/apps/app-settings.png differ diff --git a/docs/images/apps/new-app.png b/docs/images/apps/new-app.png index 3b40a4920..885d4f3fd 100644 Binary files a/docs/images/apps/new-app.png and b/docs/images/apps/new-app.png differ diff --git a/docs/user/account/notifications.md b/docs/user/account/notifications.md index 466085edc..c78d3813b 100644 --- a/docs/user/account/notifications.md +++ b/docs/user/account/notifications.md @@ -93,18 +93,18 @@ From your settings: 1. Open **Notifications**, then select **Email preferences** at the top of the page. -2. Select **Turn off** beside **Announcements**. +2. Turn off the switch beside **Announcements**. -![The Email preferences dialog: Announcements, emailed, with a Turn off button](../../images/account/notification-email.png) +![The Email preferences dialog: Announcements, with its switch on](../../images/account/notification-email.png) From an announcement's email, select **Stop receiving announcements by email** at its end, then **Stop announcement emails** on the page it opens. Your mail app may also offer an **Unsubscribe** button beside the sender, which does the same in one click. -**Email preferences** then says **Not emailed** beside **Announcements**, and +The switch beside **Announcements** in **Email preferences** is then off, and your security history lists **Announcements: emails turned off**. Turn them -back on with **Turn on**, in the same place. +back on with the same switch. ## Troubleshooting diff --git a/docs/user/agents/skills/sourceorigin-deploy/SKILL.md b/docs/user/agents/skills/sourceorigin-deploy/SKILL.md index fd68898cd..d8487a367 100644 --- a/docs/user/agents/skills/sourceorigin-deploy/SKILL.md +++ b/docs/user/agents/skills/sourceorigin-deploy/SKILL.md @@ -36,7 +36,7 @@ https://auth.sourceorigin.dev/developers/new, with: - **Post-logout URIs**: `https:///`, if the app sends users back there after signing out. - **Scopes**: the app's scopes, and `offline_access`. -- **Allow refresh tokens**: checked. +- **Allow refresh tokens**: on. - **Back-channel logout URI**: `https:///auth/backchannel-logout`, only if the app handles back-channel logout. diff --git a/docs/user/agents/skills/sourceorigin-dev-setup/SKILL.md b/docs/user/agents/skills/sourceorigin-dev-setup/SKILL.md index b11640619..08b2fd660 100644 --- a/docs/user/agents/skills/sourceorigin-dev-setup/SKILL.md +++ b/docs/user/agents/skills/sourceorigin-dev-setup/SKILL.md @@ -44,7 +44,7 @@ this machine: there after signing out. - **Scopes**: the app's scopes, and `offline_access`, which the SDKs' login routes always request. -- **Allow refresh tokens**: checked. +- **Allow refresh tokens**: on. - **Back-channel logout URI**: empty. Auth posts logout tokens only to HTTPS URIs with public addresses, so it can't reach this machine. diff --git a/docs/user/agents/skills/sourceorigin-sign-in/SKILL.md b/docs/user/agents/skills/sourceorigin-sign-in/SKILL.md index c0e57f2fe..acc6192e1 100644 --- a/docs/user/agents/skills/sourceorigin-sign-in/SKILL.md +++ b/docs/user/agents/skills/sourceorigin-sign-in/SKILL.md @@ -39,7 +39,7 @@ https://auth.sourceorigin.dev/developers/new and fill in: `email` only if the app needs it, and `offline_access`. The login routes request `offline_access` on every sign-in, and auth refuses a sign-in that asks for a scope the app may not request. -- **Allow refresh tokens**: checked. Without refresh tokens, a session ends +- **Allow refresh tokens**: on. Without refresh tokens, a session ends with its access token, within five minutes. After **Register app**, the console shows the client secret once. Ask the diff --git a/docs/user/apps/browser-apps.md b/docs/user/apps/browser-apps.md index 5c943b8ea..1886fc3ab 100644 --- a/docs/user/apps/browser-apps.md +++ b/docs/user/apps/browser-apps.md @@ -13,8 +13,8 @@ The code on this page comes from the SDK's example, 2. Add the page that finishes sign-in as a redirect URI, such as `https:///callback`. Pages on its origin may then call auth's token endpoints from the browser. -3. To keep users signed in for longer than an access token's five minutes, tick - the `offline_access` scope and **Allow refresh tokens**, and request +3. To keep users signed in for longer than an access token's five minutes, turn + on the `offline_access` scope and **Allow refresh tokens**, and request `offline_access` when signing in. 4. Add `@sourceorigin/auth` to your app. It is not on npm yet: build it from a checkout of the repository, then install it from there. diff --git a/docs/user/apps/sign-in-rust.md b/docs/user/apps/sign-in-rust.md index e9227462f..41c56ce09 100644 --- a/docs/user/apps/sign-in-rust.md +++ b/docs/user/apps/sign-in-rust.md @@ -13,8 +13,8 @@ The code on this page comes from the SDK's example app, refuse a browser or native app. 2. In its settings, add the redirect URI `https:///auth/callback`. Every login requests `offline_access`, so the session can refresh its access - token: tick the `offline_access` scope, or sign-in fails, and **Allow refresh - tokens**, or each session lasts only as long as its first access token, five + token: turn on the `offline_access` scope, or sign-in fails, and **Allow + refresh tokens**, or each session lasts only as long as its first access token, five minutes. 3. Generate a cookie key, which seals the session cookies: @@ -156,7 +156,7 @@ rest of a session, and `logout_token` validates a back-channel logout token. - **A handler answers `500`:** the route is missing `auth.layer()`. - **Sign-in answers `502`, "Sign-in could not start":** auth refused the sign-in request, and the message says why, such as a scope the app may not - request: `offline_access` when its scope is left unticked. + request: `offline_access` when its scope is left off. - **Sign-in answers `400`, "This sign-in has no pending login":** the browser lost the login's cookie, or opened the callback twice. Start again from `/auth/login`. diff --git a/docs/user/apps/sign-in-typescript.md b/docs/user/apps/sign-in-typescript.md index bacccfb0f..154fc82cd 100644 --- a/docs/user/apps/sign-in-typescript.md +++ b/docs/user/apps/sign-in-typescript.md @@ -16,8 +16,8 @@ which runs on Node's `http` server. a `TypeError` for a browser or native app. 2. In its settings, add the redirect URI `https:///auth/callback`. Every login requests `offline_access`, so the session can refresh its access - token: tick the `offline_access` scope, or sign-in fails, and **Allow refresh - tokens**, or each session lasts only as long as its first access token, five + token: turn on the `offline_access` scope, or sign-in fails, and **Allow + refresh tokens**, or each session lasts only as long as its first access token, five minutes. 3. Generate a cookie key, which seals the session cookies: @@ -191,7 +191,7 @@ a back-channel logout token. app with a backend. - **Sign-in answers `502`, "Sign-in could not start":** auth refused the sign-in request, and the message says why, such as a scope the app may not - request: `offline_access` when its scope is left unticked. + request: `offline_access` when its scope is left off. - **Sign-in answers `400`, "This sign-in has no pending login":** the browser lost the login's cookie, or opened the callback twice. Start again from `/auth/login`. diff --git a/tests/browser/screenshots/app-settings.spec.ts b/tests/browser/screenshots/app-settings.spec.ts index 10be01fa7..7f1b2f1bc 100644 --- a/tests/browser/screenshots/app-settings.spec.ts +++ b/tests/browser/screenshots/app-settings.spec.ts @@ -20,7 +20,7 @@ test('app settings and secrets', async ({ page, context }) => { await page .getByRole('textbox', { name: 'Redirect URIs', exact: true }) .fill(`${app}/auth/callback`); - await page.getByRole('checkbox', { name: 'offline_access' }).check(); + await page.getByRole('switch', { name: 'offline_access' }).check(); await page.getByLabel('Allow refresh tokens', { exact: true }).check(); await page.getByRole('button', { name: 'Register app', exact: true }).click(); await page.getByRole('link', { name: 'I saved it', exact: true }).click();