feat: 添加 TOTP 2FA 功能

This commit is contained in:
mofeng-git
2026-07-17 16:34:06 +08:00
parent fdea52d59d
commit 8bd16df6f8
27 changed files with 1505 additions and 54 deletions

View File

@@ -38,6 +38,7 @@ pub fn create_router(state: Arc<AppState>) -> Router {
let public_routes = Router::new()
.route("/health", get(handlers::health_check))
.route("/auth/login", post(handlers::login))
.route("/auth/login/totp", post(handlers::login_totp))
.route("/setup", get(handlers::setup_status))
.route("/setup/init", post(handlers::setup_init));
@@ -48,6 +49,16 @@ pub fn create_router(state: Arc<AppState>) -> Router {
.route("/auth/check", get(handlers::auth_check))
.route("/auth/password", post(handlers::change_password))
.route("/auth/username", post(handlers::change_username))
.route("/auth/totp", get(handlers::totp_status))
.route(
"/auth/totp/enrollment",
post(handlers::begin_totp_enrollment),
)
.route(
"/auth/totp/enrollment/confirm",
post(handlers::confirm_totp_enrollment),
)
.route("/auth/totp/disable", post(handlers::disable_totp))
.route("/devices", get(handlers::list_devices))
// WebSocket endpoint for real-time events
.route("/ws", any(ws_handler))