mirror of
https://github.com/ferdzo/fs.git
synced 2026-04-04 20:56:25 +00:00
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
package auth
|
|
|
|
import (
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
type Config struct {
|
|
Enabled bool
|
|
Region string
|
|
ClockSkew time.Duration
|
|
MaxPresignDuration time.Duration
|
|
MasterKey string
|
|
BootstrapAccessKey string
|
|
BootstrapSecretKey string
|
|
BootstrapPolicy string
|
|
}
|
|
|
|
func ConfigFromValues(
|
|
enabled bool,
|
|
region string,
|
|
skew time.Duration,
|
|
maxPresign time.Duration,
|
|
masterKey string,
|
|
bootstrapAccessKey string,
|
|
bootstrapSecretKey string,
|
|
bootstrapPolicy string,
|
|
) Config {
|
|
region = strings.TrimSpace(region)
|
|
if region == "" {
|
|
region = "us-east-1"
|
|
}
|
|
if skew <= 0 {
|
|
skew = 5 * time.Minute
|
|
}
|
|
if maxPresign <= 0 {
|
|
maxPresign = 24 * time.Hour
|
|
}
|
|
|
|
return Config{
|
|
Enabled: enabled,
|
|
Region: region,
|
|
ClockSkew: skew,
|
|
MaxPresignDuration: maxPresign,
|
|
MasterKey: strings.TrimSpace(masterKey),
|
|
BootstrapAccessKey: strings.TrimSpace(bootstrapAccessKey),
|
|
BootstrapSecretKey: strings.TrimSpace(bootstrapSecretKey),
|
|
BootstrapPolicy: strings.TrimSpace(bootstrapPolicy),
|
|
}
|
|
}
|