身份服务器4中的静默令牌更新与js客户端应用程序无法正常工作

Mah*_*pta 6 access-token identityserver4 implicit-flow oidc-client-js

我正在与身份服务器4一起为企业架构中的不同应用提供身份服务。

使用oidc-client.js在身份服务器4应用程序中使用隐式流注册了SPA应用程序,并且正在运行。

但是问题在于令牌更新,需要长时间保留用户登录名而又不要求用户再次登录。

为此,请使用以下配置实施静默令牌续订。

var config = {
    authority: "http://localhost:5000",
    client_id: "jswebclient",
    redirect_uri: "http://localhost:5003/callback.html",
    response_type: "id_token token",
    scope: "openid profile api1",
    post_logout_redirect_uri: "http://localhost:5003/loggedout.html",
    automaticSilentRenew: true,
    silent_redirect_uri : "http://localhost:5003/callback.html" }; 
Run Code Online (Sandbox Code Playgroud)

var mgr = new Oidc.UserManager(config);

使用上述配置时,会发生自动续订,但没有按预期进行静默续订,正在发生将页面重定向到重定向uri的完整页面,以处理来自身份服务器的响应。

例如:index.html是我的实际页面,在其中进行静默更新,而callback.html是重定向uri,index.html重定向到callback.html,然后更新,然后重定向回到index.html,并附有实际的网络日志下面,在此处输入图片说明

任何人都可以帮助我解决问题以使更新无声发生吗?

Mah*_*pta 5

经过大量的搜索并参考了许多文章后,我发现了问题所在,这与配置有关,将配置更改为以下内容后,它可以正常工作

var config = {
    authority: "http://localhost:5000",
    client_id: "jswebclient",
    redirect_uri: "http://localhost:5003/callback.html",
    response_type: "id_token token",
    scope: "openid profile api1",
    post_logout_redirect_uri: "http://localhost:5003/loggedout.html",
    automaticSilentRenew: true,
    silent_redirect_uri: "http://localhost:5003/silentrenew.html"   
};

var mgr = new Oidc.UserManager(config);
Run Code Online (Sandbox Code Playgroud)

创建了一个新的silentrenew.html页面来处理静默更新响应,并在页面中添加了以下脚本

 <script>
    new Oidc.UserManager().signinSilentCallback();        
 </script>
Run Code Online (Sandbox Code Playgroud)

多数民众赞成在...它开始按预期方式工作。

  • silentrenew.html页面不需要OIDC配置信息吗?看起来仅在index.html页面中。 (2认同)