boke练习: springboot整合springSecurity出现的问题,传递csrf
boke练习: springboot整合springSecurity出现的问题,传递csrf
freemarker模板
在html页面中加入:
<input name="_csrf" type="hidden" value="${_csrf.token}">
<input name="_csrf_header" type="hidden" value="${_csrf.headerName}"/>
在ajax代码中加入, beforeSend或headers
beforeSend: function(request) {
request.setRequestHeader(data.field._csrf_header, data.field._csrf);
},
如下
ajax({
type: 'POST',
url: "/comment", // ajax请求路径
data: {
blogId: data.field.blogId,
commentContext: data.field.desc,
},
beforeSend: function(request) {
request.setRequestHeader(data.field._csrf_header, data.field._csrf);
},
success: function(data){
layer.msg("评论成功!");
showComments(${blogModel.id});
},error:function()
{
layer.msg("评论失败!");
}
});
boke练习: springboot整合springSecurity出现的问题,传递csrf的更多相关文章
- SpringBoot整合SpringSecurity简单实现登入登出从零搭建
技术栈 : SpringBoot + SpringSecurity + jpa + freemark ,完整项目地址 : https://github.com/EalenXie/spring-secu ...
- SpringBoot整合SpringSecurity示例实现前后分离权限注解
SpringBoot 整合SpringSecurity示例实现前后分离权限注解+JWT登录认证 作者:Sans_ juejin.im/post/5da82f066fb9a04e2a73daec 一.说 ...
- 9、SpringBoot整合之SpringBoot整合SpringSecurity
SpringBoot整合SpringSecurity 一.创建项目,选择依赖 选择Spring Web.Thymeleaf即可 二.在pom文件中导入相关依赖 <!-- 导入SpringSecu ...
- boke练习: springboot整合springSecurity出现的问题,post,delete,put无法使用
springboot 与 SpringSecurity整合后,为了防御csrf攻击,只有GET|OPTIONS|HEAD|TRACE|CONNECTION可以通过. 其他方法请求时,需要有token ...
- SpringBoot整合SpringSecurity实现JWT认证
目录 前言 目录 1.创建SpringBoot工程 2.导入SpringSecurity与JWT的相关依赖 3.定义SpringSecurity需要的基础处理类 4. 构建JWT token工具类 5 ...
- springboot整合springsecurity遇到的问题
在整合springsecurity时遇到好几个问题,自动配置登录,下线,注销用户的操作,数据基于mybatis,模版引擎用的thymeleaf+bootstrap. 一.认证时密码的加密(passwo ...
- SpringBoot 整合 SpringSecurity 梳理
文档 Spring Security Reference SpringBoot+SpringSecurity+jwt整合及初体验 JSON Web Token 入门教程 - 阮一峰 JWT 官网 Sp ...
- SpringBoot整合SpringSecurity简单案例
在我们开发项目的过程中经常会用到一些权限管理框架,Java领域里边经常用的可能就是shiro了,与之对应的还有SpringSecurity,SpringSecurity可以说是非常强大,与Spring ...
- SpringBoot整合SpringSecurity,SESSION 并发管理,同账号只允许登录一次
重写了UsernamePasswordAuthenticationFilter,里面继承AbstractAuthenticationProcessingFilter,这个类里面的session认证策略 ...
随机推荐
- python,pycharm安装
下载python地址:https://www.python.org/downloads/release/python-371/ 安装python ***python安装目录下的scripts加入环境变 ...
- Python3 tkinter基础 Canvas create_rectangle 画虚边的矩形 create_oval 画椭圆形 圆形
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python 处理 CSV/EXCEL 表格文件
只想说,数据挖掘工作,80%时间都花在处理数据上了,这句话真不假! 最近和小伙伴组了个队参加数据分析比赛,记录下我处理 csv 文件的一些步骤吧: 修改csv文件 可以用csv模块1,官方文档2 im ...
- POJ 3250 Bad Hair Day【单调栈入门】
Bad Hair Day Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 24112 Accepted: 8208 Des ...
- 【ContextLoaderListener】Web项目启动报错java.lang.ClassNotFoundException: ContextLoaderListener
错误原因: 进入到tomcat的部署路径.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\下检查了一下,发现工程部署后在WE ...
- 题解——CF Manthan, Codefest 18 (rated, Div. 1 + Div. 2) T2(模拟)
题目要求很简单,做法很粗暴 直接扫一遍即可 注意结果会爆int #include <cstdio> #include <algorithm> #include <cstr ...
- [蓝桥] 基础练习 十进制转十六进制 (java)
问题描述 十六进制数是在程序设计时经常要使用到的一种整数的表示方式.它有0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F共16个符号,分别表示十进制数的0至15.十六进制的计数方法是满1 ...
- [js] - js中类(伪)数组装正规数组
今天的js中使用了自定义的原型方法去重后,再调用这个获取的去重的数组传入另一个含有for循环的方法时, console.log出错: dimensions:createTime,华联石化,海油石化,青 ...
- HDU 4656 Evaluation(MTT)
题意 \(x_k=bc^{2k}+d\) \(\displaystyle F(x)=\sum_{i=0}^{n-1}a_ix^i\) 给定 \(\{a\},b,c,d,n\) ,求 \(F(x_0), ...
- HDU 6096 String(AC自动机+树状数组)
题意 给定 \(n\) 个单词,\(q\) 个询问,每个询问包含两个串 \(s_1,s_2\),询问有多少个单词以 \(s_1\) 为前缀, \(s_2\) 为后缀,前后缀不能重叠. \(1 \leq ...