spring HTTP 状态 401 - 访问此资源需要完全身份验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31938867/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTTP Status 401 - Full authentication is required to access this resource
提问by anntheitroadq
On some link I authorized with basic type: username,password and get session: "25C87AA2BFBFB3A1B70FECD9F4441738". Now I want manually get access to other resource with same session and put header: Cookie: JSESSIONID=25C87AA2BFBFB3A1B70FECD9F4441738
在我使用基本类型授权的某些链接上:用户名、密码并获取会话:“25C87AA2BFBFB3A1B70FECD9F4441738”。现在我想手动访问具有相同会话的其他资源并放置标题:Cookie: JSESSIONID=25C87AA2BFBFB3A1B70FECD9F4441738
But error appears: HTTP Status 401 - Full authentication is required to access this resource
但出现错误:HTTP 状态 401 - 访问此资源需要完全身份验证
回答by Karthikeyan Vaithilingam
You have to add a HTTP header named Cookie
and the value should be the JSESSIONID=<JSESSIONID VALUE>
, As per you question the value should be JSESSIONID=25C87AA2BFBFB3A1B70FECD9F4441738
您必须添加一个名为的 HTTP 标头Cookie
,该值应该是JSESSIONID=<JSESSIONID VALUE>
,根据您的问题,该值应该是JSESSIONID=25C87AA2BFBFB3A1B70FECD9F4441738
By this the server will check that the session already authenticated if authenticated it will allow to access the resource.
通过这种方式,服务器将检查会话是否已经通过身份验证,如果通过身份验证,它将允许访问资源。
Update 1
更新 1
According to Postman Docsthere are some headers are restricted, unfortunately Cookie
is one of them.
根据Postman Docs有一些标题受到限制,不幸的Cookie
是其中之一。
Update 2
更新 2
As per the Postman Docsfrom version v0.9.6 sending restricted headers are possible by using Inspector extension.
根据v0.9.6 版的Postman Docs,可以使用 Inspector 扩展发送受限标头。
Refrences
参考资料
回答by Ashwini
Check if you have spring security related maven dependency in your pom.xml. Remove the dependency from pom.xml if not used. The issue will be resolved.
检查您的 pom.xml 中是否有与 spring 安全相关的 maven 依赖项。如果不使用,请从 pom.xml 中删除依赖项。问题将得到解决。