Skip to content

Commit

Permalink
Implement logout without extra api call
Browse files Browse the repository at this point in the history
utilise localStorage
  • Loading branch information
juleengraham authored and mvdbeek committed Mar 10, 2021
1 parent d6c0193 commit 3473883
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export default {
axios
.post(`${rootUrl}authnz/${idp}/login/?idphint=${this.selected.EntityID}`)
.then((response) => {
localStorage.setItem("galaxy-provider", idp);
if (response.data.redirect_uri) {
window.location = response.data.redirect_uri;
}
Expand Down
18 changes: 5 additions & 13 deletions client/src/layout/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ export function userLogout(logoutAll = false) {
const galaxy = getGalaxyInstance();
const session_csrf_token = galaxy.session_csrf_token;
const url = `${galaxy.root}user/logout?session_csrf_token=${session_csrf_token}&logout_all=${logoutAll}`;

var identities;
getIdentityProviders().then((results) => {
identities = results;
});
axios
.get(url)
.then((response) => {
Expand All @@ -26,15 +21,12 @@ export function userLogout(logoutAll = false) {
}
// Check if we need to logout of OIDC IDP
if (galaxy.config.enable_oidc) {
const email = galaxy.user.attributes.email;
var provider;
for (var i = 0; i < identities.length; i++) {
if (identities[i].email == email) {
provider = identities[i].provider;
break;
}
const provider = localStorage.getItem("galaxy-provider");
if (provider) {
localStorage.removeItem("galaxy-provider");
return axios.get(`${galaxy.root}authnz/logout?provider=${provider}`);
}
return axios.get(`${galaxy.root}authnz/${provider}/logout`);
return axios.get(`${galaxy.root}authnz/logout`);
} else {
// Otherwise pass through the initial logout response
return response;
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/controllers/authnz.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def logout(self, trans, provider, **kwargs):
return {'message': message}

@web.expose
def get_logout_url(self, trans, **kwargs):
idp_provider = trans.get_cookie(name=PROVIDER_COOKIE_NAME)
def get_logout_url(self, trans, provider=None, **kwargs):
idp_provider = provider if provider else trans.get_cookie(name=PROVIDER_COOKIE_NAME)
if idp_provider:
return trans.response.send_redirect(url_for(controller='authnz', action='logout', provider=idp_provider))

Expand Down

0 comments on commit 3473883

Please sign in to comment.