简体   繁体   English

Spring Boot OAuth2令牌

[英]Spring boot oauth2 token

I have an ouath2 module, server running on port 9999, and when I request "localhost:9999/oauth/token" I do get the token. 我有一个ouath2模块,服务器在端口9999上运行,当我请求“ localhost:9999 / oauth / token”时,我确实获得了令牌。 However, even the auth server and the REST endpoints are in the same project (different modules, but they know about each other), the controllers seem to not care if the request holds a token. 但是,即使auth服务器和REST端点都在同一项目中(不同的模块,但它们彼此了解),控制器似乎也不在乎请求是否包含令牌。

Now, here comes the interesting stuff: 现在,有趣的东西来了:

If I add this code to my application.yml, the controllers do not care about the auth at all. 如果我将此代码添加到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

But, when I remove it and try to request the controller I get this: 但是,当我删除它并尝试请求控制器时,我得到了:

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

Any ideas? 有任何想法吗? Anyone? 任何人?

@ComponentScan("the_actual_package")丢失

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM