authentication - StackOverflow 是否使用 OpenID Connect 进行 Google 登录?
问题描述
我试图更好地了解 OAuth2 和 OpenID Connect,因此我决定在使用 Google 帐户登录 StackOverflow 时查看 Chrome 的开发人员工具中显示的内容。
点击 Google 按钮登录后,会发出以下 5 个网络请求:
请注意,我已经登录 Google 并且之前已授权 StackOverflow。
1) 204 POST https://stackoverflow.com/gps/event
Request Payload:
...
properties:
location: "users_login"
openid_provider: "google"
2) 302 POST https://stackoverflow.com/users/login?...
Query String Parameters:
ssrc: head
returnurl: https://stackoverflow.com/
Form Data:
email:
password:
oauth_version: 2.0
oauth_server: https://accounts.google.com/o/oauth2/auth
openid_username:
openid_identifier:
3) 302 GET https://accounts.google.com/o/oauth2/auth?...
Query String Parameters:
client_id: xxxx
scope: profile email
redirect_uri: https://stackauth.com/auth/oauth2/google
state: {"sid":1,"st":"xxxx","ses":"xxxx"}
response_type: code
4) 302 GET https://stackauth.com/auth/oauth2/google?...
Query String Parameters:
state: {"sid":1,"st":"xxxx","ses":"xxxx"}
code: xxxx
5) 302 GET https://stackoverflow.com/users/oauth/google?...
Query String Parameters:
code: xxxx
state: {"sid":1,"st":"xxxx","ses":"xxxx"}
s: xxxx
从请求 1) 看来,使用了 OpenID Connect。但是再看请求 3),请求的范围是scope: profile email
.
如果实际使用了 OpenID Connect,是否不会openid
包含在范围内?没有它,token
端点将不会返回一个id_token
权利?
这是否意味着 StackOverflow 实际上并没有使用 OpenID Connect 来验证使用 Google 登录的用户,而是利用普通的旧 OAuth2?
如果是这样,我假设在 OpenID Connect 出现之前,普通的旧 OAuth2 通常用于身份验证(以安全方式)?
解决方案
看起来 StackOverflow 正在使用 Google 作为提供者进行简单的 OAuth 2.0 授权代码流。
请求 1) 将发送到 StackOverflow 服务器。这并不意味着什么。您可以看到,如果您在 Facebook 上按一下,
openid_provider: "facebook"
即使 Facebook 没有实现 OpenID Connect,您也会得到。
StackOverflow 正在实现类似的东西: https://developers.google.com/identity/sign-in/web/server-side-flow 但只是使用重定向而不是使用谷歌库
OAuth 2.0 授权代码流程解释: https ://aaronparecki.com/oauth-2-simplified/#web-server-apps
推荐阅读
- java - 如何实现加密的共享偏好
- google-cloud-platform - GCP 中是否有任何 API 可以获取资源使用详细信息..?
- reactjs - 谁能告诉我在 ReactJs 中开发单独的未定义组件的正确方法
- mysql - mysql if value = "0" 然后获取其他值
- mongodb - Spring Data 线程的版本注释对 Mongodb 是否安全?
- java - 如何为 Jenkins 设置 JDK 8 和为构建作业设置 JDK 14?
- node.js - pm2 显示状态“在线”,但该站点无法正常工作
- python - 将参数传递给烧瓶 GET 函数
- c# - 我应该如何在 WebAPI 集成测试中断言?
- apache-flink - Apache Flink 读取至少 2 条记录来触发 sink