Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

We shall only call the sso end session endpoint in case we still have… #2961

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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