feat: implement TASK-WP1-04 admin security

This commit is contained in:
suyx
2026-07-28 18:32:50 +08:00
parent 66fe3b763a
commit 03f1509de7
29 changed files with 2344 additions and 40 deletions
+347
View File
@@ -1,6 +1,160 @@
{
"components": {
"schemas": {
"AdminAuthenticatedUser": {
"additionalProperties": false,
"properties": {
"role": {
"enum": [
"super_admin"
],
"type": "string"
},
"status": {
"enum": [
"active"
],
"type": "string"
},
"user_id": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
"type": "string"
}
},
"required": [
"role",
"status",
"user_id"
],
"type": "object"
},
"AdminLoginCompleteRequest": {
"additionalProperties": false,
"properties": {
"registration_id": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
"type": "string"
},
"verification_code": {
"pattern": "^[0-9]{6}$",
"type": "string"
}
},
"required": [
"registration_id",
"verification_code"
],
"type": "object"
},
"AdminLoginCompleteResponse": {
"additionalProperties": false,
"properties": {
"admin": {
"$ref": "#/components/schemas/AdminAuthenticatedUser"
},
"audience": {
"enum": [
"admin"
],
"type": "string"
},
"session_expires_at": {
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
"type": "string"
},
"status": {
"enum": [
"authenticated"
],
"type": "string"
}
},
"required": [
"admin",
"audience",
"session_expires_at",
"status"
],
"type": "object"
},
"AdminLoginSendRequest": {
"additionalProperties": false,
"properties": {
"email": {
"maxLength": 320,
"pattern": "^[^@\\s]{1,128}@[^@\\s]{1,190}$",
"type": "string"
}
},
"required": [
"email"
],
"type": "object"
},
"AdminSessionResponse": {
"additionalProperties": false,
"properties": {
"acknowledged_private_content_notice_version": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"admin": {
"$ref": "#/components/schemas/AdminAuthenticatedUser"
},
"audience": {
"enum": [
"admin"
],
"type": "string"
},
"authenticated": {
"enum": [
true
],
"type": "boolean"
},
"csrf_token": {
"maxLength": 64,
"minLength": 43,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
},
"current_private_content_notice_version": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"expires_at": {
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
"type": "string"
},
"notice_acknowledged": {
"type": "boolean"
}
},
"required": [
"acknowledged_private_content_notice_version",
"admin",
"audience",
"authenticated",
"csrf_token",
"current_private_content_notice_version",
"expires_at",
"notice_acknowledged"
],
"type": "object"
},
"AuthenticatedUser": {
"additionalProperties": false,
"properties": {
@@ -1564,6 +1718,199 @@
},
"openapi": "3.1.0",
"paths": {
"/api/v1/admin-auth/login/complete": {
"post": {
"operationId": "completeAdminLogin",
"parameters": [
{
"in": "header",
"name": "idempotency-key",
"required": true,
"schema": {
"maxLength": 200,
"minLength": 32,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminLoginCompleteRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminLoginCompleteResponse"
}
}
},
"description": "Default Response"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"409": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Admin Authentication"
]
}
},
"/api/v1/admin-auth/login/send": {
"post": {
"operationId": "sendAdminLoginCode",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminLoginSendRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RegistrationSendResponse"
}
}
},
"description": "Default Response"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"409": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Admin Authentication"
]
}
},
"/api/v1/admin-auth/session": {
"get": {
"operationId": "getAdminSession",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminSessionResponse"
}
}
},
"description": "Default Response"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Admin Authentication"
]
}
},
"/api/v1/auth/login/complete": {
"post": {
"operationId": "completeLogin",