0

I am authenticating my Nuxt App with Keycloak through the Auth Module for Nuxt.js. (https://auth.nuxtjs.org/)

When the access type of my Keycloak client is set to public, everything is working as intended. Now I am trying to set the access type of my Keycloak client to confidential. But it is not working. After successfully login in my Nuxt App is caught in a Redirect Loop.

Are any of my configurations wrong or did I forget something?

Here are my OAuth2 scheme configurations:

 auth: {
    cookie: {
      options: {
        HttpOnly: false,
        Secure: true
      }
    },
    strategies: {
      local: false,
      keycloak: {
        scheme: 'oauth2',
        endpoints: {
          authorization: `${process.env.KEYCLOAK_HOST}/auth/realms/${process.env.KEYCLOAK_REALM}/protocol/openid-connect/auth`,
          userInfo: `${process.env.KEYCLOAK_HOST}/auth/realms/${process.env.KEYCLOAK_REALM}/protocol/openid-connect/userinfo`,
          token: `${process.env.KEYCLOAK_HOST}/auth/realms/${process.env.KEYCLOAK_REALM}/protocol/openid-connect/token`,
          logout: `${process.env.KEYCLOAK_HOST}/auth/realms/${process.env.KEYCLOAK_REALM}/protocol/openid-connect/logout?redirect_uri=` +
              encodeURIComponent(process.env.FRONTEND_SCHEME + '://' + process.env.FRONTEND_HOST)
        },
        token: {
          property: 'access_token',
          type: 'Bearer',
          name: 'Authorization',
          maxAge: 1800
        },
        refreshToken: {
          property: 'refresh_token',
          maxAge: 60 * 60 * 24 * 30
        },
        responseType: 'code',
        grantType: 'authorization_code',
        clientId: `${process.env.KEYCLOAK_CLIENT_ID}`,
        clientSecret: `${process.env.KEYCLOAK_CLIENT_SECRET}`,
        scope: ['openid', 'profile', 'email'],
        codeChallengeMethod: 'S256',
        vuex: {
          namespace: 'auth'
        },
        redirect: {
          login: '/login',
          logout: '/',
          callback: '/',
          home: '/'
        }
      }
    }
  },

Here are my Keycloak client settings

I tried adding the clientSecret to my OAuth2 configurations but it didn't help either. Even if it helped I am asking myself if it is the correct way to have confidential data in my Nuxt App.

Ocean
  • 1
  • 1

1 Answers1

0

It's unclear which nuxt version you are using and keycloak version. Can this demo help you? https://github.com/Kingside88/nuxt3-primevue-starter-auth