我正在开发一个使用Spring Boot和React.js SPA的web应用程序,但我的问题并不特定于这些库/框架,因为我假设向服务器报告客户端JS错误(用于记录和分析)肯定是许多现代web应用程序的常见操作。
因此,假设我们有一个捕获错误的JS客户端应用程序和一个REST端点/errors
,它接受一个JSON对象,该对象保存有关发生的事情的相关信息。客户端应用程序将数据发送到服务器,然后将数据存储在数据库中(或其他任何地方),每个人都很高兴,对吧?
现在我真的不是了。因为现在我有了一个开放的(就像允许未经身份验证的创建/写入操作) API端点,任何人只要有一点知识就可以很容易地发送垃圾邮件。
我可能会验证端点接受的JSON数据的结构,但这并不能真正解决问题。
在像"Open REST API attached to a database- what stops a bad actor spamming my db?“或"Secure Rest-Service before user authentification”这样的问题中,有这样的建议:
所以我的问题是:
发布于 2019-03-20 04:06:04
我已经看过三种不同的方式…
- For a logged in user, if an errors occurs you would hit the /error endpoint, and would authenticate using the existing user auth token.
- For a visitor, you can expose a /clientError (or named in a way that makes sense to you) endpoint that takes the client\_credentials token for the client app.
- This key would be specific to the client and would be pass in the header.
使用第三方工具或New Relic.等任何
https://stackoverflow.com/questions/55240505
复制相似问题