方法是否通过oauth2令牌保护Config Server?

时间:2016-02-05 08:16:41

标签: spring-security spring-cloud microservices oauth2

方法是否通过oauth2令牌保护配置服务器?

我计划通过oauth2令牌实现spring cloud config-server,因此客户端服务器可以通过以下方式获取属性:

 cloud:
    config:
      uri: http://user:password@localhost:8888

可行吗?

但是......我遇到了一些问题。 我开始演示https://github.com/keryhu/spring-oauth2-config-server.git

它包含四项服务:

1:eureka :首先启动,并且可以实现服务注册和发现,它没有oauth2环境。

2:auth-server :JWT OAuth2服务器配置,其次启动。

    @SessionAttributes("authorizationRequest")
    @EnableResourceServer
    @EnableDiscoveryClient

和inmemory用户:

  security:
    user:
      password: password

3:config-server :从第三位开始

@EnableDiscoveryClient
@EnableConfigServer
@EnableResourceServer

并在application.yml中:

spring:  
  cloud:
     config:
       server:
         git:
           uri: https://github.com/keryhu/cloud-config


security:
  oauth2:
    resource:
      jwt:
        keyValue: |
          -----BEGIN PUBLIC KEY-----
          ....
          -----END PUBLIC KEY-----

4:pc-gateway :是客户端服务器,也是ui服务器。最后开始

当我测试安全的uri:http://localhost:8080/hello时,页面被重定向到

http://localhost:9999/uua/login

输入" 用户:密码"后,重定向回来

http://localhost:8080/hello

所以我认为oauth-server和oauth-client很好。

但..我还在bootstrap.yml中设置了以下配置

cloud:
    config:
      uri: http://user:password@localhost:8888

启动pc-gateway服务时,从服务器获取配置有401个未授权错误:

INFO 954 --- [main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
WARN 954 --- [main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: 401 Unauthorized

需要帮助!谢谢!

0 个答案:

没有答案
相关问题