相关疑难解决方法(0)

如何从Postman休息客户端发送spring csrf令牌?

我在spring框架中有csrf保护.所以在每个请求中,我从ajax调用中在头文件中发送csrf令牌,这非常有效.

<meta name="_csrf" content="${_csrf.token}"/>
<meta name="_csrf_header" content="${_csrf.headerName}"/>

var token = $("meta[name='_csrf']").attr("content");
var header = $("meta[name='_csrf_header']").attr("content");
Run Code Online (Sandbox Code Playgroud)

在ajax

beforeSend: function(xhr) {
                xhr.setRequestHeader(header, token),
                xhr.setRequestHeader("username", "xxxx1"),
                xhr.setRequestHeader("password", "password")
            }
Run Code Online (Sandbox Code Playgroud)

我不知道生成csrf令牌并包含在Postman Rest Client的标题部分?你能帮我从Postman Rest Client发送csrf令牌吗? 在此输入图像描述

rest spring header csrf postman

44
推荐指数
3
解决办法
8万
查看次数

Spring Boot Starter安全发布​​方法不起作用

我在现有的spring boot项目中添加了spring'spring-boot-starter-security';之后,spring rest控制器中的post方法不能正常工作,它显示如下错误:

o.s.web.servlet.PageNotFound             : Request method 'POST' not supported


Remote Address:127.0.0.1:8080
Request URL:http://localhost:8080/authenticate
Request Method:POST
Status Code:405 Method Not Allowed
Response Headers
view source
Allow:GET, HEAD
Cache-Control:no-cache, no-store, max-age=0, must-revalidate
Content-Type:application/json;charset=UTF-8
Date:Wed, 14 Oct 2015 05:41:06 GMT
Expires:0
Pragma:no-cache
Server:Apache-Coyote/1.1
Transfer-Encoding:chunked
X-Content-Type-Options:nosniff
X-Frame-Options:DENY
X-XSS-Protection:1; mode=block
Request Headers
view source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:47
Content-Type:application/json;charset=UTF-8
Cookie:_ga=GA1.1.630164096.1442901791; JSESSIONID=B9F1946DAE5BCA7772526CFC735616EC
Host:localhost:8080
Origin:http://localhost:8080
Referer:http://localhost:8080/
User-Agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36
X-ZUMO-APPLICATION:GSECUHNQOOrCwgRHFFYLXWiViGnXNV88
Request Payload
Run Code Online (Sandbox Code Playgroud)

我的控制器方法是这样的:

@RequestMapping(value="/authenticate",method = …
Run Code Online (Sandbox Code Playgroud)

java spring spring-security spring-data-jpa spring-boot

1
推荐指数
2
解决办法
4092
查看次数