扩展认证逻辑支持 API Token 和动态权限解析,更新配置结构及 Swagger 文档
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
"AdminAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取系统中所有 API Token 的详详信息(不包含哈希)",
|
||||
"description": "获取系统中所有 API Token 的详细信息(不包含哈希)",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -438,7 +438,19 @@
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -475,7 +487,19 @@
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Response"
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
@@ -547,7 +571,12 @@
|
||||
},
|
||||
"/api/batches": {
|
||||
"post": {
|
||||
"description": "上传一个或多个文件并创建一个提取批次",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "上传一个或多个文件并创建一个提取批次。如果配置了 require_token,则必须提供带 upload scope 的 API Token。",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
@@ -627,7 +656,12 @@
|
||||
},
|
||||
"/api/batches/text": {
|
||||
"post": {
|
||||
"description": "中转一段长文本内容并创建一个提取批次",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "中转一段长文本内容并创建一个提取批次。如果配置了 require_token,则必须提供带 upload scope 的 API Token。",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -685,7 +719,12 @@
|
||||
},
|
||||
"/api/batches/{pickup_code}": {
|
||||
"get": {
|
||||
"description": "根据取件码获取文件批次详详情和文件列表",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "根据取件码获取文件批次详细信息和文件列表。可选提供带 pickup scope 的 API Token。",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -732,7 +771,12 @@
|
||||
},
|
||||
"/api/batches/{pickup_code}/download": {
|
||||
"get": {
|
||||
"description": "根据取件码将批次内的所有文件打包为 ZIP 格式一次性下载",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "根据取件码将批次内的所有文件打包为 ZIP 格式一次性下载。可选提供带 pickup scope 的 API Token。",
|
||||
"produces": [
|
||||
"application/zip"
|
||||
],
|
||||
@@ -799,7 +843,12 @@
|
||||
},
|
||||
"/api/files/{file_id}/download": {
|
||||
"get": {
|
||||
"description": "根据文件 ID 下载单个文件",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "根据文件 ID 下载单个文件。可选提供带 pickup scope 的 API Token。",
|
||||
"produces": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
@@ -933,13 +982,16 @@
|
||||
"config.APITokenConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"allowAdminAPI": {
|
||||
"allow_admin_api": {
|
||||
"description": "是否允许 API Token 访问管理接口",
|
||||
"type": "boolean"
|
||||
},
|
||||
"enabled": {
|
||||
"description": "是否启用 API Token",
|
||||
"type": "boolean"
|
||||
},
|
||||
"maxTokens": {
|
||||
"max_tokens": {
|
||||
"description": "最大 Token 数量",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
@@ -947,23 +999,53 @@
|
||||
"config.Config": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"apitoken": {
|
||||
"$ref": "#/definitions/config.APITokenConfig"
|
||||
"api_token": {
|
||||
"description": "API Token 设置",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/config.APITokenConfig"
|
||||
}
|
||||
]
|
||||
},
|
||||
"database": {
|
||||
"$ref": "#/definitions/config.DatabaseConfig"
|
||||
"description": "数据库设置",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/config.DatabaseConfig"
|
||||
}
|
||||
]
|
||||
},
|
||||
"security": {
|
||||
"$ref": "#/definitions/config.SecurityConfig"
|
||||
"description": "安全设置",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/config.SecurityConfig"
|
||||
}
|
||||
]
|
||||
},
|
||||
"site": {
|
||||
"$ref": "#/definitions/config.SiteConfig"
|
||||
"description": "站点设置",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/config.SiteConfig"
|
||||
}
|
||||
]
|
||||
},
|
||||
"storage": {
|
||||
"$ref": "#/definitions/config.StorageConfig"
|
||||
"description": "存储设置",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/config.StorageConfig"
|
||||
}
|
||||
]
|
||||
},
|
||||
"upload": {
|
||||
"$ref": "#/definitions/config.UploadConfig"
|
||||
"description": "上传设置",
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/config.UploadConfig"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -971,6 +1053,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"description": "数据库文件路径",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -978,16 +1061,20 @@
|
||||
"config.SecurityConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"adminPasswordHash": {
|
||||
"admin_password_hash": {
|
||||
"description": "管理员密码哈希 (bcrypt)",
|
||||
"type": "string"
|
||||
},
|
||||
"jwtsecret": {
|
||||
"jwt_secret": {
|
||||
"description": "JWT 签名密钥",
|
||||
"type": "string"
|
||||
},
|
||||
"pickupCodeLength": {
|
||||
"pickup_code_length": {
|
||||
"description": "取件码长度",
|
||||
"type": "integer"
|
||||
},
|
||||
"pickupFailLimit": {
|
||||
"pickup_fail_limit": {
|
||||
"description": "取件失败尝试限制",
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
@@ -996,9 +1083,11 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {
|
||||
"description": "站点描述",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "站点名称",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -1010,6 +1099,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"description": "本地存储路径",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -1017,42 +1107,53 @@
|
||||
"s3": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"accessKey": {
|
||||
"access_key": {
|
||||
"description": "S3 Access Key",
|
||||
"type": "string"
|
||||
},
|
||||
"bucket": {
|
||||
"description": "S3 Bucket",
|
||||
"type": "string"
|
||||
},
|
||||
"endpoint": {
|
||||
"description": "S3 端点",
|
||||
"type": "string"
|
||||
},
|
||||
"region": {
|
||||
"description": "S3 区域",
|
||||
"type": "string"
|
||||
},
|
||||
"secretKey": {
|
||||
"secret_key": {
|
||||
"description": "S3 Secret Key",
|
||||
"type": "string"
|
||||
},
|
||||
"useSSL": {
|
||||
"use_ssl": {
|
||||
"description": "是否使用 SSL",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"description": "存储类型: local, webdav, s3",
|
||||
"type": "string"
|
||||
},
|
||||
"webDAV": {
|
||||
"webdav": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"password": {
|
||||
"description": "WebDAV 密码",
|
||||
"type": "string"
|
||||
},
|
||||
"root": {
|
||||
"description": "WebDAV 根目录",
|
||||
"type": "string"
|
||||
},
|
||||
"url": {
|
||||
"description": "WebDAV 地址",
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"description": "WebDAV 用户名",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -1062,14 +1163,21 @@
|
||||
"config.UploadConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"maxBatchFiles": {
|
||||
"max_batch_files": {
|
||||
"description": "每个批次最大文件数",
|
||||
"type": "integer"
|
||||
},
|
||||
"maxFileSizeMB": {
|
||||
"max_file_size_mb": {
|
||||
"description": "单个文件最大大小 (MB)",
|
||||
"type": "integer"
|
||||
},
|
||||
"maxRetentionDays": {
|
||||
"max_retention_days": {
|
||||
"description": "最大保留天数",
|
||||
"type": "integer"
|
||||
},
|
||||
"require_token": {
|
||||
"description": "是否强制要求上传 Token",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1221,25 +1329,50 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"public.PublicAPITokenConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"public.PublicConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"api_token": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"enabled": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
"$ref": "#/definitions/public.PublicAPITokenConfig"
|
||||
},
|
||||
"security": {
|
||||
"$ref": "#/definitions/public.PublicSecurityConfig"
|
||||
},
|
||||
"site": {
|
||||
"$ref": "#/definitions/config.SiteConfig"
|
||||
},
|
||||
"storage": {
|
||||
"$ref": "#/definitions/public.PublicStorageConfig"
|
||||
},
|
||||
"upload": {
|
||||
"$ref": "#/definitions/config.UploadConfig"
|
||||
}
|
||||
}
|
||||
},
|
||||
"public.PublicSecurityConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"pickup_code_length": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"public.PublicStorageConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"public.UploadResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1284,8 +1417,14 @@
|
||||
}
|
||||
},
|
||||
"securityDefinitions": {
|
||||
"APITokenAuth": {
|
||||
"description": "Type \"Bearer \u003cAPI-Token\u003e\" to authenticate. Required scope depends on the endpoint.",
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
},
|
||||
"AdminAuth": {
|
||||
"description": "Type \"Bearer \u003cyour-jwt-token\u003e\" to authenticate.",
|
||||
"description": "Type \"Bearer \u003cJWT-Token\u003e\" or \"Bearer \u003cAPI-Token\u003e\" to authenticate. API Token must have 'admin' scope.",
|
||||
"type": "apiKey",
|
||||
"name": "Authorization",
|
||||
"in": "header"
|
||||
|
||||
Reference in New Issue
Block a user