CSRF(Cross Site Request Forgery)也就是跨站請求偽造,實現的原理是CSRF攻擊者在用戶已經登錄目標網站之后,誘使用戶訪問一個攻擊頁面,利用目標網站對用戶的信任,以用戶身份在攻擊頁面對目標網站發起偽造用戶操作的請求,達到攻擊目的;
'django.middleware.csrf.CsrfViewMiddleware'
{# #} {% csrf_token %}from django.views.generic import Viewfrom django.utils.decorators import method_decoratorfrom django.views.decorators.csrf import csrf_exemptclass CSRFTestView(View): @method_decorator(csrf_exempt) def dispatch(self, request, *args, **kwargs): return super().dispatch(request, *args, **kwargs) def post(self, request): pass
from django.views.generic import Viewfrom django.utils.decorators import method_decoratorfrom django.views.decorators.csrf import csrf_protectclass CSRFTestView(View): @method_decorator(csrf_protect) def dispatch(self, request, *args, **kwargs): return super().dispatch(request, *args, **kwargs) def post(self, request): pass
csrf解決方法。Postman是一種網頁調試與發送網頁http請求的chrome插件,可以用來很方便的模擬get、post、put、patch、delete、copy等多種方式的請求來調試接口;
postman可用作macOS,Windows和Linux操作系統的本機應用程序。Windows系統下安裝postman只需要下載安裝文件,然后運行安裝程序就可以了;
vue csrf、Postman的下載地址:https://www.getpostman.com/downloads/
參考:https://www.9xkd.com/user/plan-view.html?id=1091380484
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态