Skip to content

Commit

Permalink
Merge f0782ee into backport/vault-28314-token-max-lease-ttl-fix/forma…
Browse files Browse the repository at this point in the history
…lly-usable-jawfish
  • Loading branch information
hc-github-team-secure-vault-core authored Sep 25, 2024
2 parents 4e2c767 + f0782ee commit b77eaca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelog/28498.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
auth/token: Fix token TTL calculation so that it uses `max_lease_ttl` tune value for tokens created via `auth/token/create`.
```
9 changes: 8 additions & 1 deletion vault/token_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3138,9 +3138,16 @@ func (ts *TokenStore) handleCreateCommon(ctx context.Context, req *logical.Reque

sysView := ts.System().(extendedSystemView)

var backendMaxTTL time.Duration

mountEntry := ts.core.router.MatchingMountByAccessor(req.MountAccessor)
if mountEntry != nil {
backendMaxTTL = mountEntry.Config.MaxLeaseTTL
}

// Only calculate a TTL if you are A) periodic, B) have a TTL, C) do not have a TTL and are not a root token
if periodToUse > 0 || te.TTL > 0 || (te.TTL == 0 && !strutil.StrListContains(te.Policies, "root")) {
ttl, warnings, err := framework.CalculateTTL(sysView, 0, te.TTL, periodToUse, 0, explicitMaxTTLToUse, time.Unix(te.CreationTime, 0))
ttl, warnings, err := framework.CalculateTTL(sysView, 0, te.TTL, periodToUse, backendMaxTTL, explicitMaxTTLToUse, time.Unix(te.CreationTime, 0))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b77eaca

Please sign in to comment.