php 中 HTTP_REFERER 的其他选项是什么?

发布于 2024-09-03 08:06:03 字数 241 浏览 7 评论 0原文

我想知道 $_SERVER['HTTP_REFERER'] 是否有任何选项/工作环境。因为“HTTP_REFERER”不可信。 那么还有什么其他方法可以知道请求来自哪个 url?

情况是这样的—— http://abc.com/one.html 将有一个 iframe,其 src=http://xyz.com/giv.php?param=1。 xyz.com 上的 giv.php 如何知道请求来自 http://abc.com/one.html?

I want to know is there any option/work sround for $_SERVER['HTTP_REFERER']. Because 'HTTP_REFERER' can not be trusted.
Then What is other way to know that from which url the request has came from?.

Here is the situation -
http:// abc.com/one.htmlwill have an iframe having src=http:// xyz.com/giv.php?param=1.
How giv.php on xyz.com will know that request is coming from http:// abc.com/one.html?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

旧竹 2024-09-10 08:06:03

抱歉,没有其他办法了。欢迎来到互联网

Sorry, there is no other way. Welcome to the Internet

守不住的情 2024-09-10 08:06:03

这看起来可能是一个 XY 问题

如果 X 是

如何阻止未经授权的网站构建我的内容并将其呈现给毫无戒心的用户?

那么推荐人就“足够好”了。

要伪造引用者,用户必须参与。未经授权的网站无法告诉用户的浏览器发送虚假引荐来源网址。

This looks like it might be an X-Y problem.

If X is

How can I stop unauthorized websites framing my content and presenting it to their unsuspecting users?

Then the referer is "good enough".

For the referer to be forged, the user has to participate. The unauthorised website can't tell the user's browser to send a false referer.

渡你暖光 2024-09-10 08:06:03

如果您确实想要信任,那么:

  • 服务器和浏览器之间的所有通信都需要通过 HTTP 完成
  • abc.com 需要从 xyz.com 请求唯一的标识符令牌(可能在消息中包含客户端 IP 地址,但可以意识到某些客户端会循环 IP 地址)
  • 该令牌需要包含在 iframe 的 xyz.com URL 中(例如,在查询字符串中),以便服务器可以对其进行身份验证

即使如此,该令牌也可能会被用户泄露(或者故意或通过安装在其系统上的恶意软件)。

If you really want trust, then:

  • All communication between the servers and the browser needs to be done over HTTPs
  • abc.com needs to request a unique identifier token from xyz.com (possibly with the client IP address included in the message, but be aware that some clients cycle IP addresses)
  • That token needs to be included in the xyz.com URL of the iframe (e.g. in the query string) so that the server can authenticate it

Even then, the token can be leaked by the user (either intentionally or through malware installed on their system).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文