- 修正 RustFS 端点地址为 192.168.1.154:9000(对应服务器实际部署) - 移除 config.go 中硬编码的 AccessKey/SecretKey 默认值,改为环境变量传入 - 移除 middleware/auth.go 中硬编码的 API_KEY_VALUE 常量,改为参数注入 - 新增 Config.AuthAPIKey 字段,通过 AUTH_API_KEY 环境变量配置 - 移除 login.html 页面上的密钥格式提示,防止信息泄露 - docker-compose.yml 补全 RustFS 连接所需的环境变量 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
788 B
Go
31 lines
788 B
Go
package common
|
|
|
|
import "os"
|
|
|
|
type Config struct {
|
|
RustFSEndpoint string
|
|
RustFSAccessKeyID string
|
|
RustFSSecretAccessKey string
|
|
RustFSRegion string
|
|
ServerPort string
|
|
AuthAPIKey string
|
|
}
|
|
|
|
func LoadConfig() *Config {
|
|
return &Config{
|
|
RustFSEndpoint: getEnv("RUSTFS_ENDPOINT_URL", "http://192.168.1.154:9000"),
|
|
RustFSAccessKeyID: getEnv("RUSTFS_ACCESS_KEY_ID", ""),
|
|
RustFSSecretAccessKey: getEnv("RUSTFS_SECRET_ACCESS_KEY", ""),
|
|
RustFSRegion: getEnv("RUSTFS_REGION", "us-east-1"),
|
|
ServerPort: getEnv("SERVER_PORT", "8080"),
|
|
AuthAPIKey: getEnv("AUTH_API_KEY", ""),
|
|
}
|
|
}
|
|
|
|
func getEnv(key, fallback string) string {
|
|
if value, ok := os.LookupEnv(key); ok {
|
|
return value
|
|
}
|
|
return fallback
|
|
}
|