diff --git a/pipeline/mutate/mutator_hydrator.go b/pipeline/mutate/mutator_hydrator.go index 128f85affc..11e24c9a61 100644 --- a/pipeline/mutate/mutator_hydrator.go +++ b/pipeline/mutate/mutator_hydrator.go @@ -167,6 +167,12 @@ func (a *MutatorHydrator) Mutate(r *http.Request, session *authn.AuthenticationS if err != nil { return errors.WithStack(err) } + + if r.URL != nil { + q := r.URL.Query() + req.URL.RawQuery = q.Encode() + } + for key, values := range r.Header { for _, value := range values { req.Header.Add(key, value) diff --git a/pipeline/mutate/mutator_hydrator_test.go b/pipeline/mutate/mutator_hydrator_test.go index d27097b654..40760caba7 100644 --- a/pipeline/mutate/mutator_hydrator_test.go +++ b/pipeline/mutate/mutator_hydrator_test.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "net/http" "net/http/httptest" + "net/url" "testing" "github.com/julienschmidt/httprouter" @@ -324,6 +325,27 @@ func TestMutatorHydrator(t *testing.T) { Match: newAuthenticationSession(setExtra(sampleKey, sampleValue)), Err: nil, }, + "Pass Query Parameters": { + Setup: func(t *testing.T) http.Handler { + router := httprouter.New() + router.POST("/", func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + q := r.URL.Query() + assert.Equal(t, len(q), 2) + assert.Equal(t, q["a"], []string{"b"}) + assert.Equal(t, q["c"], []string{"&12"}) + + _, err = w.Write([]byte(`{}`)) + require.NoError(t, err) + }) + return router + }, + Session: newAuthenticationSession(), + Rule: &rule.Rule{ID: "test-rule"}, + Config: defaultConfigForMutator(), + Request: &http.Request{URL: &url.URL{RawQuery: "a=b&c=%2612"}}, + Match: newAuthenticationSession(), + Err: nil, + }, } for testName, specs := range testMap {