Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个像这样的网址:
http://example.com/get-users
它返回所有用户的 JSON 对象。但是,我不希望任何人(或任何机器人)能够访问此 url 来获取此信息。我希望它只响应来自同一网站中其他本地模块的调用。
我将如何实施这样的事情?
将 REMOTE_ADDR 与已批准 IP 的白名单进行比较。如果它不在该列表中,则只需不返回任何内容、关闭套接字或返回 HTTP 错误。
你用的是弹簧吗?是否考虑过在您的上下文中添加过滤器 bean 以仅允许来自您站点的 HTTP 请求?