brewlog/src/domain/users.rs
Jon Seager 03e03d87d9
feat(auth): replace password auth with WebAuthn passkeys
Replace username/password authentication with FIDO2/WebAuthn passkey-based
auth using webauthn-rs. Sessions and bearer tokens are unchanged — only the
way they are created changes.

- Add webauthn-rs, uuid, open, url deps; remove argon2, rpassword
- Add passkey_credentials and registration_tokens tables (migrations 17-18)
- Add domain entities, typed IDs, and repository traits for passkeys/tokens
- Add SQL repository implementations for passkeys and registration tokens
- Add ChallengeStore for in-memory WebAuthn ceremony state
- Add WebAuthn route handlers (register/auth start+finish ceremonies)
- Add CLI browser handoff for token creation (opens browser, local callback)
- Replace login form with "Sign in with Passkey" button
- Add registration page for first-user bootstrap via one-time token
- Replace BREWLOG_ADMIN_USERNAME/PASSWORD with BREWLOG_RP_ID/RP_ORIGIN
- Change default BREWLOG_URL from 127.0.0.1 to localhost (WebAuthn requires it)
2026-02-05 11:00:07 +00:00

35 lines
702 B
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use crate::domain::ids::UserId;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct User {
pub id: UserId,
pub username: String,
pub uuid: String,
pub created_at: DateTime<Utc>,
}
#[derive(Debug, Clone)]
pub struct NewUser {
pub username: String,
pub uuid: String,
}
impl User {
pub fn new(id: UserId, username: String, uuid: String, created_at: DateTime<Utc>) -> Self {
Self {
id,
username,
uuid,
created_at,
}
}
}
impl NewUser {
pub fn new(username: String, uuid: String) -> Self {
Self { username, uuid }
}
}