即使使用 permitall antMatchers,Spring Boot Oauth 2 配置也会导致 401 [英] Spring boot Oauth 2 configuration cause to 401 even with the permitall antMatchers

查看:206
本文介绍了即使使用 permitall antMatchers,Spring Boot Oauth 2 配置也会导致 401的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Spring Boot 和 Aouth 2 的新手.我尝试使用 OAuth2 保护我的 Spring Boot 应用程序.但是我的身份验证无法正常工作,即使使用不安全的 url,也会导致 401 错误.我的代码可以在 git hub 中的 url 下找到

I am little new Spring boot and Aouth 2. I tried to secure my spring boot application with OAuth2. But My authentication is nit working and it causes for 401 error even with unsecured url. My code can be found in the git hub with under url

我使用了下面的 curl 命令

I used the below curl command

curl -i http://localhost:8990/api/hello

但结果是

{"timestamp":1489824873836,"status":401,"error":"Unauthorized","message":"Full authentication is required to access this resource","path":"/api/hello"}

此外,当我尝试访问我的安全网址时,如下所示,它会产生相同的错误.

Also when I try to access my secured url as below, it produces the same error.

curl -i -H "Authorization: Bearer <access_token>" http://localhost:8990/api/secure

我已经在互联网上进行了搜索,但仍无法解决我的问题.谁能帮帮我

I have searched in the internet but unable to fix my problem yet. Could anybody please help me

谢谢

Git 中心网址

https://github.com/txmr765/Spring-Oauth2

推荐答案

身份验证代码需要更改的地方很少,现在可以正常工作了.

Authentication code has got few things to be changed and now and it's working.

只需检查 curl -vu secureapp:secret 'http://localhost:8990/api/oauth/token?username=admin&password=admin&grant_type=password'

Just check curl -vu secureapp:secret 'http://localhost:8990/api/oauth/token?username=admin&password=admin&grant_type=password'

这篇关于即使使用 permitall antMatchers,Spring Boot Oauth 2 配置也会导致 401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆