Seal wrap requesting in logical.Request wrapinfo (#3559)

This commit is contained in:
Jeff Mitchell 2017-11-09 10:32:49 -05:00 committed by GitHub
parent 6b72b90efa
commit 922ac56222
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -8,7 +8,7 @@ import (
)
// RequestWrapInfo is a struct that stores information about desired response
// wrapping behavior
// and seal wrapping behavior
type RequestWrapInfo struct {
// Setting to non-zero specifies that the response should be wrapped.
// Specifies the desired TTL of the wrapping token.
@ -17,6 +17,10 @@ type RequestWrapInfo struct {
// The format to use for the wrapped response; if not specified it's a bare
// token
Format string `json:"format" structs:"format" mapstructure:"format" sentinel:""`
// A flag to conforming backends that data for a given request should be
// seal wrapped
SealWrap bool `json:"seal_wrap" structs:"seal_wrap" mapstructure:"seal_wrap" sentinel:""`
}
func (r *RequestWrapInfo) SentinelGet(key string) (interface{}, error) {

View File

@ -129,6 +129,9 @@ func (b *CubbyholeBackend) handleWrite(
Key: req.ClientToken + "/" + req.Path,
Value: buf,
}
if req.WrapInfo != nil && req.WrapInfo.SealWrap {
entry.SealWrap = true
}
if err := req.Storage.Put(entry); err != nil {
return nil, fmt.Errorf("failed to write: %v", err)
}