CSRF issue with Spring + Angular 2 + Oauth2 + CORS

谁都会走 提交于 2019-12-03 11:39:32

Ad.2. Your code is perfectly valid and you set everything correctly. CSRF protection in spring is designed with frontend in the same domain as backend. As Angular has no access to CSRF data it obviously can't set it in the modifying requests. And without setting them in server filter in regular headers (not cookie) it is no way to access them.

Ad.1. Security of JWT tokens is good enough as big companies use them successfully. However, remember that token itself should be signed with RSA key (not simpler MAC key) as well as all communication must go through secured connections (https/ssl). Usage of refresh tokens always reduces security slightly. Business application usually omits them. General audience applications have to store them securely and nevertheless have the option to drop they validity in case of abuse.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!