扩展认证逻辑支持 API Token 和动态权限解析,更新配置结构及 Swagger 文档
This commit is contained in:
209
docs/docs.go
209
docs/docs.go
@@ -31,7 +31,7 @@ const docTemplate = `{
|
||||
"AdminAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取系统中所有 API Token 的详详信息(不包含哈希)",
|
||||
"description": "获取系统中所有 API Token 的详细信息(不包含哈希)",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -445,7 +445,19 @@ const docTemplate = `{
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -482,7 +494,19 @@ const docTemplate = `{
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/model.Response"
|
||||
"allOf": [
|
||||
{
|
||||
"$ref": "#/definitions/model.Response"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"data": {
|
||||
"$ref": "#/definitions/config.Config"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
@@ -554,7 +578,12 @@ const docTemplate = `{
|
||||
},
|
||||
"/api/batches": {
|
||||
"post": {
|
||||
"description": "上传一个或多个文件并创建一个提取批次",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "上传一个或多个文件并创建一个提取批次。如果配置了 require_token,则必须提供带 upload scope 的 API Token。",
|
||||
"consumes": [
|
||||
"multipart/form-data"
|
||||
],
|
||||
@@ -634,7 +663,12 @@ const docTemplate = `{
|
||||
},
|
||||
"/api/batches/text": {
|
||||
"post": {
|
||||
"description": "中转一段长文本内容并创建一个提取批次",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "中转一段长文本内容并创建一个提取批次。如果配置了 require_token,则必须提供带 upload scope 的 API Token。",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -692,7 +726,12 @@ const docTemplate = `{
|
||||
},
|
||||
"/api/batches/{pickup_code}": {
|
||||
"get": {
|
||||
"description": "根据取件码获取文件批次详详情和文件列表",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "根据取件码获取文件批次详细信息和文件列表。可选提供带 pickup scope 的 API Token。",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -739,7 +778,12 @@ const docTemplate = `{
|
||||
},
|
||||
"/api/batches/{pickup_code}/download": {
|
||||
"get": {
|
||||
"description": "根据取件码将批次内的所有文件打包为 ZIP 格式一次性下载",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "根据取件码将批次内的所有文件打包为 ZIP 格式一次性下载。可选提供带 pickup scope 的 API Token。",
|
||||
"produces": [
|
||||
"application/zip"
|
||||
],
|
||||
@@ -806,7 +850,12 @@ const docTemplate = `{
|
||||
},
|
||||
"/api/files/{file_id}/download": {
|
||||
"get": {
|
||||
"description": "根据文件 ID 下载单个文件",
|
||||
"security": [
|
||||
{
|
||||
"APITokenAuth": []
|
||||
}
|
||||
],
|
||||
"description": "根据文件 ID 下载单个文件。可选提供带 pickup scope 的 API Token。",
|
||||
"produces": [
|
||||
"application/octet-stream"
|
||||
],
|
||||
@@ -940,13 +989,16 @@ const docTemplate = `{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -954,23 +1006,53 @@ const docTemplate = `{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -978,6 +1060,7 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"description": "数据库文件路径",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -985,16 +1068,20 @@ const docTemplate = `{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -1003,9 +1090,11 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"description": {
|
||||
"description": "站点描述",
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"description": "站点名称",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -1017,6 +1106,7 @@ const docTemplate = `{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"path": {
|
||||
"description": "本地存储路径",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -1024,42 +1114,53 @@ const docTemplate = `{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -1069,14 +1170,21 @@ const docTemplate = `{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1228,25 +1336,50 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
@@ -1291,8 +1424,14 @@ const docTemplate = `{
|
||||
}
|
||||
},
|
||||
"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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -61,49 +61,71 @@ definitions:
|
||||
type: object
|
||||
config.APITokenConfig:
|
||||
properties:
|
||||
allowAdminAPI:
|
||||
allow_admin_api:
|
||||
description: 是否允许 API Token 访问管理接口
|
||||
type: boolean
|
||||
enabled:
|
||||
description: 是否启用 API Token
|
||||
type: boolean
|
||||
maxTokens:
|
||||
max_tokens:
|
||||
description: 最大 Token 数量
|
||||
type: integer
|
||||
type: object
|
||||
config.Config:
|
||||
properties:
|
||||
apitoken:
|
||||
$ref: '#/definitions/config.APITokenConfig'
|
||||
api_token:
|
||||
allOf:
|
||||
- $ref: '#/definitions/config.APITokenConfig'
|
||||
description: API Token 设置
|
||||
database:
|
||||
$ref: '#/definitions/config.DatabaseConfig'
|
||||
allOf:
|
||||
- $ref: '#/definitions/config.DatabaseConfig'
|
||||
description: 数据库设置
|
||||
security:
|
||||
$ref: '#/definitions/config.SecurityConfig'
|
||||
allOf:
|
||||
- $ref: '#/definitions/config.SecurityConfig'
|
||||
description: 安全设置
|
||||
site:
|
||||
$ref: '#/definitions/config.SiteConfig'
|
||||
allOf:
|
||||
- $ref: '#/definitions/config.SiteConfig'
|
||||
description: 站点设置
|
||||
storage:
|
||||
$ref: '#/definitions/config.StorageConfig'
|
||||
allOf:
|
||||
- $ref: '#/definitions/config.StorageConfig'
|
||||
description: 存储设置
|
||||
upload:
|
||||
$ref: '#/definitions/config.UploadConfig'
|
||||
allOf:
|
||||
- $ref: '#/definitions/config.UploadConfig'
|
||||
description: 上传设置
|
||||
type: object
|
||||
config.DatabaseConfig:
|
||||
properties:
|
||||
path:
|
||||
description: 数据库文件路径
|
||||
type: string
|
||||
type: object
|
||||
config.SecurityConfig:
|
||||
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
|
||||
type: object
|
||||
config.SiteConfig:
|
||||
properties:
|
||||
description:
|
||||
description: 站点描述
|
||||
type: string
|
||||
name:
|
||||
description: 站点名称
|
||||
type: string
|
||||
type: object
|
||||
config.StorageConfig:
|
||||
@@ -111,45 +133,63 @@ definitions:
|
||||
local:
|
||||
properties:
|
||||
path:
|
||||
description: 本地存储路径
|
||||
type: string
|
||||
type: object
|
||||
s3:
|
||||
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: object
|
||||
type:
|
||||
description: '存储类型: local, webdav, s3'
|
||||
type: string
|
||||
webDAV:
|
||||
webdav:
|
||||
properties:
|
||||
password:
|
||||
description: WebDAV 密码
|
||||
type: string
|
||||
root:
|
||||
description: WebDAV 根目录
|
||||
type: string
|
||||
url:
|
||||
description: WebDAV 地址
|
||||
type: string
|
||||
username:
|
||||
description: WebDAV 用户名
|
||||
type: string
|
||||
type: object
|
||||
type: object
|
||||
config.UploadConfig:
|
||||
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
|
||||
type: object
|
||||
model.APIToken:
|
||||
properties:
|
||||
@@ -250,18 +290,34 @@ definitions:
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
public.PublicAPITokenConfig:
|
||||
properties:
|
||||
enabled:
|
||||
type: boolean
|
||||
type: object
|
||||
public.PublicConfig:
|
||||
properties:
|
||||
api_token:
|
||||
properties:
|
||||
enabled:
|
||||
type: boolean
|
||||
type: object
|
||||
$ref: '#/definitions/public.PublicAPITokenConfig'
|
||||
security:
|
||||
$ref: '#/definitions/public.PublicSecurityConfig'
|
||||
site:
|
||||
$ref: '#/definitions/config.SiteConfig'
|
||||
storage:
|
||||
$ref: '#/definitions/public.PublicStorageConfig'
|
||||
upload:
|
||||
$ref: '#/definitions/config.UploadConfig'
|
||||
type: object
|
||||
public.PublicSecurityConfig:
|
||||
properties:
|
||||
pickup_code_length:
|
||||
type: integer
|
||||
type: object
|
||||
public.PublicStorageConfig:
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
public.UploadResponse:
|
||||
properties:
|
||||
batch_id:
|
||||
@@ -306,7 +362,7 @@ info:
|
||||
paths:
|
||||
/admin/api-tokens:
|
||||
get:
|
||||
description: 获取系统中所有 API Token 的详详信息(不包含哈希)
|
||||
description: 获取系统中所有 API Token 的详细信息(不包含哈希)
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
@@ -553,7 +609,12 @@ paths:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/config.Config'
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.Response'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/config.Config'
|
||||
type: object
|
||||
security:
|
||||
- AdminAuth: []
|
||||
summary: 获取完整配置
|
||||
@@ -576,7 +637,12 @@ paths:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/model.Response'
|
||||
allOf:
|
||||
- $ref: '#/definitions/model.Response'
|
||||
- properties:
|
||||
data:
|
||||
$ref: '#/definitions/config.Config'
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
@@ -625,7 +691,8 @@ paths:
|
||||
post:
|
||||
consumes:
|
||||
- multipart/form-data
|
||||
description: 上传一个或多个文件并创建一个提取批次
|
||||
description: 上传一个或多个文件并创建一个提取批次。如果配置了 require_token,则必须提供带 upload scope 的 API
|
||||
Token。
|
||||
parameters:
|
||||
- description: 文件列表
|
||||
in: formData
|
||||
@@ -668,12 +735,14 @@ paths:
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Response'
|
||||
security:
|
||||
- APITokenAuth: []
|
||||
summary: 上传文件
|
||||
tags:
|
||||
- Public
|
||||
/api/batches/{pickup_code}:
|
||||
get:
|
||||
description: 根据取件码获取文件批次详详情和文件列表
|
||||
description: 根据取件码获取文件批次详细信息和文件列表。可选提供带 pickup scope 的 API Token。
|
||||
parameters:
|
||||
- description: 取件码
|
||||
in: path
|
||||
@@ -696,12 +765,14 @@ paths:
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/model.Response'
|
||||
security:
|
||||
- APITokenAuth: []
|
||||
summary: 获取批次信息
|
||||
tags:
|
||||
- Public
|
||||
/api/batches/{pickup_code}/download:
|
||||
get:
|
||||
description: 根据取件码将批次内的所有文件打包为 ZIP 格式一次性下载
|
||||
description: 根据取件码将批次内的所有文件打包为 ZIP 格式一次性下载。可选提供带 pickup scope 的 API Token。
|
||||
parameters:
|
||||
- description: 取件码
|
||||
in: path
|
||||
@@ -719,6 +790,8 @@ paths:
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/model.Response'
|
||||
security:
|
||||
- APITokenAuth: []
|
||||
summary: 批量下载文件
|
||||
tags:
|
||||
- Public
|
||||
@@ -726,7 +799,8 @@ paths:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 中转一段长文本内容并创建一个提取批次
|
||||
description: 中转一段长文本内容并创建一个提取批次。如果配置了 require_token,则必须提供带 upload scope 的 API
|
||||
Token。
|
||||
parameters:
|
||||
- description: 文本内容及配置
|
||||
in: body
|
||||
@@ -754,6 +828,8 @@ paths:
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/model.Response'
|
||||
security:
|
||||
- APITokenAuth: []
|
||||
summary: 发送长文本
|
||||
tags:
|
||||
- Public
|
||||
@@ -777,7 +853,7 @@ paths:
|
||||
- Public
|
||||
/api/files/{file_id}/download:
|
||||
get:
|
||||
description: 根据文件 ID 下载单个文件
|
||||
description: 根据文件 ID 下载单个文件。可选提供带 pickup scope 的 API Token。
|
||||
parameters:
|
||||
- description: 文件 ID (UUID)
|
||||
in: path
|
||||
@@ -799,12 +875,21 @@ paths:
|
||||
description: Gone
|
||||
schema:
|
||||
$ref: '#/definitions/model.Response'
|
||||
security:
|
||||
- APITokenAuth: []
|
||||
summary: 下载单个文件
|
||||
tags:
|
||||
- Public
|
||||
securityDefinitions:
|
||||
APITokenAuth:
|
||||
description: Type "Bearer <API-Token>" to authenticate. Required scope depends
|
||||
on the endpoint.
|
||||
in: header
|
||||
name: Authorization
|
||||
type: apiKey
|
||||
AdminAuth:
|
||||
description: Type "Bearer <your-jwt-token>" to authenticate.
|
||||
description: Type "Bearer <JWT-Token>" or "Bearer <API-Token>" to authenticate.
|
||||
API Token must have 'admin' scope.
|
||||
in: header
|
||||
name: Authorization
|
||||
type: apiKey
|
||||
|
||||
Reference in New Issue
Block a user