authenticate: fix internal service URL dashboard redirect (#3305)

This commit is contained in:
Caleb Doxsey 2022-04-29 14:09:28 +00:00 committed by GitHub
parent 820be99a2f
commit 464ccdf767
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -640,6 +640,25 @@ func TestJwksEndpoint(t *testing.T) {
func TestAuthenticate_userInfo(t *testing.T) {
t.Parallel()
t.Run("cookie-redirect-uri", func(t *testing.T) {
w := httptest.NewRecorder()
r := httptest.NewRequest("GET", "https://authenticate.service.cluster.local/.pomerium/?pomerium_redirect_uri=https://www.example.com", nil)
var a Authenticate
a.state = newAtomicAuthenticateState(&authenticateState{
cookieSecret: cryptutil.NewKey(),
})
a.options = config.NewAtomicOptions()
a.options.Store(&config.Options{
SharedKey: cryptutil.NewBase64Key(),
AuthenticateURLString: "https://authenticate.example.com",
AuthenticateInternalURLString: "https://authenticate.service.cluster.local",
})
err := a.userInfo(w, r)
assert.NoError(t, err)
assert.Equal(t, http.StatusFound, w.Code)
assert.Equal(t, "https://authenticate.example.com/.pomerium/", w.Header().Get("Location"))
})
now := time.Now()
tests := []struct {
name string