Skip to content

Commit

Permalink
addressing feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Hoffman committed Apr 3, 2018
1 parent 0b465c4 commit 2317f5e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions builtin/credential/ldap/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ func (b *backend) pathLoginRenew(ctx context.Context, req *logical.Request, d *f
return nil, fmt.Errorf("policies have changed, not renewing")
}

resp.Auth = req.Auth

// Remove old aliases
resp.Auth.GroupAliases = nil

Expand Down
1 change: 1 addition & 0 deletions builtin/credential/okta/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ func (b *backend) pathLoginRenew(ctx context.Context, req *logical.Request, d *f
return nil, err
}

resp.Auth = req.Auth
resp.Auth.TTL = cfg.TTL
resp.Auth.MaxTTL = cfg.MaxTTL

Expand Down
1 change: 1 addition & 0 deletions builtin/credential/radius/path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (b *backend) pathLogin(ctx context.Context, req *logical.Request, d *framew
}
}

resp.Auth = req.Auth
resp.Auth = &logical.Auth{
Policies: policies,
Metadata: map[string]string{
Expand Down
3 changes: 3 additions & 0 deletions builtin/logical/database/secret_creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (b *databaseBackend) secretCredsRenew() framework.OperationFunc {
}
if ttl > 0 {
expireTime := time.Now().Add(ttl)
// Adding a small buffer since the TTL will be calculated again afeter this call
// to ensure the database credential does not expire before the lease
expireTime = expireTime.Add(5 * time.Second)
err := db.RenewUser(ctx, role.Statements, username, expireTime)
if err != nil {
b.CloseIfShutdown(db, err)
Expand Down
3 changes: 3 additions & 0 deletions builtin/logical/postgresql/secret_creds.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ func (b *backend) secretCredsRenew(ctx context.Context, req *logical.Request, d
}
if ttl > 0 {
expireTime := time.Now().Add(ttl)
// Adding a small buffer since the TTL will be calculated again afeter this call
// to ensure the database credential does not expire before the lease
expireTime = expireTime.Add(5 * time.Second)
expiration := expireTime.Format("2006-01-02 15:04:05-0700")

query := fmt.Sprintf(
Expand Down
2 changes: 1 addition & 1 deletion logical/framework/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func LeaseExtend(backendIncrement, backendMax time.Duration, systemView logical.
}
}

// CalculateTTL takes all the user-specifie, backend, and system inputs and calculates
// CalculateTTL takes all the user-specified, backend, and system inputs and calculates
// a TTL for a lease
func CalculateTTL(sysView logical.SystemView, increment, backendTTL, period, backendMaxTTL, explicitMaxTTL time.Duration, startTime time.Time) (ttl time.Duration, warnings []string, errors error) {
// Truncate all times to the second since that is the lowest precision for
Expand Down

0 comments on commit 2317f5e

Please sign in to comment.