【问题标题】:Spring boot oauth2 tokenSpring Boot oauth2 令牌
【发布时间】:2017-01-01 14:20:53
【问题描述】:

我有一个 ouath2 模块,服务器在端口 9999 上运行,当我请求“localhost:9999/oauth/token”时,我确实得到了令牌。 但是,即使身份验证服务器和 REST 端点在同一个项目中(不同的模块,但它们彼此了解),控制器似乎也不关心请求是否包含令牌。

现在,有趣的东西来了:

如果我将此代码添加到我的 application.yml,控制器根本不关心身份验证。

security:
  basic:
    enabled: false
  oauth2:
    client:
      client-id: acme
      client-secret: acmesecret
      access-token-uri: http://localhost:9999/oauth/token
      user-authorization-uri: http://localhost:9999/oauth/authorize
    resource:
      user-info-uri: http://localhost:9999/user
      token-info-uri: http://localhost:9999/oauth/check_token

auth:
 server:
  url: http://localhost:9999/oauth/check_token/
  clientId: acme
  clientSecret: acmesecret
oauth2:
 resource:
  userInfoUri: http://localhost:9999/user

但是,当我删除它并尝试请求控制器时,我得到了这个:

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

有什么想法吗?有人吗?

【问题讨论】:

    标签: java oauth spring-boot token spring-security-oauth2


    【解决方案1】:

    @ComponentScan("the_actual_package") 不见了

    【讨论】:

      猜你喜欢
      • 2015-06-02
      • 2018-05-03
      • 2018-12-01
      • 2020-04-23
      • 2020-06-17
      • 2018-03-15
      • 2017-06-02
      • 2019-05-12
      • 2016-09-06
      相关资源
      最近更新 更多