Skip to content

Commit

Permalink
[VAULT-1986] Cap AWS Token TTL based on Default Lease TTL (hashicorp#…
Browse files Browse the repository at this point in the history
…12026)

* fix: cap token TTL at login time based on default lease TTL

* add changelog file

* patch: update warning messages to not include 'at login'

* patch: remove default lease capping and test

* update changelog

* patch: revert warning message
  • Loading branch information
vinay-gopalan authored and jartek committed Sep 11, 2021
1 parent 6dd3be3 commit 012b461
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 0 additions & 4 deletions builtin/credential/aws/path_role.go
Expand Up @@ -889,11 +889,7 @@ func (b *backend) pathRoleCreateUpdate(ctx context.Context, req *logical.Request
}
}

defaultLeaseTTL := b.System().DefaultLeaseTTL()
systemMaxTTL := b.System().MaxLeaseTTL()
if roleEntry.TokenTTL > defaultLeaseTTL {
resp.AddWarning(fmt.Sprintf("Given ttl of %d seconds greater than current mount/system default of %d seconds; ttl will be capped at login time", roleEntry.TokenTTL/time.Second, defaultLeaseTTL/time.Second))
}
if roleEntry.TokenMaxTTL > systemMaxTTL {
resp.AddWarning(fmt.Sprintf("Given max ttl of %d seconds greater than current mount/system default of %d seconds; max ttl will be capped at login time", roleEntry.TokenMaxTTL/time.Second, systemMaxTTL/time.Second))
}
Expand Down
4 changes: 2 additions & 2 deletions builtin/credential/aws/path_role_test.go
Expand Up @@ -762,10 +762,10 @@ func TestAwsEc2_RoleDurationSeconds(t *testing.T) {
}

if resp.Data["ttl"].(int64) != 10 {
t.Fatalf("bad: period; expected: 10, actual: %d", resp.Data["ttl"])
t.Fatalf("bad: ttl; expected: 10, actual: %d", resp.Data["ttl"])
}
if resp.Data["max_ttl"].(int64) != 20 {
t.Fatalf("bad: period; expected: 20, actual: %d", resp.Data["max_ttl"])
t.Fatalf("bad: max_ttl; expected: 20, actual: %d", resp.Data["max_ttl"])
}
if resp.Data["period"].(int64) != 30 {
t.Fatalf("bad: period; expected: 30, actual: %d", resp.Data["period"])
Expand Down
3 changes: 3 additions & 0 deletions changelog/12026.txt
@@ -0,0 +1,3 @@
```release-note:bug
auth/aws: Remove warning stating AWS Token TTL will be capped by the Default Lease TTL.
```

0 comments on commit 012b461

Please sign in to comment.