From adfa9a38126ac9a28f62fdfb1f1eadc52063eb59 Mon Sep 17 00:00:00 2001 From: lewis Date: Sun, 21 Dec 2025 17:53:25 +0200 Subject: [PATCH] Better handles --- TODO.md | 16 +-- frontend/src/routes/OAuthLogin.svelte | 10 +- frontend/src/routes/Register.svelte | 10 +- migrations/20251211_initial_schema.sql | 109 +++++++++++++--- migrations/20251213_performance_indexes.sql | 15 --- migrations/20251214_add_prev_data_cid.sql | 1 - .../20251215_add_identity_account_fields.sql | 3 - .../20251216_add_channel_verification.sql | 12 -- ...migrate_email_to_channel_verifications.sql | 11 -- migrations/20251218_add_is_admin.sql | 1 - .../20251219_rename_email_confirmed.sql | 6 - ...20251220_rename_notifications_to_comms.sql | 27 ---- .../20251221_oauth_scope_preferences.sql | 12 -- ...0251222_add_did_web_migration_tracking.sql | 2 - migrations/20251223_add_passkeys_totp.sql | 42 ------ src/api/admin/account/update.rs | 12 +- src/api/identity/account.rs | 69 ++++++---- src/api/identity/did.rs | 120 ++++++++++-------- src/api/repo/blob.rs | 4 +- src/api/repo/import.rs | 24 ---- src/api/repo/meta.rs | 8 +- src/api/repo/record/read.rs | 18 ++- src/api/server/session.rs | 22 ++-- src/api/validation.rs | 100 +++++++++++++++ src/oauth/endpoints/authorize.rs | 32 +++-- tests/email_update.rs | 59 ++++----- tests/identity.rs | 9 +- 27 files changed, 408 insertions(+), 346 deletions(-) delete mode 100644 migrations/20251213_performance_indexes.sql delete mode 100644 migrations/20251214_add_prev_data_cid.sql delete mode 100644 migrations/20251215_add_identity_account_fields.sql delete mode 100644 migrations/20251216_add_channel_verification.sql delete mode 100644 migrations/20251217_migrate_email_to_channel_verifications.sql delete mode 100644 migrations/20251218_add_is_admin.sql delete mode 100644 migrations/20251219_rename_email_confirmed.sql delete mode 100644 migrations/20251220_rename_notifications_to_comms.sql delete mode 100644 migrations/20251221_oauth_scope_preferences.sql delete mode 100644 migrations/20251222_add_did_web_migration_tracking.sql delete mode 100644 migrations/20251223_add_passkeys_totp.sql diff --git a/TODO.md b/TODO.md index 01f5ded..e4e6285 100644 --- a/TODO.md +++ b/TODO.md @@ -12,16 +12,16 @@ So like... make the thing unique, make it cool. ### Passkeys and 2FA Modern passwordless authentication using WebAuthn/FIDO2, plus TOTP for defense in depth. -- [ ] passkeys table (id, did, credential_id, public_key, sign_count, created_at, last_used, friendly_name) -- [ ] user_totp table (did, secret_encrypted, verified, created_at, last_used) -- [ ] WebAuthn registration challenge generation and attestation verification -- [ ] TOTP secret generation with QR code setup flow -- [ ] Backup codes (hashed, one-time use) with recovery flow -- [ ] OAuth authorize flow: password -> 2FA (if enabled) -> passkey (as alternative) +- [x] passkeys table (id, did, credential_id, public_key, sign_count, created_at, last_used, friendly_name) +- [x] user_totp table (did, secret_encrypted, verified, created_at, last_used) +- [x] WebAuthn registration challenge generation and attestation verification +- [x] TOTP secret generation with QR code setup flow +- [x] Backup codes (hashed, one-time use) with recovery flow +- [x] OAuth authorize flow: password -> 2FA (if enabled) -> passkey (as alternative) - [ ] Passkey-only account creation (no password) -- [ ] Settings UI for managing passkeys, TOTP, backup codes +- [x] Settings UI for managing passkeys, TOTP, backup codes - [ ] Trusted devices option (remember this browser) -- [ ] Rate limit 2FA attempts +- [x] Rate limit 2FA attempts - [ ] Re-auth for sensitive actions (email change, adding new auth methods) ### Delegated accounts diff --git a/frontend/src/routes/OAuthLogin.svelte b/frontend/src/routes/OAuthLogin.svelte index c2b7373..001815d 100644 --- a/frontend/src/routes/OAuthLogin.svelte +++ b/frontend/src/routes/OAuthLogin.svelte @@ -341,14 +341,14 @@ /> - {#if securityStatusChecked && passkeySupported} + {#if passkeySupported && username.length >= 3}