authorize: fix x-forwarded-uri (#3479)

* authorize: fix x-forwarded-uri

* fix raw path
This commit is contained in:
Caleb Doxsey 2022-07-14 09:32:48 -06:00 committed by GitHub
parent 24a9d627cd
commit bc078f8bd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 22 deletions

View file

@ -0,0 +1,22 @@
package urlutil
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGetForwardAuthURL(t *testing.T) {
t.Run("double-escaping", func(t *testing.T) {
req, err := http.NewRequest("GET", "https://example.com", nil)
require.NoError(t, err)
req.Header.Set("X-Forwarded-Proto", "https")
req.Header.Set("X-Forwarded-Host", "protected-host.tld")
req.Header.Set("X-Forwarded-Uri", "/example?a=b&c=d")
u := GetForwardAuthURL(req)
assert.Equal(t, "https://protected-host.tld/example?a=b&c=d", u.String())
})
}