VAULT-24736 CE changes for static secret capability behaviour toggle (#26744)

This commit is contained in:
Violet Hynes
2024-05-03 14:12:19 -04:00
committed by GitHub
parent 2a99b3651f
commit f2b4ca4def
6 changed files with 149 additions and 9 deletions

View File

@@ -109,6 +109,7 @@ type Cache struct {
DisableCachingDynamicSecrets bool `hcl:"disable_caching_dynamic_secrets"`
StaticSecretTokenCapabilityRefreshIntervalRaw interface{} `hcl:"static_secret_token_capability_refresh_interval"`
StaticSecretTokenCapabilityRefreshInterval time.Duration `hcl:"-"`
StaticSecretTokenCapabilityRefreshBehaviour string `hcl:"static_secret_token_capability_refresh_behavior"`
}
// AutoAuth is the configured authentication method and sinks
@@ -271,6 +272,15 @@ func (c *Config) ValidateConfig() error {
return fmt.Errorf("no auto_auth, cache, or listener block found in config")
}
if c.Cache != nil && c.Cache.StaticSecretTokenCapabilityRefreshBehaviour != "" {
switch c.Cache.StaticSecretTokenCapabilityRefreshBehaviour {
case "pessimistic":
case "optimistic":
default:
return fmt.Errorf("cache.static_secret_token_capability_refresh_behavior must be either \"optimistic\" or \"pessimistic\"")
}
}
return nil
}