1

我有一个小应用程序可以通过后端vue对用户进行身份验证。Keycloakoidc-client用来将客户端重定向到身份验证页面。

每当登录逻辑触发时,URL 使用客户端的 url 而不是权限。(所有查询参数都是正确的)。

这是浏览器上的网址:

在此处输入图像描述

这是我的代码(简化且没有 URL):

import Oidc from "oidc-client";

let config = {
    authority: "http://XXX.XXX.XXX.XXX:9855/auth/realms/AvosetGo_Tests",
    client_id: "CLIENT-ID",
    redirect_uri: "localhost:4200/callback",
    response_type: "code",
    scope: "openid profile email",
    post_logout_redirect_uri: "http://localhost:4200/",
    automaticSilentRenew: true,
    filterProtocolClaims: true,
    loadUserInfo: true
};
const mgr = new Oidc.UserManager(config);

export const authManager = {
    signin: async () => {
        const user = await mgr.getUser();
        console.log("this is is " + user);
        if (!user) {
            await mgr.signinRedirect();
        }
    }
}

4

0 回答 0