Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VAULT-1986] Cap AWS Token TTL based on Default Lease TTL #12026

Merged
merged 6 commits into from Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max ttl will be capped at login time

Is this now slightly inaccurate? I believe if you read the config back for the role, it will probably have stored the system max TTL instead of the specified max TTL right? So it's actually already been capped.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, we should remove the about "at login". We're now setting this on the role.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe if you read the config back for the role, it will probably have stored the system max TTL instead of the specified max TTL right?

I don't think that this is the case because we're not actually modifying/overriding roleEntry.TokenMaxTTL so the cap is actually determined at login time. The outdated diff looks like we were at one point but then we reverted back (which I think is the right call).

}
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.
```