在 SameSite=Lax 的情况下使用 oidc-client 进行静默续订

Posted

技术标签:

【中文标题】在 SameSite=Lax 的情况下使用 oidc-client 进行静默续订【英文标题】:Silent Renew using oidc-client in case SameSite=Lax 【发布时间】:2020-04-14 16:15:40 【问题描述】:

Chrome 计划在 2020 年 2 月为 Chrome 80 实施新的默认安全模型。 现在我正在测试我们所有可能受到影响的应用程序。

对于身份验证/授权,我们在后端使用 oidc-client(在 UI 上)和 IndentityServer。

工作流程如下:

请求

发布http://my_identity_server/api/authenticate 用户名,密码

回复

设置 Cookie:idsrv=abc

"redirectUrl":"http://my_identity_server/connect/authorize/callback?client_id=MyApplication&response_type=id_tokentoken&scope=openid"

请求

http://my_identity_server/connect/authorize/callback?client_id=MyApplication&response_type=id_tokentoken&scope=openid" Cookie:idsrv=abc

回复

302 位置:http://myApplication/#id_token=123&access_token=456&token_type=Bearer

请求

http://myApplication/#id_token=123&access_token=456&token_type=Bearer

当应用程序被加载时,Oidc-client 添加 IFrame 来执行实际上发送额外请求

的silentRenew

GET http://my_identity_server/connect/authorize?client_id=MyApplication&response_type=id_token token&prompt=none Cookie:idsrv=abc

我不明白为什么最后一个请求在 IFrame 中包含 idsrv cookie? 该请求是在 IFrame 内完成的,它绝对是第三方 cookie。 如果我将 SameSite 设置切换为“严格”,一切都按预期工作,cookie 不会发送。

如果有人可以向我解释这个案例或提出一些想法来检查,那就太好了!谢谢!

【问题讨论】:

【参考方案1】:

OIDC 客户端库使用 OIDC 会话管理来跟踪使用 OP iframe 和 client(RP) iframe 完成的会话。

身份服务器为此目的发出 idsrv:session cookie

检查这个 https://medium.com/@piraveenaparalogarajah/openid-connect-session-management-dc6a65040cc

【讨论】:

以上是关于在 SameSite=Lax 的情况下使用 oidc-client 进行静默续订的主要内容,如果未能解决你的问题,请参考以下文章

怎样限制第三方Cookie

即使指定了 samesite=none,浏览器也会使用 samesite=lax

此 Set-Cookie 未指定“SameSite”属性,默认为“SameSite=Lax”-Localhost

对于未来chrome80 samesite问题的兼容解决方案

dajngo设置cookie的samesite属性

dajngo设置cookie的samesite属性