Created
October 5, 2020 14:00
-
-
Save alvistar/b7adad5eb086915a67ad316452e86b8a to your computer and use it in GitHub Desktop.
Nuxtjs Logout Fix for Keycloak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Oauth2Scheme from '@nuxtjs/auth-next/dist/schemes/oauth2' | |
import { encodeQuery } from '@nuxtjs/auth-next/dist/utils' | |
export default class KeycloakScheme extends Oauth2Scheme { | |
logout () { | |
if (this.options.endpoints.logout) { | |
const opts = { | |
client_id: this.options.clientId, | |
post_logout_redirect_uri: this._logoutRedirectURI | |
} | |
const url = this.options.endpoints.logout + '?' + encodeQuery(opts) | |
window.location.replace(url) | |
} | |
return this.$auth.reset() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build: { | |
transpile: ['@nuxtjs/auth-next'], | |
}, | |
auth: { | |
redirect: { | |
callback: '/callback' | |
}, | |
strategies: { | |
keycloak: { | |
scheme: '~/plugins/keycloak.ts', | |
endpoints: { | |
authorization: 'http://localhost:8081/auth/realms/vue/protocol/openid-connect/auth', | |
token: 'http://localhost:8081/auth/realms/vue/protocol/openid-connect/token', | |
userInfo: 'http://localhost:8081/auth/realms/vue/protocol/openid-connect/userinfo', | |
logout: 'http://localhost:8081/auth/realms/vue/protocol/openid-connect/logout' | |
}, | |
token: { | |
property: 'access_token', | |
type: 'Bearer' | |
}, | |
codeChallengeMethod: 'S256', | |
scope: ['openid', 'profile', 'email'], | |
accessType: 'offline', | |
responseType: 'code', | |
clientId: 'vue-client', | |
grantType: 'authorization_code' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment