dsb-norge / vue-keycloak-js

A Keycloak plugin for Vue 2
https://www.dsb.no
ISC License
272 stars 99 forks source link

Login success but redirect again. #188

Open joveth1 opened 7 months ago

joveth1 commented 7 months ago

I'm use vue2 , the config like this.

Vue.use(keycloak, {
  init: {
    checkLoginIframe: false,
    onLoad: 'login-required'
  },
  config: {
    url: process.env.VUE_APP_SUP_KEYCLOAK_URL,
    realm: process.env.VUE_APP_SUP_KEYCLOAK_REALM,
    clientId: process.env.VUE_APP_SUP_KEYCLOAK_CLIENTID
  },
  onReady: (keycloak) => {
    console.log(keycloak)
    setToken(KEYCLOAK + keycloak.token, true)
    new Vue({
      el: '#app',
      router,
      store,
      render: h => h(App)
    })
  }
})

When login success and redirect to the dashboard, It's will redirect to the keycloak page again with error :Invalid parameter: redirect_uri

The browser url like this: http://172.1.101.10:8780/realms/sup/protocol/openid-connect/auth?client_id=one-ui&redirect_uri=http%3A%2F%2Flocalhost%3A8011%2Fone%2Fdashboard%23iss%3Dhttp%253A%252F%252F172.1.101.10%253A8780%252Frealms%252Fsup%23reloaded&state=7687d636-a26f-4c23-8ed7-1d8a506ca399&response_mode=fragment&response_type=code&scope=openid&nonce=3d318315-ad02-4ea7-8a9c-ed208a8d1c3b

In my keycloak project ,I have set Valid redirect URIs to *

image

Need Help!

Thanks!

joveth1 commented 7 months ago

After change my project to "keycloak-js": "23.0.7" the result is ok. In network i saw two auth requests. In the dashboard the request like this:

http://172.1.101.10:8780/realms/sup/protocol/openid-connect/auth?client_id=onecode-ui&redirect_uri=http%3A%2F%2Flocalhost%3A8011%2Fone%2Fdashboard%23reloaded&state=d76ac084-5c37-4683-a3f4-40772be10aca&response_mode=fragment&response_type=code&scope=openid&nonce=af0b9667-8b94-44f0-8172-b139b3a626a9

Different is the iss param

Wilsonoonn commented 7 months ago

redirect URL 是你要跳转的项目地址,不能是*

akozlov99 commented 2 months ago

try to add useNonce: false in init section