email - 在授权代码流程中使用时,id_token 是否应包含声明

标签 email oauth-2.0 openid claims userinfo

使用 response_type=code 对支持 OpenID 的 OAuth2 授权服务器进行身份验证后与 scope=openid email ,调用 token 端点应返回 id_token .

我缺少的是这是否id_token应该包含 email与否 - 在这种情况下,客户应调用 userInfo端点。

规范说:

http://openid.net/specs/openid-connect-core-1_0.html#ScopeClaims

The Claims requested by the profile, email, address, and phone scope values are returned from the UserInfo Endpoint, as described in Section 5.3.2, when a response_type value is used that results in an Access Token being issued. However, when no Access Token is issued (which is the case for the response_type value id_token), the resulting Claims are returned in the ID Token.



据我了解,这意味着 id_token不需要包含email如果 access_token可用作 userInfo应该被调用来获取它。然而,在 https://github.com/bitly/oauth2_proxy 中查看 oidc 客户端的实现看来他们确实需要 email声称在内部可用 id_token无需调用 userInfo端点。

OpenID 兼容授权服务器中的正确行为是什么?

最佳答案

openid 规范比 Google 或 Microsoft 正在做的更严格(可能其他提供商也是如此,但我没有检查)。
我猜 oauth2_proxy 保留了提供者的行为。
例如谷歌,返回 id_token交换时您要求的范围内的所有权利要求codeaccess_token .但是如果你阅读他们的文档,他们会指定 userInfo端点:
https://developers.google.com/identity/protocols/OpenIDConnect

我想只要你支持所有的端点,目标是否返回id_token连同所有权利要求以及 access_token你决定。它删除了对 userInfo 的一个额外调用。在大多数情况下,它不会暴露任何漏洞。

关于email - 在授权代码流程中使用时,id_token 是否应包含声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50740532/

相关文章:

javascript - Angularjs + Google oauth2 + 获取 id_token

GitHub 当有人关注我时收到一封电子邮件

email - 我是否需要将长度超过 72 个字符的电子邮件换行?

ruby-on-rails - 尝试连接到 Exchange 2003 IMAP 时邮件 gem SSL_read::版本号错误

android - 通过 playstore firebase oauth2 分发时谷歌登录不工作

github - 使用私有(private) github 进行 Teleport 社区身份验证

asp.net-mvc - 从自定义身份验证迁移到 Open ID

php - OpenID登录速度慢

php - 使用 openid-selector 在没有第三方的情况下实现社交登录

email - 电子邮件标题 “name <email>”的格式是什么?