backend signup

This commit is contained in:
2025-10-30 01:15:26 +01:00
parent 4d14d5a3d4
commit 84f4cd05f4
8 changed files with 458 additions and 142 deletions
+38 -8
View File
@@ -8,7 +8,8 @@ use uuid::Uuid;
paths(
doc::health_check,
doc::login,
doc::signup,
doc::signup_start,
doc::signup_finish,
doc::refresh,
doc::logout,
doc::me,
@@ -60,7 +61,9 @@ use uuid::Uuid;
components(
schemas(
schemas::LoginRequest,
schemas::SignupRequest,
schemas::SignupStartRequest,
schemas::SignupStartResponse,
schemas::SignupFinishRequest,
schemas::AccessTokenResponse,
schemas::TenantSnippet,
schemas::TenantSelectionResponse,
@@ -167,16 +170,29 @@ mod doc {
#[utoipa::path(
post,
path = "/api/auth/signup",
request_body = SignupRequest,
path = "/api/auth/signup/start",
request_body = SignupStartRequest,
responses(
(status = 200, description = "Signup succeeded", body = LoginResponseVariants),
(status = 200, description = "Signup challenge created", body = SignupStartResponse),
(status = 400, description = "Invalid signup request"),
(status = 409, description = "Username already exists")
),
tag = "Auth"
)]
pub(super) fn signup() {}
pub(super) fn signup_start() {}
#[utoipa::path(
post,
path = "/api/auth/signup/finish",
request_body = SignupFinishRequest,
responses(
(status = 200, description = "Signup completed", body = LoginResponseVariants),
(status = 400, description = "Invalid signup completion"),
(status = 409, description = "Username already exists")
),
tag = "Auth"
)]
pub(super) fn signup_finish() {}
#[utoipa::path(
post,
@@ -678,6 +694,7 @@ pub mod schemas {
AuthenticationChallengeResponse, PasskeyLoginFinishPayload, PasskeyLoginStartPayload,
PasskeyRegistrationFinishPayload, PasskeySummary, RegistrationChallengeResponse,
};
use webauthn_rs::prelude::RegisterPublicKeyCredential;
#[derive(Serialize, Deserialize, ToSchema)]
pub struct LoginRequest {
@@ -688,9 +705,22 @@ pub mod schemas {
}
#[derive(Serialize, Deserialize, ToSchema)]
pub struct SignupRequest {
pub struct SignupStartRequest {
pub username: String,
pub password: String,
}
#[derive(Serialize, Deserialize, ToSchema)]
pub struct SignupStartResponse {
pub signup_token: String,
pub challenge: RegistrationChallengeResponse,
}
#[derive(Serialize, Deserialize, ToSchema)]
pub struct SignupFinishRequest {
pub signup_token: String,
pub credential: RegisterPublicKeyCredential,
#[schema(nullable)]
pub nickname: Option<String>,
}
#[derive(Serialize, Deserialize, ToSchema)]