Spring Boot:访问此资源需要完全身份验证

dee*_*een 14 security access-token wso2is spring-boot

我正在使用wso2is服务器从这篇文章https://github.com/angel-git/wso2is-springoauth做的Spring Boot Security示例,当我尝试使用访问令牌访问资源时我得到了

{"error":"unauthorized","error_description":"访问此资源需要完全身份验证"}

我通过以下方式生成访问令牌:

curl -u CLIENT_ID:CLIENT_SECRET -k -d"grant_type = password&username = admin&password = admin"-H"Content-Type:application/x-www-form-urlencoded" https:// localhost:9443/oauth2/token

和访问资源:

curl -H GET"授权:ACCESS_TOKEN" http:// localhost:8080/greeting

我在stackoverflow上找到了很多解决方案,但遗憾的是无法解决我的问题

请帮忙,谢谢

A.P*_*A.P 10

我得到了相同的错误消息

"curl http://localhost:8080/spring4/beans" :
{"timestamp":1493591079040,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource.","path":"/spring4/beans"}
Run Code Online (Sandbox Code Playgroud)

设置下面的属性application.properties绕过安全检查我可以使用所有的acuator端点:

management.security.enabled=false
Run Code Online (Sandbox Code Playgroud)

  • 不知何故,我怀疑绕过安全性是试图使用Spring安全性的人的正确答案. (19认同)
  • 是的,我只是用它进行测试.必须使用令牌等以获得完全的安全性. (2认同)

dee*_*een 3

非常感谢 Angel Gavalda 帮助我解决了问题。我使用以下命令来生成访问令牌和访问资源

用于生成访问令牌:-

卷曲 -k -d 'grant_type=client_credentials&client_id=yourClientId&client_secret=yourClientSecret' https://localhost:9443/oauth2/token

用于访问资源:-

卷曲-k -H“授权:承载$ ACCESS_TOKEN” http://localhost:8080/greeting