add jwt config

This commit is contained in:
2025-12-18 19:58:04 +02:00
parent 7e581d99f5
commit a1f6c1ffa9

View File

@@ -32,14 +32,21 @@ type FuncConfig struct {
}
type Auth struct {
SignAlg string `mapstructure:"sign_alg"`
HMACSecretPath string `mapstructure:"hmac_secret_path"`
RefreshTokenTTL time.Duration `mapstructure:"refresh_token_ttl"`
AccessTokenTTL time.Duration `mapstructure:"access_token_ttl"`
}
type Data struct {
DataPath string `mapstructure:"data_dir"`
}
type Config struct {
Server ServerConfig `mapstructure:"server"`
Functions FuncConfig `mapstructure:"functions"`
Auth Auth `mapstructure:"auth"`
Data Data `mapstructure:"data"`
}
var configPath atomic.Value // string
@@ -54,10 +61,14 @@ var defaults = map[string]any{
"server.block.enabled": true,
"server.block.block_dir": "./blocks",
"data.data_dir": "./data",
"functions.func_dir": "./functions",
"auth.refresh_token_ttl": 24 * time.Hour,
"auth.access_token_ttl": 15 * time.Minute,
"auth.sign_alg": "HS256",
"auth.hmac_secret_path": "./secret/hmac_secret",
}
func read(cfg *Config) error {