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

Logout in oc10 while click logout in web #6939

Merged
merged 4 commits into from
May 30, 2022
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
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-not-logged-out-if-oC10-backend
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Not logged out if backend is ownCloud 10

We've fixed an issue, where the user won't be logged out if the backend is ownCloud 10

https://github.com/owncloud/web/pull/6939
https://github.com/owncloud/web/issues/5886
3 changes: 2 additions & 1 deletion config/config.json.sample-oc10
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"auth": {
"clientId": "UmCVsEIxdWmssxa6uVRRPC3txYBVN4qqxooJbsPhuuoPmHk9Pt9Oy68N4ZaKXUYy",
"url": "http://localhost:8080/index.php/apps/oauth2/api/v1/token",
"authUrl": "http://localhost:8080/index.php/apps/oauth2/authorize"
"authUrl": "http://localhost:8080/index.php/apps/oauth2/authorize",
"logoutUrl": "http://localhost:8080/index.php/logout"
},
"apps": [
"files",
Expand Down
3 changes: 2 additions & 1 deletion dev/docker/oc10.web.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"auth": {
"clientId": "M8W5mo3wQV3VHWYsaYpWhkr8dwa949i4GljCkedHhl7GWqmHMkxSeJgK2PcS0jt5",
"url": "http://host.docker.internal:8080/index.php/apps/oauth2/api/v1/token",
"authUrl": "http://host.docker.internal:8080/index.php/apps/oauth2/authorize"
"authUrl": "http://host.docker.internal:8080/index.php/apps/oauth2/authorize",
"logoutUrl": "http://host.docker.internal:8080/index.php/logout"
},
"apps": [
"files",
Expand Down
28 changes: 18 additions & 10 deletions packages/web-runtime/src/store/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const state = {
}

const actions = {
cleanUpLoginState(context) {
cleanUpLoginState(context, options = { clearOIDCLoginState: true }) {
if (context.state.id === '') {
return
}
Expand All @@ -31,18 +31,26 @@ const actions = {
// clear dynamic navItems
context.dispatch('clearDynamicNavItems')

// clear oidc client state
vueAuthInstance.clearLoginState()
if (options.clearOIDCLoginState) {
// clear oidc client state
vueAuthInstance.clearLoginState()
}
Comment on lines +34 to +37
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kulmann this code path triggers a redirect already and interferes with redirecting to the oc10 log out,
I don't call vueAuthInstance.clearLoginState()anymore if we are logged in via oauth2, is this ok?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really sufficient for oauth2 to skip that step? o_O

},
async logout({ dispatch }) {
const logoutFinalizer = (forceRedirect = false) => {
async logout(context) {
const logoutFinalizer = (isOauth2 = false) => {
// Remove signed in user
dispatch('cleanUpLoginState')
dispatch('hideModal')
dispatch('loadSettingsValues')
context.dispatch('cleanUpLoginState', { clearOIDCLoginState: !isOauth2 })
context.dispatch('hideModal')
context.dispatch('loadSettingsValues')

// Force redirect
if (isOauth2) {
if (context.getters?.configuration?.auth?.logoutUrl) {
return (window.location = context.getters?.configuration?.auth?.logoutUrl)
} else if (context.getters?.configuration?.server) {
return (window.location = `${context.getters?.configuration?.server}/index.php/logout`)
}

// Force redirect to login
if (forceRedirect) {
router.push({ name: 'login' })
}
}
Expand Down