http - 我应该在 OAuth 2 回调中验证 HTTP Referer 吗?

标签 http authentication oauth http-headers oauth-2.0

我能够使用我的 Oauth2 servlet 成功验证 Facebook 和 Google 帐户。我正在使用带有计时器和 session cookie 的状态来尝试验证它确实是合法的 Oauth 回调。

  1. 如果我还检查 HTTP Referer header 以确保我是从提供商的 OAuth 页面重定向过来的,是否有任何好处?

  2. 如果没有好处,如果我也检查 HTTP Referer 字段会不会有问题?

最佳答案

没有。

  1. 作为恶意攻击者,我可以模拟任何我想要的 header 。我可以让它看起来像是来自 http://cia.fbi.gov.vpn/uber1337h4x。这是显而易见的,也是众所周知的。

  2. 任何来自 HTTPS 的页面都不会根据 RFC2616 sec15 发送引用 header :

    Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

  3. 根据 RFC2616 sec15 中断可用性:

    Because the source of a link might be private information or might reveal an otherwise private information source, it is strongly recommended that the user be able to select whether or not the Referer field is sent.

简而言之,您没有获得更高的安全性。您的安全性不在于检查极其不安全的传输协议(protocol),而在于 OAuth 层。您还会破坏可用性。

不要这样做。

关于http - 我应该在 OAuth 2 回调中验证 HTTP Referer 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9932679/

相关文章:

python - 4 月份的 urlfetch 更改和 simpleoauth

java - Android - 选择 HTTP Java 库

ruby-on-rails - Ruby on Rails 和 Cocoa

http - 当tomcat停止时请求会发生什么

authentication - 如何使用 Passport.js 访问 OAuth 的状态参数?

java - 为什么我在访问 token 时在 Spring Oauth2 中出现未经授权的 401 错误?

OAuth - 访问 token 有效期?

http - URL 重写 web.config 位置 https

javascript - 绕过 SSO 的 cypress 脚本示例

c# - 将 mvc 5 adfs 转换为 .net 核心 adfs