Merge pull request #1684 from hashicorp/issue-1683
Add extra nil check for an error response/use duration helper for TTL values
This commit is contained in:
commit
c4992fa3e5
|
@ -232,7 +232,7 @@ func respondErrorCommon(w http.ResponseWriter, resp *logical.Response, err error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp != nil {
|
if resp != nil && resp.IsError(){
|
||||||
err = fmt.Errorf("%s", resp.Data["error"].(string))
|
err = fmt.Errorf("%s", resp.Data["error"].(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
|
|
||||||
"github.com/armon/go-metrics"
|
"github.com/armon/go-metrics"
|
||||||
"github.com/hashicorp/go-uuid"
|
"github.com/hashicorp/go-uuid"
|
||||||
|
"github.com/hashicorp/vault/helper/duration"
|
||||||
"github.com/hashicorp/vault/helper/jsonutil"
|
"github.com/hashicorp/vault/helper/jsonutil"
|
||||||
"github.com/hashicorp/vault/helper/locksutil"
|
"github.com/hashicorp/vault/helper/locksutil"
|
||||||
"github.com/hashicorp/vault/helper/policyutil"
|
"github.com/hashicorp/vault/helper/policyutil"
|
||||||
|
@ -1179,7 +1180,7 @@ func (ts *TokenStore) handleCreateCommon(
|
||||||
}
|
}
|
||||||
|
|
||||||
if data.ExplicitMaxTTL != "" {
|
if data.ExplicitMaxTTL != "" {
|
||||||
dur, err := time.ParseDuration(data.ExplicitMaxTTL)
|
dur, err := duration.ParseDurationSecond(data.ExplicitMaxTTL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return logical.ErrorResponse(err.Error()), logical.ErrInvalidRequest
|
return logical.ErrorResponse(err.Error()), logical.ErrInvalidRequest
|
||||||
}
|
}
|
||||||
|
@ -1191,7 +1192,7 @@ func (ts *TokenStore) handleCreateCommon(
|
||||||
|
|
||||||
// Parse the TTL/lease if any
|
// Parse the TTL/lease if any
|
||||||
if data.TTL != "" {
|
if data.TTL != "" {
|
||||||
dur, err := time.ParseDuration(data.TTL)
|
dur, err := duration.ParseDurationSecond(data.TTL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return logical.ErrorResponse(err.Error()), logical.ErrInvalidRequest
|
return logical.ErrorResponse(err.Error()), logical.ErrInvalidRequest
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue