mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 03:58:01 +00:00
Error on violating SysView boundaries
This commit is contained in:
@@ -178,6 +178,7 @@ func (b *Backend) System() logical.SystemView {
|
|||||||
// those with the SystemView values. If they are empty default values are set.
|
// those with the SystemView values. If they are empty default values are set.
|
||||||
// If they are set, their boundaries are validated.
|
// If they are set, their boundaries are validated.
|
||||||
func (b *Backend) SanitizeTTL(ttlStr, maxTTLStr string) (ttl, maxTTL time.Duration, err error) {
|
func (b *Backend) SanitizeTTL(ttlStr, maxTTLStr string) (ttl, maxTTL time.Duration, err error) {
|
||||||
|
sysMaxTTL := b.System().MaxLeaseTTL()
|
||||||
if len(ttlStr) == 0 {
|
if len(ttlStr) == 0 {
|
||||||
ttl = b.System().DefaultLeaseTTL()
|
ttl = b.System().DefaultLeaseTTL()
|
||||||
} else {
|
} else {
|
||||||
@@ -185,8 +186,10 @@ func (b *Backend) SanitizeTTL(ttlStr, maxTTLStr string) (ttl, maxTTL time.Durati
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, fmt.Errorf("Invalid ttl: %s", err)
|
return 0, 0, fmt.Errorf("Invalid ttl: %s", err)
|
||||||
}
|
}
|
||||||
|
if ttl > sysMaxTTL {
|
||||||
|
return 0, 0, fmt.Errorf("\"ttl\" value must be less than allowed max lease TTL value '%s'", sysMaxTTL.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sysMaxTTL := b.System().MaxLeaseTTL()
|
|
||||||
if len(maxTTLStr) == 0 {
|
if len(maxTTLStr) == 0 {
|
||||||
maxTTL = sysMaxTTL
|
maxTTL = sysMaxTTL
|
||||||
} else {
|
} else {
|
||||||
@@ -194,9 +197,9 @@ func (b *Backend) SanitizeTTL(ttlStr, maxTTLStr string) (ttl, maxTTL time.Durati
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, fmt.Errorf("Invalid max_ttl: %s", err)
|
return 0, 0, fmt.Errorf("Invalid max_ttl: %s", err)
|
||||||
}
|
}
|
||||||
}
|
if maxTTL > sysMaxTTL {
|
||||||
if maxTTL > sysMaxTTL {
|
return 0, 0, fmt.Errorf("\"max_ttl\" value must be less than allowed max lease TTL value '%s'", sysMaxTTL.String())
|
||||||
maxTTL = sysMaxTTL
|
}
|
||||||
}
|
}
|
||||||
if ttl > maxTTL {
|
if ttl > maxTTL {
|
||||||
ttl = maxTTL
|
ttl = maxTTL
|
||||||
|
|||||||
Reference in New Issue
Block a user