增加日志与退出时404问题处理
This commit is contained in:
@@ -38,7 +38,11 @@ func (handler *authLogoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Reque
|
||||
for _, write := range identity.ClearSessionCookies(secure) {
|
||||
http.SetCookie(w, transportCookie(write))
|
||||
}
|
||||
w.Header().Set("Location", logoutLocation(requestURL))
|
||||
redirectBaseURL := strings.TrimSpace(handler.config.PublicBaseURL)
|
||||
if redirectBaseURL == "" {
|
||||
redirectBaseURL = requestURL
|
||||
}
|
||||
w.Header().Set("Location", logoutLocation(redirectBaseURL))
|
||||
w.WriteHeader(http.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,20 @@ func TestAuthLogoutUsesRequestOriginAndExplicitCookieSecurity(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthLogoutUsesPublicBaseURLBehindDevelopmentProxy(t *testing.T) {
|
||||
handler := httpapi.NewAuthLogoutHandler(httpapi.LogoutConfig{PublicBaseURL: "http://127.0.0.1:3000"})
|
||||
request := httptest.NewRequest(http.MethodPost, "http://127.0.0.1:8080/api/auth/logout", nil)
|
||||
response := httptest.NewRecorder()
|
||||
handler.ServeHTTP(response, request)
|
||||
|
||||
if response.Code != http.StatusTemporaryRedirect {
|
||||
t.Fatalf("status = %d, want %d", response.Code, http.StatusTemporaryRedirect)
|
||||
}
|
||||
if got := response.Header().Get("Location"); got != "http://127.0.0.1:3000/auth/login?loggedOut=1" {
|
||||
t.Fatalf("Location = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthLogoutMethodAndPathSemantics(t *testing.T) {
|
||||
handler := httpapi.NewAuthLogoutHandler(httpapi.LogoutConfig{})
|
||||
tests := []struct {
|
||||
|
||||
Reference in New Issue
Block a user