Skip to content

Commit

Permalink
Merge pull request #2961 from owncloud/bugfix/logout-without-id-token
Browse files Browse the repository at this point in the history
We shall only call the sso end session endpoint in case we still have…
  • Loading branch information
Lukas Hirt authored Mar 26, 2020
2 parents 7c03d42 + 90313f2 commit cd2bb9e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/2961
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Fix logout when no tokens are known anymore

Single Log Out requires the id_token and in cases where this token is no
longer known calling the SLO endpoint will result in an error.

This has been fixed.

https://github.com/owncloud/phoenix/pull/2961
11 changes: 11 additions & 0 deletions src/services/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ export function initVueAuthenticate (config) {
}
return null
},
getStoredUserObject () {
const storageString = sessionStorage.getItem('oc_oAuth' + mgr._userStoreKey)
if (storageString) {
const user = User.fromStorageString(storageString)
if (user) {
mgr.events.load(user, false)
return user
}
}
return null
},
isAuthenticated () {
return this.getToken() !== null
},
Expand Down
20 changes: 13 additions & 7 deletions src/store/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ const actions = {
// force redirect to login page after logout
router.push({ name: 'login' })
}
vueAuthInstance.logout()
.then(logoutFinalizer)
.catch(error => {
console.error(error)
logoutFinalizer()
})
// TODO: only call logout if we still have the id token
const u = vueAuthInstance.getStoredUserObject()
if (u && u.id_token) {
vueAuthInstance.logout()
.then(logoutFinalizer)
.catch(error => {
console.error(error)
logoutFinalizer()
})
} else {
logoutFinalizer()
}
},
initAuth (context, payload = { autoRedirect: false }) {
function init (client, token, doLogin = true) {
Expand Down Expand Up @@ -107,7 +113,7 @@ const actions = {
vueAuthInstance.events().addUserUnloaded(() => {
console.log('user unloaded…')
context.dispatch('cleanUpLoginState')
router.push({ name: 'accessDenied' })
router.push({ name: 'login' })
})
vueAuthInstance.events().addSilentRenewError(error => {
console.error('Silent Renew Error:', error)
Expand Down

0 comments on commit cd2bb9e

Please sign in to comment.