mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-19 03:57:17 +02:00
proxy: fix sign out redirect (#3827)
* proxy: fix sign out redirect * add test
This commit is contained in:
parent
c048af7523
commit
753eeff12f
2 changed files with 8 additions and 2 deletions
|
@ -75,7 +75,9 @@ func (p *Proxy) SignOut(w http.ResponseWriter, r *http.Request) error {
|
||||||
redirectURL = uri
|
redirectURL = uri
|
||||||
}
|
}
|
||||||
|
|
||||||
dashboardURL := *state.authenticateDashboardURL
|
dashboardURL := state.authenticateDashboardURL.ResolveReference(&url.URL{
|
||||||
|
Path: "/.pomerium/sign_out",
|
||||||
|
})
|
||||||
q := dashboardURL.Query()
|
q := dashboardURL.Query()
|
||||||
if redirectURL != nil {
|
if redirectURL != nil {
|
||||||
q.Set(urlutil.QueryRedirectURI, redirectURL.String())
|
q.Set(urlutil.QueryRedirectURI, redirectURL.String())
|
||||||
|
@ -83,7 +85,7 @@ func (p *Proxy) SignOut(w http.ResponseWriter, r *http.Request) error {
|
||||||
dashboardURL.RawQuery = q.Encode()
|
dashboardURL.RawQuery = q.Encode()
|
||||||
|
|
||||||
state.sessionStore.ClearSession(w, r)
|
state.sessionStore.ClearSession(w, r)
|
||||||
httputil.Redirect(w, r, urlutil.NewSignedURL(state.sharedKey, &dashboardURL).String(), http.StatusFound)
|
httputil.Redirect(w, r, urlutil.NewSignedURL(state.sharedKey, dashboardURL).String(), http.StatusFound)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,10 @@ func TestProxy_SignOut(t *testing.T) {
|
||||||
if status := w.Code; status != tt.wantStatus {
|
if status := w.Code; status != tt.wantStatus {
|
||||||
t.Errorf("status code: got %v want %v", status, tt.wantStatus)
|
t.Errorf("status code: got %v want %v", status, tt.wantStatus)
|
||||||
}
|
}
|
||||||
|
u, err := urlutil.ParseAndValidateURL(w.HeaderMap.Get("Location"))
|
||||||
|
if assert.NoError(t, err) {
|
||||||
|
assert.Equal(t, "/.pomerium/sign_out", u.Path)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue