如何安全地将CSRF令牌传递到单独的VueJS前端? [英] How to pass a CSRF token safely to a separate VueJS frontend?

查看:98
本文介绍了如何安全地将CSRF令牌传递到单独的VueJS前端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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:

将csrf令牌从Laravel传递到Vue

创建注册令牌从单独的前端应用程序中获取Laravel应用程序

(Laracasts论坛)CSRF在单独的角度应用程序中

我知道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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆