【问题标题】:Spring boot OAuth2 SSO ClusterSpring Boot OAuth2 SSO 集群
【发布时间】:2017-09-05 07:00:37
【问题描述】:

我是用spring boot、Spring OAuth2搭建SSO服务器的。在单机模式下,令牌存储在内存中,运行良好。但现在,我想在多台服务器上运行 SSO 服务器。我用 JDBC 更改了存储策略,然后在端口 9999 和 9998 上运行了两个实例。 我不知道如何配置 application.yml 文件的客户端和资源服务器。我在客户端服务器上尝试了以下配置:

security:
  basic:
    enabled: false
  oauth2:
    client:
      client-id: mud
      client-secret: mud
      access-token-uri: http://localhost:9999/oauth/token,http://localhost:9998/oauth/token
      user-authorization-uri: http://localhost:9999/oauth/authorize,http://localhost:9998/oauth/authorize
      scope: read, write
    resource:
      token-info-uri: http://localhost:9999/oauth/check_token,http://localhost:9998/oauth/check_token

它不起作用...当我访问资源时,SSO 服务器重定向到“http://localhost:9999/oauth/token,http://localhost:9998/oauth/token”。

spring如何配置多个SSO认证服务器?

【问题讨论】:

    标签: spring oauth-2.0 single-sign-on


    【解决方案1】:

    我想用zuul来解决这个问题,我在客户端服务器上尝试了以下配置:

    server:
      port: 8080
    security:
      basic:
        enabled: false
      oauth2:                                              
        client:
          client-id: mud
          client-secret: mud
          access-token-uri: http://localhost:8080/proxy/oauth/token
          user-authorization-uri: http://localhost:8080/proxy/oauth/authorize
          scope: read, write
        resource:
          token-info-uri: http://localhost:8080/proxy/oauth/check_token
      ignored: /proxy/oauth/token, /proxy/oauth/authorize, /proxy/oauth/check_token
    zuul:
      routes:
        auth-server:
          path: /proxy/**
          serviceId: mud-microservice-security
    mud-microservice-security:
      ribbon:
        NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RoundRobinRule
    

    当我像 127.0.0.1:8080/env 一样访问这个客户端时,它可以被重定向到 SSO 服务器的登录页面。但是当登录成功时,它不会重定向到 127.0.0.1:8080/env 并且我再次访问 127.0.0.1:8080/env 时,它会重定向到登录页面。

    【讨论】:

      【解决方案2】:

      我认为您应该为您的 oauth 实例配置会话共享

      【讨论】:

      • 你能更好地解释一下这是如何回答这个问题的吗?
      • 似乎用户登录了 oauth2 instance1,但以下请求被重定向到 oauth2 instance2。我认为这就是登录页面再次显示的原因。也许 instance1 和 instance2 之间的共享会话应该可以解决问题。
      猜你喜欢
      • 1970-01-01
      • 2016-02-01
      • 2019-12-26
      • 2017-10-27
      • 2017-12-21
      • 2017-06-14
      • 1970-01-01
      • 2017-02-12
      • 2017-11-08
      相关资源
      最近更新 更多