feat: implement TASK-WP1-02 login sessions

This commit is contained in:
suyx
2026-07-28 16:28:30 +08:00
parent f467e7c09f
commit ee70001d44
20 changed files with 2480 additions and 28 deletions
+441
View File
@@ -639,6 +639,24 @@
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
},
{
"enum": [
"AUTH_ENTRY_REJECTED"
],
"type": "string"
},
{
"enum": [
"AUTH_RATE_LIMITED"
],
"type": "string"
},
{
"enum": [
"AUTH_CSRF_INVALID"
],
"type": "string"
}
]
},
@@ -929,6 +947,110 @@
}
]
},
"LoginCompleteRequest": {
"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"
},
"LoginCompleteResponse": {
"additionalProperties": false,
"properties": {
"audience": {
"enum": [
"user"
],
"type": "string"
},
"credits": {
"$ref": "#/components/schemas/CreditSummary"
},
"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"
},
"user": {
"$ref": "#/components/schemas/AuthenticatedUser"
}
},
"required": [
"audience",
"credits",
"session_expires_at",
"status",
"user"
],
"type": "object"
},
"LoginSendRequest": {
"additionalProperties": false,
"properties": {
"email": {
"maxLength": 320,
"pattern": "^[^@\\s]{1,128}@[^@\\s]{1,190}$",
"type": "string"
}
},
"required": [
"email"
],
"type": "object"
},
"LogoutHeaders": {
"additionalProperties": true,
"properties": {
"idempotency-key": {
"maxLength": 200,
"minLength": 32,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
},
"x-csrf-token": {
"maxLength": 64,
"minLength": 43,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
},
"required": [
"idempotency-key",
"x-csrf-token"
],
"type": "object"
},
"LogoutResponse": {
"additionalProperties": false,
"properties": {
"status": {
"enum": [
"logged_out"
],
"type": "string"
}
},
"required": [
"status"
],
"type": "object"
},
"ModelConfigSseEvent": {
"additionalProperties": false,
"properties": {
@@ -1336,6 +1458,24 @@
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
},
{
"enum": [
"AUTH_ENTRY_REJECTED"
],
"type": "string"
},
{
"enum": [
"AUTH_RATE_LIMITED"
],
"type": "string"
},
{
"enum": [
"AUTH_CSRF_INVALID"
],
"type": "string"
}
]
},
@@ -1424,6 +1564,243 @@
},
"openapi": "3.1.0",
"paths": {
"/api/v1/auth/login/complete": {
"post": {
"operationId": "completeLogin",
"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/LoginCompleteRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LoginCompleteResponse"
}
}
},
"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": [
"Authentication"
]
}
},
"/api/v1/auth/login/send": {
"post": {
"operationId": "sendLoginCode",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LoginSendRequest"
}
}
},
"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": [
"Authentication"
]
}
},
"/api/v1/auth/logout": {
"post": {
"operationId": "logoutUser",
"parameters": [
{
"in": "header",
"name": "idempotency-key",
"required": true,
"schema": {
"maxLength": 200,
"minLength": 32,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
},
{
"in": "header",
"name": "x-csrf-token",
"required": true,
"schema": {
"maxLength": 64,
"minLength": 43,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/LogoutResponse"
}
}
},
"description": "Default Response"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"403": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Authentication"
]
}
},
"/api/v1/auth/register/complete": {
"post": {
"operationId": "completeRegistration",
@@ -1541,6 +1918,16 @@
},
"description": "Default Response"
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
@@ -1869,6 +2256,24 @@
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
},
{
"enum": [
"AUTH_ENTRY_REJECTED"
],
"type": "string"
},
{
"enum": [
"AUTH_RATE_LIMITED"
],
"type": "string"
},
{
"enum": [
"AUTH_CSRF_INVALID"
],
"type": "string"
}
]
},
@@ -2333,6 +2738,24 @@
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
},
{
"enum": [
"AUTH_ENTRY_REJECTED"
],
"type": "string"
},
{
"enum": [
"AUTH_RATE_LIMITED"
],
"type": "string"
},
{
"enum": [
"AUTH_CSRF_INVALID"
],
"type": "string"
}
]
},
@@ -2838,6 +3261,24 @@
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
},
{
"enum": [
"AUTH_ENTRY_REJECTED"
],
"type": "string"
},
{
"enum": [
"AUTH_RATE_LIMITED"
],
"type": "string"
},
{
"enum": [
"AUTH_CSRF_INVALID"
],
"type": "string"
}
]
},