Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/auth-service/src/web/admin/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ pub(super) async fn rotate(cx: &Cx, form: Option<Form<Rotation>>) -> Result<Resp
refusal: refusal,
)
};
App::render(cx, StatusCode::OK, "Client secrets", page).await
// A large page: its future is boxed, off the handler's stack.
Box::pin(App::render(cx, StatusCode::OK, "Client secrets", page)).await
}

/// The form rotating a client's secret: the developer console's, with why.
Expand Down
5 changes: 2 additions & 3 deletions apps/auth-service/src/web/auth/login/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,7 @@ impl WebApplication {
alert: alert,
)
};
Ok(self
.render(cx, status, step.title().as_str(), &targets, view)
.await?)
// A large page: its future is boxed, off the handler's stack.
Ok(Box::pin(self.render(cx, status, step.title().as_str(), &targets, view)).await?)
}
}
7 changes: 6 additions & 1 deletion apps/auth-service/src/web/settings/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,12 @@ async fn announcement_emails_are_turned_off_from_the_inbox_or_their_link() {
preferences.expect("preferences")[0].email
};
let page = html(browser.visit(&replicas.a, settings::NOTIFICATIONS).await).await;
assert!(page.contains("Turn off emails for Announcements"), "{page}");
assert!(
page.contains(
r#"aria-checked="true"><span class="visually-hidden">Emails for Announcements"#
),
"{page}"
);
for email in [false, true] {
let change = InboxChange::Email {
category: EmailCategory::Announcements,
Expand Down
86 changes: 84 additions & 2 deletions crates/ui/assets/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
66 changes: 37 additions & 29 deletions crates/ui/src/clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,12 @@ async fn refusal<'a>(of: &'a Described<'a>) -> Result<impl View> {
})
}

/// 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,
Expand All @@ -482,6 +485,7 @@ pub(crate) async fn choice<'a>(
<div class="choice">
<input
type=(if value.is_some() { "radio" } else { "checkbox" })
role=(value.is_none().then_some("switch"))
id=(input.id.as_str())
name=(name)
value=(value)
Expand Down Expand Up @@ -525,22 +529,24 @@ async fn kind_question(chosen: ClientKind) -> Result<impl View> {
})
}

/// 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<impl View> {
Ok(view! {
<fieldset aria-describedby=(scopes.refused().then(|| scopes.error()))>
<legend>"Scopes"</legend>
for scope in Scope::ALL {
choice(
name: scope.as_str(),
checked: chosen.has(scope),
autofocus: scopes.refused() && scope == Scope::ALL[0],
label: view! { <code>(scope.as_str())</code> },
detail: view! { (scope_description(scope)) },
)
}
<div class="choices">
for scope in Scope::ALL {
choice(
name: scope.as_str(),
checked: chosen.has(scope),
autofocus: scopes.refused() && scope == Scope::ALL[0],
label: view! { <code>(scope.as_str())</code> },
detail: view! { (scope_description(scope)) },
)
}
</div>
</fieldset>
refusal(of: scopes)
})
Expand Down Expand Up @@ -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 " <code>"offline_access"</code> ", 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 " <code>"/oauth/par"</code> " (RFC 9126), so none of their parameters travel through the browser."
},
)
<div class="choices">
choice(
name: "allow_refresh",
checked: draft.allow_refresh.0,
label: view! { "Allow refresh tokens" },
detail: view! {
"When your app requests " <code>"offline_access"</code> ", 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 " <code>"/oauth/par"</code> " (RFC 9126), so none of their parameters travel through the browser."
},
)
</div>
backchannel_input(uri: &draft.backchannel_logout_uri, of: &backchannel)
(child)
)
Expand Down
27 changes: 25 additions & 2 deletions crates/ui/src/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,16 @@ pub(crate) async fn hidden(#[into] fields: Fields) -> Result<impl View> {
/// 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<bool>,
#[into]
#[default]
aria_label: Option<String>,
Expand Down Expand Up @@ -456,7 +459,11 @@ pub(crate) async fn change_form<'a>(
<p class="notice error" role="alert" data-passkey-error="" hidden=""></p>
}
<div class="row actions">
<button class=(class) aria-label=(aria_label.as_deref())>(label.as_str())</button>
if let Some(on) = on {
switch(on: on, label: label.as_str())
} else {
<button class=(class) aria-label=(aria_label.as_deref())>(label.as_str())</button>
}
if let Some(cancel) = &cancel {
<a class="button secondary" href=(cancel.as_str())>"Cancel"</a>
}
Expand All @@ -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<impl View> {
Ok(view! {
<button role="switch" aria-checked=(if on { "true" } else { "false" }) disabled=(disabled)>
<span class="visually-hidden">(label)</span>
</button>
})
}

/// A passkey ceremony the passkey script runs before posting a [`passkey_form`],
/// named by the form's marker.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
Expand Down
20 changes: 6 additions & 14 deletions crates/ui/src/settings/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
};
Expand Down Expand Up @@ -232,14 +232,9 @@ async fn email_preferences<'a>(page: InboxPage<'a>) -> Result<impl View> {
<ul class="list">
for preference in page.preferences {
<li>
let label = format!("Emails for {}", preference.category.label());
<div class="text">
<strong>(preference.category.label())</strong>
" "
if preference.email {
<span class="badge ok">"Emailed"</span>
} else {
<span class="badge">"Not emailed"</span>
}
<small>(preference.category.description())</small>
</div>
if owner {
Expand All @@ -249,14 +244,11 @@ async fn email_preferences<'a>(page: InboxPage<'a>) -> Result<impl View> {
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)
}
</li>
}
Expand Down
2 changes: 1 addition & 1 deletion docs/dev/operations/administration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Binary file modified docs/images/account/notification-email.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/apps/app-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/apps/new-app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/user/account/notifications.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/user/agents/skills/sourceorigin-deploy/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ https://auth.sourceorigin.dev/developers/new, with:
- **Post-logout URIs**: `https://<environment's host>/`, 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://<environment's host>/auth/backchannel-logout`, only if the app
handles back-channel logout.
Expand Down
2 changes: 1 addition & 1 deletion docs/user/agents/skills/sourceorigin-dev-setup/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/user/agents/skills/sourceorigin-sign-in/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading