feat: add admin user initialization endpoint with request handling

This commit is contained in:
GW_MC
2025-12-18 22:10:50 +08:00
parent 8f2193bed2
commit 08b1a055a4
5 changed files with 218 additions and 4 deletions

View File

@@ -9,6 +9,40 @@
"version": "0.1.0"
},
"paths": {
"/api/auth/init_admin": {
"post": {
"tags": [
"Authentication"
],
"summary": "Initializes the admin user",
"description": "Initializes the admin user if no admin user exists and the correct setup secret is provided.",
"operationId": "init_admin",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminInitRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Admin user initialized successfully"
},
"400": {
"description": "Invalid request payload"
},
"401": {
"description": "Unauthorized: Admin user already exists or invalid setup secret"
},
"500": {
"description": "Internal server error"
}
}
}
},
"/api/auth/login": {
"post": {
"tags": [
@@ -75,6 +109,26 @@
},
"components": {
"schemas": {
"AdminInitRequest": {
"type": "object",
"description": "Login request payload",
"required": [
"username",
"password",
"setup_secret"
],
"properties": {
"password": {
"type": "string"
},
"setup_secret": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"HealthInfo": {
"type": "object",
"description": "System health information",