From e3163e317a8f38df24bca676568505f7dbda6cea Mon Sep 17 00:00:00 2001 From: Alexander Matyushentsev Date: Sat, 6 Mar 2021 20:07:33 -0800 Subject: [PATCH] fix: logout link is broken (#5698) Signed-off-by: Alexander Matyushentsev --- server/logout/logout.go | 9 ++++++++- ui/src/app/shared/components/page/page.tsx | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/server/logout/logout.go b/server/logout/logout.go index c4b5d60d3b..b0409590bb 100644 --- a/server/logout/logout.go +++ b/server/logout/logout.go @@ -63,7 +63,14 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - logoutRedirectURL := strings.TrimRight(strings.TrimLeft(argoCDSettings.URL, "/"), "/") + strings.TrimRight(strings.TrimLeft(h.rootPath, "/"), "/") + argoURL := argoCDSettings.URL + if argoURL == "" { + // golang does not provide any easy way to determine scheme of current request + // so redirecting ot http which will auto-redirect too https if necessary + argoURL = fmt.Sprintf("http://%s", r.Host) + } + + logoutRedirectURL := strings.TrimRight(strings.TrimLeft(argoURL, "/"), "/") + strings.TrimRight(strings.TrimLeft(h.rootPath, "/"), "/") cookies := r.Cookies() tokenString, err = httputil.JoinCookies(common.AuthCookieName, cookies) diff --git a/ui/src/app/shared/components/page/page.tsx b/ui/src/app/shared/components/page/page.tsx index d6e31eb66c..db07d087be 100644 --- a/ui/src/app/shared/components/page/page.tsx +++ b/ui/src/app/shared/components/page/page.tsx @@ -1,8 +1,11 @@ import {DataLoader, Page as ArgoPage, Toolbar, Utils} from 'argo-ui'; import * as React from 'react'; import {BehaviorSubject, Observable} from 'rxjs'; + import {Context, ContextApis} from '../../context'; import {services} from '../../services'; +import requests from '../../services/requests'; + const mostRecentLoggedIn = new BehaviorSubject(false); import './page.scss'; @@ -20,7 +23,7 @@ export const AddAuthToToolbar = (init: Toolbar | Observable, ctx: Conte isLoggedIn()}> {loggedIn => loggedIn ? ( - ctx.navigation.goto('/auth/logout')}> + (window.location.href = requests.toAbsURL('/auth/logout'))}> Log out ) : (