Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bcab16f2bf |
@@ -229,7 +229,7 @@ func ValidateStateCookie(w http.ResponseWriter, r *http.Request, prefix, querySt
|
|||||||
// redirect back to it after SSO login completes.
|
// redirect back to it after SSO login completes.
|
||||||
func SetReturnToCookie(w http.ResponseWriter, r *http.Request, prefix string) {
|
func SetReturnToCookie(w http.ResponseWriter, r *http.Request, prefix string) {
|
||||||
path := r.URL.Path
|
path := r.URL.Path
|
||||||
if path == "" || path == "/login" || path == "/sso/callback" {
|
if path == "" || path == "/login" || strings.HasPrefix(path, "/sso/") {
|
||||||
path = "/"
|
path = "/"
|
||||||
}
|
}
|
||||||
http.SetCookie(w, &http.Cookie{
|
http.SetCookie(w, &http.Cookie{
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ func TestReturnToDefaultsToRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestReturnToSkipsLoginPaths(t *testing.T) {
|
func TestReturnToSkipsLoginPaths(t *testing.T) {
|
||||||
for _, p := range []string{"/login", "/sso/callback"} {
|
for _, p := range []string{"/login", "/sso/callback", "/sso/redirect"} {
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
req := httptest.NewRequest(http.MethodGet, p, nil)
|
req := httptest.NewRequest(http.MethodGet, p, nil)
|
||||||
SetReturnToCookie(rec, req, "mcr")
|
SetReturnToCookie(rec, req, "mcr")
|
||||||
|
|||||||
Reference in New Issue
Block a user