mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 03:58:01 +00:00
Adding a Clone() function to the request hanlder to be used when theres a need to modify the current request before saving it (#9499)
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mitchellh/copystructure"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RequestWrapInfo is a struct that stores information about desired response
|
// RequestWrapInfo is a struct that stores information about desired response
|
||||||
@@ -179,6 +181,15 @@ type Request struct {
|
|||||||
ResponseWriter *HTTPResponseWriter `json:"-" sentinel:""`
|
ResponseWriter *HTTPResponseWriter `json:"-" sentinel:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clone returns a deep copy of the request by using copystructure
|
||||||
|
func (r *Request) Clone() (*Request, error) {
|
||||||
|
cpy, err := copystructure.Copy(r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return cpy.(*Request), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Get returns a data field and guards for nil Data
|
// Get returns a data field and guards for nil Data
|
||||||
func (r *Request) Get(key string) interface{} {
|
func (r *Request) Get(key string) interface{} {
|
||||||
if r.Data == nil {
|
if r.Data == nil {
|
||||||
|
|||||||
2
vendor/github.com/hashicorp/vault/sdk/helper/awsutil/generate_credentials.go
generated
vendored
2
vendor/github.com/hashicorp/vault/sdk/helper/awsutil/generate_credentials.go
generated
vendored
@@ -62,7 +62,7 @@ func (c *CredentialsConfig) GenerateCredentialChain() (*credentials.Credentials,
|
|||||||
roleARN := os.Getenv("AWS_ROLE_ARN")
|
roleARN := os.Getenv("AWS_ROLE_ARN")
|
||||||
tokenPath := os.Getenv("AWS_WEB_IDENTITY_TOKEN_FILE")
|
tokenPath := os.Getenv("AWS_WEB_IDENTITY_TOKEN_FILE")
|
||||||
sessionName := os.Getenv("AWS_ROLE_SESSION_NAME")
|
sessionName := os.Getenv("AWS_ROLE_SESSION_NAME")
|
||||||
if roleARN != "" && tokenPath != "" && sessionName != "" {
|
if roleARN != "" && tokenPath != "" {
|
||||||
// this session is only created to create the WebIdentityRoleProvider, as the env variables are already there
|
// this session is only created to create the WebIdentityRoleProvider, as the env variables are already there
|
||||||
// this automatically assumes the role, but the provider needs to be added to the chain
|
// this automatically assumes the role, but the provider needs to be added to the chain
|
||||||
sess, err := session.NewSession()
|
sess, err := session.NewSession()
|
||||||
|
|||||||
11
vendor/github.com/hashicorp/vault/sdk/logical/request.go
generated
vendored
11
vendor/github.com/hashicorp/vault/sdk/logical/request.go
generated
vendored
@@ -5,6 +5,8 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mitchellh/copystructure"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RequestWrapInfo is a struct that stores information about desired response
|
// RequestWrapInfo is a struct that stores information about desired response
|
||||||
@@ -179,6 +181,15 @@ type Request struct {
|
|||||||
ResponseWriter *HTTPResponseWriter `json:"-" sentinel:""`
|
ResponseWriter *HTTPResponseWriter `json:"-" sentinel:""`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clone returns a deep copy of the request by using copystructure
|
||||||
|
func (r *Request) Clone() (*Request, error) {
|
||||||
|
cpy, err := copystructure.Copy(r)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return cpy.(*Request), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Get returns a data field and guards for nil Data
|
// Get returns a data field and guards for nil Data
|
||||||
func (r *Request) Get(key string) interface{} {
|
func (r *Request) Get(key string) interface{} {
|
||||||
if r.Data == nil {
|
if r.Data == nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user