-
Notifications
You must be signed in to change notification settings - Fork 98
Open
Description
Im relative new to vue and i am trying to connect my Vue Application based on Quasar with Keycloak. I followed this tutorial and used the dsb-norge/vue-keycloak-js library.
Everything works in case, the Keycloak server is reachable.
Now, of course, it is possible that the server is unreachable for some reason, such as DNS problems. In this case i got a blank white page instead of showing the page without working login button. With using the onInit Option from the library i can catch the error but very lately and still the page is blank.
How can the page still loaded and show content just without a working login button if the keycloak server is unreachable/not able to process my request?
//keycloak.ts
import VueKeyCloak from '@dsb-norge/vue-keycloak-js'
import { boot } from 'quasar/wrappers';
import { VueKeycloakInstance } from '@dsb-norge/vue-keycloak-js/dist/types';
import { api } from 'boot/axios';
import {InternalAxiosRequestConfig} from 'axios';
export default boot(async ({ app}) => {
function registerTokenInterceptor () {
app.provide('keycloak', app.config.globalProperties.$keycloak);
api.interceptors.request.use((config: InternalAxiosRequestConfig) => {
if (app.config.globalProperties.$keycloak.authenticated) {
config.headers.Authorization = `Bearer ${app.config.globalProperties.$keycloak.token}`
}
return config
}, error => {
return Promise.reject(error)
}) //null, { synchronous: true })
}
return new Promise(resolve => {
app.use(VueKeyCloak, {
init: {
checkLoginIframe: false, // or 'login-required'
flow: 'standard',
onLoad: 'check-sso',
pkceMethod: 'S256',
silentCheckSsoRedirectUri: window.location.origin + '/silent-check-sso.html'
},
config: {
url: 'http://localhost:8080/auth',
realm: 'master',
clientId: 'testclient',
},
logout: {
redirectUri: 'http://localhost:9000',
},
onReady() {
registerTokenInterceptor()
resolve()
}
})
})
})
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$keycloak: VueKeycloakInstance
}
}```
Metadata
Metadata
Assignees
Labels
No labels