mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Add wrapping through core and change to use TTL instead of Duration.
This commit is contained in:
@@ -54,9 +54,9 @@ type Request struct {
|
||||
// request path with the MountPoint trimmed off.
|
||||
MountPoint string
|
||||
|
||||
// WrapDuration contains the requested TTL of the token used to wrap the
|
||||
// WrapTTL contains the requested TTL of the token used to wrap the
|
||||
// response in a cubbyhole.
|
||||
WrapDuration time.Duration
|
||||
WrapTTL time.Duration
|
||||
}
|
||||
|
||||
// Get returns a data field and guards for nil Data
|
||||
|
||||
@@ -30,7 +30,7 @@ const (
|
||||
type WrapInfo struct {
|
||||
// Setting to non-zero specifies that the response should be wrapped.
|
||||
// Specifies the desired TTL of the wrapping token.
|
||||
Duration time.Duration
|
||||
TTL time.Duration
|
||||
|
||||
// The token containing the wrapped response
|
||||
Token string
|
||||
@@ -132,6 +132,11 @@ func (r *Response) ClearWarnings() {
|
||||
r.warnings = make([]string, 0, 1)
|
||||
}
|
||||
|
||||
// Copies the warnings from the other response to this one
|
||||
func (r *Response) CloneWarnings(other *Response) {
|
||||
r.warnings = other.warnings
|
||||
}
|
||||
|
||||
// IsError returns true if this response seems to indicate an error.
|
||||
func (r *Response) IsError() bool {
|
||||
return r != nil && len(r.Data) == 1 && r.Data["error"] != nil
|
||||
|
||||
@@ -5,6 +5,7 @@ func SanitizeResponse(input *Response) *HTTPResponse {
|
||||
Data: input.Data,
|
||||
Warnings: input.Warnings(),
|
||||
}
|
||||
|
||||
if input.Secret != nil {
|
||||
logicalResp.LeaseID = input.Secret.LeaseID
|
||||
logicalResp.Renewable = input.Secret.Renewable
|
||||
@@ -32,6 +33,7 @@ type HTTPResponse struct {
|
||||
Renewable bool `json:"renewable"`
|
||||
LeaseDuration int `json:"lease_duration"`
|
||||
Data map[string]interface{} `json:"data"`
|
||||
WrapInfo *HTTPWrapInfo `json:"wrap_info"`
|
||||
Warnings []string `json:"warnings"`
|
||||
Auth *HTTPAuth `json:"auth"`
|
||||
}
|
||||
@@ -44,3 +46,8 @@ type HTTPAuth struct {
|
||||
LeaseDuration int `json:"lease_duration"`
|
||||
Renewable bool `json:"renewable"`
|
||||
}
|
||||
|
||||
type HTTPWrapInfo struct {
|
||||
Token string `json:"token"`
|
||||
TTL int `json:"ttl"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user