首页 > 解决方案 > signinSilent 不起作用(openID Connect)

问题描述

我在我的 React 项目中实现了 oidc。

它适用于signinRedirect和 to signoutRedirect,也automaticSilentRenew设置为 true 并且有效。

问题是它signinSilent不起作用。

我使用有效令牌登录另一个选项卡,在当前选项卡中我收到: 在此处输入图像描述

我的授权文件包含所有重定向 uri(redirect_uri、post_logout_redirect_uri、silent_redirect_uri 等)

在页面加载时,我正在调用一个 init() 函数,其中包含使用 oidc 进行静默登录的逻辑:

{
    return _mgr
        .signinRedirectCallback()
        .then(user => {
            // if this is a signin redirect action then set the user info
            console.log('signinRedirectCallback: Successful redirect signin.', user);
            return (_user = user);
        })
        .catch(error => {
            // otherwise this is a page reload
            console.log('signinRedirectCallback: Page reload.', error);

            // Execute logic to check if the user is still authenticated, it invokes a silent signin call which happens through an iFrame.
            return _mgr
                .signinSilent({ redirect_uri: _config.oidc.silent_redirect_uri })
                .then(user => {
                    // if user is still authenticated then set the user info
                    console.log('signinSilent:  Page reload. Successful silent signin.', user);
                    user.profile.given_name = user.profile.preferred_username;
                    return (_user = user);
                })
                .catch(error => {
                    // otherwise unset user info
                    console.log('signinSilent: Page reload.', error);
                    _user = null;
                    return Promise.reject(error);
                });
        })
}

如何删除此“框架窗口超时”并使静默登录成功?

标签: openid-connect

解决方案


您正在使用哪个授权服务器以及什么令牌存储模型(在内存、会话存储等中)?

它可能与试图呈现登录页面的 AS 相关 - 即使 OIDC 客户端在静默重定向上发送 prompt=none 也是如此。


推荐阅读