mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Rename mongodb secret backend's 'ttl_max' lease configuration field to 'max_ttl'
This commit is contained in:
@@ -163,7 +163,7 @@ func testAccStepWriteLease(t *testing.T) logicaltest.TestStep {
|
||||
Path: "config/lease",
|
||||
Data: map[string]interface{}{
|
||||
"ttl": "1h5m",
|
||||
"ttl_max": "24h",
|
||||
"max_ttl": "24h",
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -173,7 +173,7 @@ func testAccStepReadLease(t *testing.T) logicaltest.TestStep {
|
||||
Operation: logical.ReadOperation,
|
||||
Path: "config/lease",
|
||||
Check: func(resp *logical.Response) error {
|
||||
if resp.Data["ttl"] != "1h5m0s" || resp.Data["ttl_max"] != "24h0m0s" {
|
||||
if resp.Data["ttl"] != "1h5m0s" || resp.Data["max_ttl"] != "24h0m0s" {
|
||||
return fmt.Errorf("bad: %#v", resp)
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func pathConfigLease(b *backend) *framework.Path {
|
||||
Description: "Default ttl for credentials.",
|
||||
},
|
||||
|
||||
"ttl_max": &framework.FieldSchema{
|
||||
"max_ttl": &framework.FieldSchema{
|
||||
Type: framework.TypeString,
|
||||
Description: "Maximum time a set of credentials can be valid for.",
|
||||
},
|
||||
@@ -36,23 +36,23 @@ func pathConfigLease(b *backend) *framework.Path {
|
||||
func (b *backend) pathConfigLeaseWrite(
|
||||
req *logical.Request, d *framework.FieldData) (*logical.Response, error) {
|
||||
ttlRaw := d.Get("ttl").(string)
|
||||
ttlMaxRaw := d.Get("ttl_max").(string)
|
||||
maxTTLRaw := d.Get("max_ttl").(string)
|
||||
|
||||
ttl, err := time.ParseDuration(ttlRaw)
|
||||
if err != nil {
|
||||
return logical.ErrorResponse(fmt.Sprintf(
|
||||
"Invalid ttl: %s", err)), nil
|
||||
}
|
||||
ttlMax, err := time.ParseDuration(ttlMaxRaw)
|
||||
maxTTL, err := time.ParseDuration(maxTTLRaw)
|
||||
if err != nil {
|
||||
return logical.ErrorResponse(fmt.Sprintf(
|
||||
"Invalid ttl_max: %s", err)), nil
|
||||
"Invalid max_ttl: %s", err)), nil
|
||||
}
|
||||
|
||||
// Store it
|
||||
entry, err := logical.StorageEntryJSON("config/lease", &configLease{
|
||||
TTL: ttl,
|
||||
TTLMax: ttlMax,
|
||||
MaxTTL: maxTTL,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -78,14 +78,14 @@ func (b *backend) pathConfigLeaseRead(
|
||||
return &logical.Response{
|
||||
Data: map[string]interface{}{
|
||||
"ttl": leaseConfig.TTL.String(),
|
||||
"ttl_max": leaseConfig.TTLMax.String(),
|
||||
"max_ttl": leaseConfig.MaxTTL.String(),
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
type configLease struct {
|
||||
TTL time.Duration
|
||||
TTLMax time.Duration
|
||||
MaxTTL time.Duration
|
||||
}
|
||||
|
||||
const pathConfigLeaseHelpSyn = `
|
||||
@@ -98,7 +98,7 @@ This configures the default lease TTL settings used for
|
||||
credentials generated by this backend. The ttl specifies the
|
||||
duration that a set of credentials will be valid for before
|
||||
the lease must be renewed (if it is renewable), while the
|
||||
ttl_max specifies the overall maximum duration that the
|
||||
max_ttl specifies the overall maximum duration that the
|
||||
credentials will be valid regardless of lease renewals.
|
||||
|
||||
The format for the TTL values is an integer and then unit. For
|
||||
|
||||
@@ -39,7 +39,7 @@ func (b *backend) secretCredsRenew(req *logical.Request, d *framework.FieldData)
|
||||
leaseConfig = &configLease{}
|
||||
}
|
||||
|
||||
f := framework.LeaseExtend(leaseConfig.TTL, leaseConfig.TTLMax, b.System())
|
||||
f := framework.LeaseExtend(leaseConfig.TTL, leaseConfig.MaxTTL, b.System())
|
||||
return f(req, d)
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ Optionally, we can configure the lease settings for the credentials generated
|
||||
by Vault. This is done by writing to the `config/lease` key:
|
||||
|
||||
```
|
||||
$ vault write mongodb/config/lease ttl=1h ttl_max=24h
|
||||
$ vault write mongodb/config/lease ttl=1h max_ttl=24h
|
||||
Success! Data written to: mongodb/config/lease
|
||||
```
|
||||
|
||||
@@ -184,7 +184,7 @@ applications are restricted in the credentials they are allowed to read.
|
||||
with time suffix. Hour is the largest suffix.
|
||||
</li>
|
||||
<li>
|
||||
<span class="param">ttl_max</span>
|
||||
<span class="param">max_ttl</span>
|
||||
<span class="param-flags">required</span>
|
||||
The maximum ttl value provided as a string duration
|
||||
with time suffix. Hour is the largest suffix.
|
||||
|
||||
Reference in New Issue
Block a user