首页 文章

Spring OAuth2 ResourceServer外部AuthorizationServer

提问于
浏览
-1

如何设置单独的Spring OAuth2 ResourceServer,它使用和第三方AuthorizationServer

我看到的所有示例都始终在同一个应用程序中实现ResourceServer和AuthorizationServer .

我不想实现AuthorizationServer,因为其他人会提供这个 .

试过没有运气

@Configuration
   @EnableResourceServer
   public class OAuth2ResourceServerConfig extends ResourceServerConfigurerAdapter

而application.yml包括

security:
  oauth2:
    resource:
      userInfoUri: https://...../userinfo

在我的问题中添加一些进一步的细节::

根据我的理解 - 与OAuth有4个玩家:

  • 资源所有者:一个人

  • 资源服务器:服务器公开受保护的API(受认证服务器保护)

  • authentication server:处理向客户端发出访问令牌的服务器

  • client:资源所有者已经同意后访问资源服务器API的应用程序(比如网站)

我尝试了各种教程,但似乎都实现了自己的授权服务器

http://www.swisspush.org/security/2016/10/17/oauth2-in-depth-introduction-for-enterprises https://gigsterous.github.io/engineering/2017/03/01/spring-boot-4.html

或者是实现客户端播放器的示例

我的问题是:如何通过第三方认证服务器实现仅保护我的REST API的资源服务器,仅此而已 .

1 回答

  • 2

    我已经解决了这个问题 - 你需要的只是:

    @SpringBootApplication
    @EnableResourceServer
    public class ResourceServer {
    
        public static void main(String[] args) {
            SpringApplication.run(ResourceServer.class, args);
        }
    }
    

    使用application.yml发布在原始问题中:

    security:
     oauth2:
       resource:
         userInfoUri: https://........userinfo
    

相关问题