扩展认证逻辑支持 API Token 和动态权限解析,更新配置结构及 Swagger 文档
This commit is contained in:
@@ -8,61 +8,62 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Site SiteConfig `yaml:"site"`
|
||||
Security SecurityConfig `yaml:"security"`
|
||||
Upload UploadConfig `yaml:"upload"`
|
||||
Storage StorageConfig `yaml:"storage"`
|
||||
APIToken APITokenConfig `yaml:"api_token"`
|
||||
Database DatabaseConfig `yaml:"database"`
|
||||
Site SiteConfig `yaml:"site" json:"site"` // 站点设置
|
||||
Security SecurityConfig `yaml:"security" json:"security"` // 安全设置
|
||||
Upload UploadConfig `yaml:"upload" json:"upload"` // 上传设置
|
||||
Storage StorageConfig `yaml:"storage" json:"storage"` // 存储设置
|
||||
APIToken APITokenConfig `yaml:"api_token" json:"api_token"` // API Token 设置
|
||||
Database DatabaseConfig `yaml:"database" json:"database"` // 数据库设置
|
||||
}
|
||||
|
||||
type SiteConfig struct {
|
||||
Name string `yaml:"name"`
|
||||
Description string `yaml:"description"`
|
||||
Name string `yaml:"name" json:"name"` // 站点名称
|
||||
Description string `yaml:"description" json:"description"` // 站点描述
|
||||
}
|
||||
|
||||
type SecurityConfig struct {
|
||||
AdminPasswordHash string `yaml:"admin_password_hash"`
|
||||
PickupCodeLength int `yaml:"pickup_code_length"`
|
||||
PickupFailLimit int `yaml:"pickup_fail_limit"`
|
||||
JWTSecret string `yaml:"jwt_secret"`
|
||||
AdminPasswordHash string `yaml:"admin_password_hash" json:"admin_password_hash"` // 管理员密码哈希 (bcrypt)
|
||||
PickupCodeLength int `yaml:"pickup_code_length" json:"pickup_code_length"` // 取件码长度
|
||||
PickupFailLimit int `yaml:"pickup_fail_limit" json:"pickup_fail_limit"` // 取件失败尝试限制
|
||||
JWTSecret string `yaml:"jwt_secret" json:"jwt_secret"` // JWT 签名密钥
|
||||
}
|
||||
|
||||
type UploadConfig struct {
|
||||
MaxFileSizeMB int64 `yaml:"max_file_size_mb"`
|
||||
MaxBatchFiles int `yaml:"max_batch_files"`
|
||||
MaxRetentionDays int `yaml:"max_retention_days"`
|
||||
MaxFileSizeMB int64 `yaml:"max_file_size_mb" json:"max_file_size_mb"` // 单个文件最大大小 (MB)
|
||||
MaxBatchFiles int `yaml:"max_batch_files" json:"max_batch_files"` // 每个批次最大文件数
|
||||
MaxRetentionDays int `yaml:"max_retention_days" json:"max_retention_days"` // 最大保留天数
|
||||
RequireToken bool `yaml:"require_token" json:"require_token"` // 是否强制要求上传 Token
|
||||
}
|
||||
|
||||
type StorageConfig struct {
|
||||
Type string `yaml:"type"`
|
||||
Type string `yaml:"type" json:"type"` // 存储类型: local, webdav, s3
|
||||
Local struct {
|
||||
Path string `yaml:"path"`
|
||||
} `yaml:"local"`
|
||||
Path string `yaml:"path" json:"path"` // 本地存储路径
|
||||
} `yaml:"local" json:"local"`
|
||||
WebDAV struct {
|
||||
URL string `yaml:"url"`
|
||||
Username string `yaml:"username"`
|
||||
Password string `yaml:"password"`
|
||||
Root string `yaml:"root"`
|
||||
} `yaml:"webdav"`
|
||||
URL string `yaml:"url" json:"url"` // WebDAV 地址
|
||||
Username string `yaml:"username" json:"username"` // WebDAV 用户名
|
||||
Password string `yaml:"password" json:"password"` // WebDAV 密码
|
||||
Root string `yaml:"root" json:"root"` // WebDAV 根目录
|
||||
} `yaml:"webdav" json:"webdav"`
|
||||
S3 struct {
|
||||
Endpoint string `yaml:"endpoint"`
|
||||
Region string `yaml:"region"`
|
||||
AccessKey string `yaml:"access_key"`
|
||||
SecretKey string `yaml:"secret_key"`
|
||||
Bucket string `yaml:"bucket"`
|
||||
UseSSL bool `yaml:"use_ssl"`
|
||||
} `yaml:"s3"`
|
||||
Endpoint string `yaml:"endpoint" json:"endpoint"` // S3 端点
|
||||
Region string `yaml:"region" json:"region"` // S3 区域
|
||||
AccessKey string `yaml:"access_key" json:"access_key"` // S3 Access Key
|
||||
SecretKey string `yaml:"secret_key" json:"secret_key"` // S3 Secret Key
|
||||
Bucket string `yaml:"bucket" json:"bucket"` // S3 Bucket
|
||||
UseSSL bool `yaml:"use_ssl" json:"use_ssl"` // 是否使用 SSL
|
||||
} `yaml:"s3" json:"s3"`
|
||||
}
|
||||
|
||||
type APITokenConfig struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
AllowAdminAPI bool `yaml:"allow_admin_api"`
|
||||
MaxTokens int `yaml:"max_tokens"`
|
||||
Enabled bool `yaml:"enabled" json:"enabled"` // 是否启用 API Token
|
||||
AllowAdminAPI bool `yaml:"allow_admin_api" json:"allow_admin_api"` // 是否允许 API Token 访问管理接口
|
||||
MaxTokens int `yaml:"max_tokens" json:"max_tokens"` // 最大 Token 数量
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
Path string `yaml:"path"`
|
||||
Path string `yaml:"path" json:"path"` // 数据库文件路径
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user