Comments (5)
@MarcelCode import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import VueKeyCloak from '@dsb-norge/vue-keycloak-js'
import type { KeycloakInstance } from "keycloak-js";
const app = createApp(App)
.use(VueKeyCloak, {
config: {
realm: "dss",
url: import.meta.env.VITE_KEYCLOAK_BASE_URL,
clientId: "dss-frontend",
},
init: {
onLoad: 'check-sso',
silentCheckSsoRedirectUri: window.location.origin + "/silent-check-sso.html",
checkLoginIframe: false,
silentCheckSsoFallback: false,
redirectUri: import.meta.env.VITE_APP_BASE_URL + '/console',
token:token,
refreshToken:refreshToken
},
onReady(keycloak: KeycloakInstance) {
if (keycloak.authenticated) {
console.log('Authenticatied')
}
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.requiresAuth)) {
if (keycloak.authenticated) {
return next();
} else {
let loginUrl = keycloak.createLoginUrl();
window.location.replace(loginUrl)
}
} else {
return next();
}
})
app.use(router)
.use(vuetify)
app.mount("#app");
}
})
`
One way I was able to make it work was by using the router navigation guard this way
from vue-keycloak-js.
@djdemarco Did you found any solutions to this issue ?
from vue-keycloak-js.
It would be really great if someone can give an example how to use it with the router in vue3
from vue-keycloak-js.
@djdemarco Did you found any solutions to this issue ?
I moved on to using another library since we will be using Nuxt 3 for the framework. Also, in the future we might switch to another authentication provider other than Keycloak so it's best to use a library that can cater to a wide range of identity providers. I'm using this now instead: https://github.com/sidebase/nuxt-auth
Nuxt 3's support of its native auth module is still in the planning stages as stated here: https://github.com/sidebase/nuxt-auth. Hence the need to use another library for authentication.
from vue-keycloak-js.
I moved on to using another authentication library instead
from vue-keycloak-js.
Related Issues (20)
- For my keycloak version (18), the url configuration should not have "/auth" in the vite_vue3 example HOT 1
- Vue3 HOT 1
- Configurable token update interval
- The Vue 3 injection Symbol should be in a separate file and exported HOT 7
- Implementing PKCE with vue-keycloak-js HOT 2
- Always Redirect with URL #error=login_required HOT 3
- [vite] Internal server error: Failed to resolve import "@dsb-norge/vue-keycloak-js/dist/types" from "src/main.ts". Does the file exist? HOT 2
- [question] Where can I get an indication that the token has expired as a basis for jumping to the login
- Vue3 Support
- Support for Keycloak v21 HOT 1
- Cannot use namespace 'Keycloak' as a type HOT 2
- [question] Why and how do I prevent a blank page when the Keycloak server is not available? Vue, Keycloak, Quasar
- Refresh the system page and automatically add a hash parameter after the URL. How to remove the following parameters
- js-sha256 warning
- vue3 enable to use HRM HOT 1
- Vue Keycloak variable is undefined.
- Issuer displayed in browser URL after login? HOT 3
- Login success but redirect again. HOT 2
- requestStorageAccess errors and keycloak init errors on Chrome HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-keycloak-js.