【问题标题】:automaticSilentRenew not working for angular oidc-client libraryautomaticSilentRenew 不适用于角度 oidc-client 库
【发布时间】:2021-01-11 15:27:44
【问题描述】:

我使用 "oidc-client": "1.10.1" 进行 oidc 身份验证,下面是我对 userManager 的配置

const settings = {
    
    authority: (window as any).__env.auth.authority, //OAuth 2.0 authorization endpoint of the OpenID Provider
    
    client_id: (window as any).__env.auth.clientID, //
    
    redirect_uri: (window as any).__env.auth.redirectUri, //callback URI for the authentication response
    
    response_type: 'id_token token',
    
    scope: 'openid profile api',
    
    automaticSilentRenew: true,
    
    silent_redirect_uri: (window as any).__env.auth.silentRedirectUri,
    
    userStore: new WebStorageStateStore({ store: window.localStorage }),
    
    loadUserInfo: true,
    
    post_logout_redirect_uri: (window as any).__env.auth.postLogoutRedirectUri,
    
    silentRequestTimeout: 30000,
    
};

甚至没有进行静默更新令牌调用,即用户在令牌到期后注销。我错过了什么吗?

附:我想让令牌自动更新工作,因为我手动尝试了令牌更新,它确实有效,但似乎不是一种可靠的方法。

【问题讨论】:

    标签: angular openid-connect oidc-client-js


    【解决方案1】:

    这里有几件事要检查:

    • 是否正在发送续订消息?浏览器工具或 Fiddler 等代理应该会为您提供一些信息。

    • 您是否从 OIDC 客户端日志中获得有关错误或计时器触发的任何信息?控制台输出可能会有所帮助。

    • 您是否正在处理续订回复?您通常需要调用用户 manager.signInSilentCallback。

    • 或者可能只是因为令牌不在到期后 5 分钟内而没有发生续订。

    我的资源

    请注意,在我的情况下,我没有使用单独的 HTML 文件进行续订,而是使用 index.html 和 this startup code

    【讨论】:

    • 我确实让它手动工作并且工作正常,但不知何故甚至没有调用自动更新,我已经仔细查看了网络日志,如果它失败了我可以在网络中看到,但是甚至没有提出静默续订请求。
    • 服务器端访问令牌的生命周期也只有 30 分钟,这可能是个问题吗?
    • 我相信只有在令牌距离到期不到几分钟时才会触发续订。尝试将访问令牌生命周期配置为一个较小的值,例如 5 分钟,我认为您会看到一些请求触发 - OIDC 客户端日志条目将显示一些计时器事件触发并且在令牌接近到期之前什么都不做 - 见上文截图。
    猜你喜欢
    • 2021-02-06
    • 2021-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-12
    • 2020-02-05
    • 2019-02-14
    • 2019-07-21
    相关资源
    最近更新 更多