【发布时间】:2015-11-10 14:27:14
【问题描述】:
我正在尝试使用 https://github.com/spring-projects/spring-security-oauth 将我的 Spring 应用程序配置为使用 JWT。我已经为ConsumerTokenServices 公开了一个由JwtTokenStore 支持的bean,但是点击/oauth/token 并没有给我一个JWT。
$ curl localhost:8643/contextpath/oauth/token?grant_type=client_credentials -u user:password`
{"access_token":"a78a6225-78d5-4cb8-9393-6c0b567a6f24","token_type":"bearer","expires_in":5684,"scope":"read write"}%
我知道TokenStore 正在被使用,因为点击check_token 会产生错误,而以前不会。
$ curl https://localhost:8643/context/oauth/check_token?token=a78a6225-78d5-4cb8-9393-6c0b567a6f24
{"error":"invalid_token","error_description":"Cannot convert access token to JSON"}%
如何让我的TokenEndpoint 吐回 JWT?
【问题讨论】:
-
您是否尝试使用 Spring Boot 1.3 制作示例应用程序?它确实带有对 OAuth2 的自动支持,请参阅 spring.io/blog/2015/11/16/spring-boot-1-3-0-released。我会尝试构建一个示例应用程序,然后查看github.com/spring-projects/spring-boot/blob/master/… 和github.com/dynamind/spring-boot-security-oauth2-minimal。另一个不错的博客系列是spring.io/blog/2015/02/03/…
-
你能解决这个问题吗?
-
我最终没有使用 Spring。
标签: spring spring-security jwt spring-security-oauth2