donqh00404 2012-07-10 12:34
浏览 11
已采纳

安全API(JSONP)仅检查域

I am building an API(PHP) which allows access only by domain names, how should I check the JSONP request origin?
And are there any security layers I could Implement? (I am not using keys currently*)


* = I want the users only to add the script tag, I don't want them to have to insert keys and get messed up - if you have any idea to make that happen and secure it I would be delighted to hear it.

  • 写回答

2条回答 默认 最新

  • douyiqi9640 2012-07-10 12:43
    关注

    The best you are going to get is to:

    Accept the request if the referer header is missing or set to a URL with a domain on your whitelist.

    This will stop people effectively using your API client side on HTTP sites.

    Some (relative small number of) users will have referers disabled. They will be able to use the API on any site that uses it (but since they are a minority, most sites won't want to depend on this as it will simply break for the majority of users).

    It won't stop people running an HTTPS website and using the API - but their users will be warned about a mix of secure and insecure content, so this is also an unattractive option.

    This won't stop people hitting your API server side, but you can combat that with IP based rate limiting.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作