mirror of
https://github.com/ferdzo/fs.git
synced 2026-04-05 08:56:26 +00:00
Initial working authentication with SigV4
This commit is contained in:
50
auth/config.go
Normal file
50
auth/config.go
Normal file
@@ -0,0 +1,50 @@
|
||||
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),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user