brewlog/src/domain/passkey_credentials.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

31 lines
749 B
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use crate::domain::ids::{PasskeyCredentialId, UserId};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PasskeyCredential {
pub id: PasskeyCredentialId,
pub user_id: UserId,
pub credential_json: String,
pub name: String,
pub created_at: DateTime<Utc>,
pub last_used_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone)]
pub struct NewPasskeyCredential {
pub user_id: UserId,
pub credential_json: String,
pub name: String,
}
impl NewPasskeyCredential {
pub fn new(user_id: UserId, credential_json: String, name: String) -> Self {
Self {
user_id,
credential_json,
name,
}
}
}