Skip to content

Commit

Permalink
simplify check for Vault-Request header
Browse files Browse the repository at this point in the history
  • Loading branch information
mjarmy committed Oct 11, 2019
1 parent a915b64 commit 34ff6dd
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions command/agent/cache/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"io"
"io/ioutil"
"net/http"
"reflect"
"time"

"github.com/hashicorp/errwrap"
Expand All @@ -27,8 +26,7 @@ func Handler(ctx context.Context, logger hclog.Logger, proxier Proxier, inmemSin

// Check for the required request header
if requireRequestHeader {
val, ok := r.Header["Vault-Request"]
if !ok || !reflect.DeepEqual(val, []string{"true"}) {
if val, ok := r.Header["Vault-Request"]; !ok || len(val) != 1 || val[0] != "true" {
logical.RespondError(w, http.StatusPreconditionFailed, errors.New("missing 'Vault-Request' header"))
return
}
Expand Down

0 comments on commit 34ff6dd

Please sign in to comment.