Skip to content

Commit e8deebe

Browse files
PiquelChipsclaude
andcommitted
feat(auth): developer console at auth.piquel.fr/developers
Accounts register and manage their own OIDC clients on auth's own server-rendered pages: the apps list, registration, and each app's overview, settings and secrets. A new secret shows once, in the answer to the change that made it, and reloading it never posts again. The settings pages and the console share one page flow, and pages are classified by their route template. The owned-client JSON API goes, its tests ported to the service, since the console calls the same operations in-process. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent fade8b1 commit e8deebe

51 files changed

Lines changed: 4931 additions & 2065 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎README.md‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# piquel.fr
22

33
A monorepo for piquel.fr and its services. The first release is a passkey-first
4-
OIDC/SSO authority at `auth.piquel.fr`, which also serves the account settings.
4+
OIDC/SSO authority at `auth.piquel.fr`, which also serves the account settings and
5+
the developer console.
56

67
The authentication service is **one Rust executable** containing its login,
7-
onboarding, consent, passkey and settings pages. PostgreSQL is its only external
8+
onboarding, consent, passkey, settings and developer console pages. PostgreSQL is its only external
89
data service. GitHub and Google are optional login providers. The admin dashboard
910
(`apps/admin-web`, at `admin.piquel.fr`) calls its private admin API, and
1011
`piquel.fr` redirects to auth, keeping the path. See
@@ -35,7 +36,7 @@ just preview
3536

3637
This snapshots this checkout, including uncommitted changes, builds auth and the
3738
admin dashboard, applies migrations, and prints the preview's URLs; the settings
38-
are at `/settings` on its auth URL. The preview has its own database and keys. URLs
39+
are at `/settings`, and the developer console at `/developers`, on its auth URL. The preview has its own database and keys. URLs
3940
work from devices on the tailnet. Run the same command after changing code.
4041
`just preview-delete` removes it.
4142

@@ -355,11 +356,12 @@ userinfo endpoints from a browser. Scopes default to `openid`, `profile` and
355356
first-party clients only. `--require-par` makes the client push its authorization
356357
requests (`update --no-require-par` lifts it).
357358

358-
Accounts can also register clients for their own applications, through the
359-
account API: see [Managing your own OIDC clients](docs/guides/client-management.md).
359+
Accounts can also register clients for their own applications in the developer
360+
console, at `auth.piquel.fr/developers`: see
361+
[Managing your own OIDC clients](docs/guides/client-management.md).
360362
Auth generates their IDs and limits their scopes to `openid`, `profile`, `email`
361363
and `offline_access`; they are never trusted, and an account can have 10 and
362-
register 20 a day. They never appear in the account API of other accounts, while
364+
register 20 a day. They never appear in other accounts' consoles, while
363365
`client list` shows every client. Owners can disable and enable their clients;
364366
`client suspend` disables one so that its owner cannot enable it until
365367
`client unsuspend`, which leaves it disabled. Deleting a client, from either side, disables it, revokes its
@@ -478,12 +480,15 @@ explains how to choose a requirement and handle the challenge.
478480
it; plain registration ignores it. A social login can never replace an
479481
established account's passkeys.
480482
- Sensitive changes (adding or removing a passkey, linking or unlinking a provider,
481-
adding, removing or changing the primary email address) need a passkey confirmation of the current browser session from the last five
483+
adding, removing or changing the primary email address, and registering an OIDC
484+
client, rotating its secret, deleting it or changing its redirect or post-logout
485+
URIs) need a passkey confirmation of the current browser session from the last five
482486
minutes. A passkey sign-in counts; social sign-in never does. The age counts from
483487
the confirmation and is never extended by use, and it never applies to another
484-
session. Without one, a settings page asks for the passkey before it posts the
485-
change, and the API answers `403` with `"code": "step_up_required"` and `max_age`.
486-
Reads and renaming a passkey need only ordinary login.
488+
session. Without one, a page asks for the passkey before it posts the change, or,
489+
for a client's URIs, once the change is refused; the API answers `403` with
490+
`"code": "step_up_required"` and `max_age`. Reads, renaming a passkey and a
491+
client's other settings need only ordinary login.
487492
- Matching verified email suggests linking; it never grants account access.
488493
Linking requires possession of the provider account and the target account's
489494
passkey confirmation. Explicit linking, started from settings, permits

‎apps/auth-service/src/account/subject.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use std::ops::Deref;
2020
/// fields are private and only the extractors and [`Self::resolve`] build one,
2121
/// from the session cookie, so an operation only the owner may run, such as adding
2222
/// a passkey or an address, takes an `Owner`: no administrator or operator can
23-
/// call it.
23+
/// call it. A clone is the same owner, as the same request found them.
24+
#[derive(Clone)]
2425
pub(crate) struct Owner {
2526
/// The owner's browser session, as the request found it.
2627
session: StoredSession,

‎apps/auth-service/src/account/tests.rs‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use super::*;
66
use crate::{
77
AdminError, GracePeriod, Operator, Reason,
88
admin::tests::{Account, Harness, assert_refused, cli, operator},
9+
clients::{ClientPatch, ClientSettings, NewClient},
910
config::EmailConfig,
1011
passkey::PasskeyError,
1112
security::ApiError,
@@ -713,18 +714,18 @@ impl Confirming {
713714
service.revoke_passkey(&subject, state.passkey).await
714715
}
715716
Self::CreateClient => {
716-
let new = json!({
717-
"kind": "public",
718-
"display_name": "Other",
719-
"redirect_uris": ["https://other.example/callback"],
720-
});
721-
let new = serde_json::from_value(new).expect("new client");
717+
let new = NewClient {
718+
kind: ClientKind::Public,
719+
settings: ClientSettings::test("https://other.example"),
720+
};
722721
service.create_client(&owner, new).await.map(drop)
723722
}
724723
Self::UpdateClientRedirects => {
725724
let client = service.owned_client(owner, state.client.as_str()).await?;
726-
let patch = json!({"redirect_uris": ["https://attacker.example/callback"]});
727-
let patch = serde_json::from_value(patch).expect("patch");
725+
let patch = ClientPatch {
726+
redirect_uris: Some(vec!["https://attacker.example/callback".into()]),
727+
..ClientPatch::default()
728+
};
728729
service.update_client(&client, patch).await.map(drop)
729730
}
730731
Self::RotateClientSecret => {

‎apps/auth-service/src/admin/types.rs‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use super::AdminError;
44
use chrono::Duration;
55
use piquel_common::{HandleError, UserId};
6+
use piquel_ui::Grace;
67
use serde::Deserialize;
78
use std::{fmt, str::FromStr};
89
use thiserror::Error;
@@ -108,6 +109,19 @@ impl Default for GracePeriod {
108109
}
109110
}
110111

112+
impl From<Grace> for GracePeriod {
113+
/// The period the rotation form's choice names.
114+
fn from(grace: Grace) -> Self {
115+
Self(Minutes(match grace {
116+
Grace::Now => 0,
117+
Grace::Hour => MINUTES_PER_HOUR,
118+
Grace::Day => MINUTES_PER_DAY,
119+
Grace::Week => 7 * MINUTES_PER_DAY,
120+
Grace::Month => 30 * MINUTES_PER_DAY,
121+
}))
122+
}
123+
}
124+
111125
impl<const MIN: i64, const MAX: i64> TryFrom<String> for Lifetime<MIN, MAX> {
112126
type Error = InvalidLifetime;
113127
/// Parses owned text, as serde reads it.
@@ -257,6 +271,21 @@ mod tests {
257271
);
258272
}
259273

274+
/// Each choice of the rotation form is the grace period it is written as.
275+
#[test]
276+
fn rotation_choices_are_the_periods_they_name() {
277+
for grace in Grace::ALL {
278+
assert_eq!(
279+
Ok(GracePeriod::from(grace)),
280+
grace
281+
.as_str()
282+
.parse::<GracePeriod>()
283+
.map_err(|error| error.to_string()),
284+
"{grace}"
285+
);
286+
}
287+
}
288+
260289
/// Reasons count Unicode characters and reject blank or control input.
261290
#[test]
262291
fn reasons_are_bounded_visible_text() {

‎apps/auth-service/src/clients/api/mod.rs‎

Lines changed: 0 additions & 174 deletions
This file was deleted.

0 commit comments

Comments
 (0)