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

Token revocation refactor #4512

Merged
merged 17 commits into from
May 10, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Return invalid lease on negative TTL"
This reverts commit a39597e.
  • Loading branch information
calvn committed May 8, 2018
commit c107e0cc86f4b5c404405576b42cced8297034b0
20 changes: 9 additions & 11 deletions vault/logical_system.go
Original file line number Diff line number Diff line change
@@ -2215,36 +2215,34 @@ func (b *SystemBackend) handleLeaseLookup(ctx context.Context, req *logical.Requ
logical.ErrInvalidRequest
}

le, err := b.Core.expiration.FetchLeaseTimes(leaseID)
leaseTimes, err := b.Core.expiration.FetchLeaseTimes(leaseID)
if err != nil {
b.Backend.Logger().Error("error retrieving lease", "lease_id", leaseID, "error", err)
return handleError(err)
}

if le == nil || le.ttl() < 0 {
if leaseTimes == nil {
return logical.ErrorResponse("invalid lease"), logical.ErrInvalidRequest
}

resp := &logical.Response{
Data: map[string]interface{}{
"id": leaseID,
"issue_time": le.IssueTime,
"issue_time": leaseTimes.IssueTime,
"expire_time": nil,
"last_renewal": nil,
"ttl": int64(0),
},
}
renewable, _ := le.renewable()
renewable, _ := leaseTimes.renewable()
resp.Data["renewable"] = renewable

if !le.LastRenewalTime.IsZero() {
resp.Data["last_renewal"] = le.LastRenewalTime
if !leaseTimes.LastRenewalTime.IsZero() {
resp.Data["last_renewal"] = leaseTimes.LastRenewalTime
}
if !le.ExpireTime.IsZero() {
resp.Data["expire_time"] = le.ExpireTime
resp.Data["ttl"] = le.ttl()
if !leaseTimes.ExpireTime.IsZero() {
resp.Data["expire_time"] = leaseTimes.ExpireTime
resp.Data["ttl"] = leaseTimes.ttl()
}

return resp, nil
}