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的更多相关文章

  1. SpringBoot整合SpringSecurity简单实现登入登出从零搭建

    技术栈 : SpringBoot + SpringSecurity + jpa + freemark ,完整项目地址 : https://github.com/EalenXie/spring-secu ...

  2. SpringBoot整合SpringSecurity示例实现前后分离权限注解

    SpringBoot 整合SpringSecurity示例实现前后分离权限注解+JWT登录认证 作者:Sans_ juejin.im/post/5da82f066fb9a04e2a73daec 一.说 ...

  3. 9、SpringBoot整合之SpringBoot整合SpringSecurity

    SpringBoot整合SpringSecurity 一.创建项目,选择依赖 选择Spring Web.Thymeleaf即可 二.在pom文件中导入相关依赖 <!-- 导入SpringSecu ...

  4. boke练习: springboot整合springSecurity出现的问题,post,delete,put无法使用

    springboot 与 SpringSecurity整合后,为了防御csrf攻击,只有GET|OPTIONS|HEAD|TRACE|CONNECTION可以通过. 其他方法请求时,需要有token ...

  5. SpringBoot整合SpringSecurity实现JWT认证

    目录 前言 目录 1.创建SpringBoot工程 2.导入SpringSecurity与JWT的相关依赖 3.定义SpringSecurity需要的基础处理类 4. 构建JWT token工具类 5 ...

  6. springboot整合springsecurity遇到的问题

    在整合springsecurity时遇到好几个问题,自动配置登录,下线,注销用户的操作,数据基于mybatis,模版引擎用的thymeleaf+bootstrap. 一.认证时密码的加密(passwo ...

  7. SpringBoot 整合 SpringSecurity 梳理

    文档 Spring Security Reference SpringBoot+SpringSecurity+jwt整合及初体验 JSON Web Token 入门教程 - 阮一峰 JWT 官网 Sp ...

  8. SpringBoot整合SpringSecurity简单案例

    在我们开发项目的过程中经常会用到一些权限管理框架,Java领域里边经常用的可能就是shiro了,与之对应的还有SpringSecurity,SpringSecurity可以说是非常强大,与Spring ...

  9. SpringBoot整合SpringSecurity,SESSION 并发管理,同账号只允许登录一次

    重写了UsernamePasswordAuthenticationFilter,里面继承AbstractAuthenticationProcessingFilter,这个类里面的session认证策略 ...

随机推荐

  1. oracle常用SQL——创建用户、表空间、授权(12C)

    一.查询 查询用户所属 表空间 select username,default_tablespace from dba_users where username='xxx' 查询表空间情况 SELEC ...

  2. topcoder srm 315 div1

    problem1  link 直接模拟即可. import java.util.*; import java.math.*; import static java.lang.Math.*; publi ...

  3. Linux 字符设备驱动开发基础(二)—— 编写简单 PWM 设备驱动【转】

    本文转载自:https://blog.csdn.net/zqixiao_09/article/details/50858776 版权声明:本文为博主原创文章,未经博主允许不得转载.    https: ...

  4. Master of GCD 【线段树区间更新 || 差分】

    Master of GCD 时间限制: 1 Sec  内存限制: 128 MB 提交: 670  解决: 112 [提交] [状态] [命题人:admin] 题目描述 Hakase has n num ...

  5. Ubuntu: repository/PPA 源

    在Ubuntu中,每个PPA源是单独存放在/etc/apt/sources.list.d/文件夹中的,进入到该文件夹,使用ls命令查询即可列出当前系统添加的PPA源. 添加 sudo add-apt- ...

  6. 为linux dns (bind named)服务器配置 单独的笔记

    注意: 当在把 named.ca文件下载好13个根dns服务器的 全球记录后, 就不再需要别的 dns服务器来辅助获得了. 只要把所有 本地服务器 不能解析的请求, 都发送到 . 点根去就行了, 所以 ...

  7. Golang模拟客户端POST表单功能文件上传

    客户端通过multipart.Write把文件的文本流写入一个缓存中,然后调用http的Post方法把缓存传到服务器. package main import ( "bytes" ...

  8. 洛谷P1803 凌乱的yyy dp

    我要日更嘤嘤嘤>_< 原题戳>>https://www.luogu.org/problem/show?pid=1803<<(其实是戳不动的,复制粘贴吧) 题目背景 ...

  9. 8、nginx和tengine简介

    练习: 使用nginx反向代理(rr调度)用户请求至两个以上的后端LAMP(按标准路径部署的有pma,wd),不管用户请求是什么内容都反向代理至后端服务器去,但是如果用户请求的是图片或者是html,就 ...

  10. cookie 简单用法

    cookie 简单用法 //当前登录人的组织Id HttpCookie SingleValueCookie = new HttpCookie("DepartmentId", &qu ...