1

我正在使用身份服务器4为企业架构中的不同应用程序提供身份服务。身份服务器4中的静默令牌续订js客户端应用程序未按预期工作

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

但问题在于令牌更新,需要长时间保持用户登录而无需再次请求用户登录。

为了使这种情况发生,使用以下配置实现静默令牌更新。

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" }; 

var mgr = new Oidc.UserManager(config);

与上述配置自动更新正在发生的事情,但它不是沉默的更新,这是预期的,完整的页面重定向到重定向URI是发生在处理从身份服务器响应。

对于例如:index.html是我的实际页面,其中发生无声续约,callback.html是重定向URI,index.html被重定向到callback.html,然后更新,然后重定向回到index.html,实际网络日志附在下面,enter image description here

任何人都可以帮我解决问题,使无声更新发生。

回答

1

google搜索了很多,提到了许多文章后,我发现了这个问题,这与配置,更改配置到下面

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); 

后曾创造了一个新的silentrenew.html页面来处理无声续约响应,并在页面中添加下面的脚本

<script> 
    new Oidc.UserManager().signinSilentCallback();   
</script> 

这就是所有......它开始按预期工作。

相关问题