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. Install jdk on Ubuntu16

    wikiHow to Install Oracle Java JDK on Ubuntu Linux This tutorial will cover the installation of 32-b ...

  2. 从Git上导入Maven 项目到Eclipse

    Note: 经验之谈,操作过程中有不懂的地方可以留言问. Step: Open the Eclipse: --1.File>>Import>>Git:Project from ...

  3. R语言之正则表达式

    常见与正则表达式相关的函数: grep(pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE, fixed = FALSE, use ...

  4. JAVA 上传文件到linux上并解压缩

    package com.inborn.inshop.controller.mkt; import java.io.*; import ch.ethz.ssh2.ChannelCondition;imp ...

  5. 批处理bat标准化获取当前系统日期的几种方法,补0

    首先有两个推荐的方案. 一: for /f "tokens=2 delims==" %%a in ('wmic path win32_operatingsystem get Loc ...

  6. Js操作Cookie的实现

  7. MVC ---- 怎删改查

    using Modelsop; using System; using System.Collections.Generic; using System.Linq; using System.Web; ...

  8. Java只给汉字转URLEncoder

    public static String encode(String str, String charset) throws UnsupportedEncodingException { Patter ...

  9. Mysql 函数使用记录(三)——UNIX_TIMESTAMP() 、UNIX_TIMESTAMP(date)

    参考资料:https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_unix-timestamp UN ...

  10. Jenkins--Credentials添加证书从git上拉代码

    直接上图: