如何安全地将CSRF令牌传递到单独的VueJS前端? [英] How to pass a CSRF token safely to a separate VueJS frontend?
问题描述
Laravel(后端)和VueJS(使用Vue CLI创建的前端)是分开的,因此具有不同的域和存储库.我想知道将CSRF令牌从Laravel安全地传递到VueJS的最佳方法是安全.
Laravel(backend) and VueJS(frontend created with Vue CLI) are separated, hence have different domains and repositories. I am wondering what is the best way to pass a CSRF token from Laravel to VueJS safely.
我在这里和《拉拉卡斯特》上都发现了一些老问题,但它们要么无关紧要,要么过时,要么没有答案.这里有一些:
I've found some old questions here and on Laracasts but they are either irrelevant, outdated or have no answer. Here are a few:
创建注册令牌从单独的前端应用程序中获取Laravel应用程序
我知道Laravel在VerifyCSRFToken中间件中附带了 $ except
数组.将前端的URL添加到此列表中会造成安全漏洞,对吗?
I am aware that Laravel ships with $except
array in VerifyCSRFToken middleware. Adding frontend's URL to this list will create a security flaw, am I correct?
推荐答案
在使用独立应用程序(vue,react,angular ....)的情况下,最好的解决方案是使用
In case of using a standalone application (vue, react, angular ....) the best solution is to use Laravel Passport instead of using CSRF tokens.
这篇关于如何安全地将CSRF令牌传递到单独的VueJS前端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!