0

如果用户未经授权,我想在进入应用程序时进行自动登录。我的应用程序使用 Keycloak 完全关闭。我需要如果用户没有登录,他不会被重定向到 /login 页面,而是直接到 keycloak 登录页面

nuxt.config.js

auth: {
strategies: {
  local: false,
  keycloak: {
    scheme: 'oauth2',
    endpoints: {
      authorization: `http://localhost:8081/auth/realms/web/protocol/openid-connect/auth`,
      userInfo: `http://localhost:8081/auth/realms/web/protocol/openid-connect/userinfo`,
      token: `http://localhost:8081/auth/realms/web/protocol/openid-connect/token`,
      logout:
        `http://localhost:8081/auth/realms/web/protocol/openid-connect/logout?redirect_uri=` +
        encodeURIComponent(String('localhost:3000')),
    },
    token: {
      property: 'access_token',
      type: 'Bearer',
      name: 'Authorization',
      maxAge: 300,
    },
    refreshToken: {
      property: 'refresh_token',
      maxAge: 60 * 60 * 24 * 30,
    },
    responseType: 'code',
    grantType: 'authorization_code',
    clientId: 'web',
    scope: ['openid', 'profile', 'email'],
    codeChallengeMethod: 'S256'
  },
},
redirect: {
  login: '/login',
  home: '/',
  callback: false,
},

},

我该怎么做?

4

0 回答 0