【问题标题】:Seeking thorough documentation on the spring.cloud.config properties group for client applications在 spring.cloud.config 属性组中寻找客户端应用程序的完整文档
【发布时间】:2016-12-24 04:24:22
【问题描述】:

我正在尝试连接到托管在关键云代工厂中的 spring 云配置配置服务器(服务)。

配置服务受 OAuth2 保护,我无法让客户端通过配置服务器进行身份验证。我不断收到 401 Unauthorized 消息。

我无法在 bootstrap.yml 中找出正确的属性组合。

这是我当前的 bootstrap.yml,您可以看到我尝试过很多不同的配置,我什至已经从等式中删除了 Pivotal Cloud Foundry,并试图从我的本地主机中访问它,同时我正在处理这些安全错误。

bootstrap.yml:

#Search for System Property of cloud config server, otherwise use localhost 

config server.
spring:
  cloud:
    config:
      enabled: true
      #uri: ${vcap.services.config-server.credentials.uri:http://localhost:8888}
      uri: https://config-fa3bfbbf-546c-a2c0-b07a-136da18a4fa1.host.domain.com
      authorization: ${security.oauth2.client}
      #username: ${vcap.services.config-server.credentials.client_id}
      #password: ${vcap.services.config-server.credentials.client_secret}
      name: app    
      #token: ${security.oauth2.client.token-name}
security:
  basic:
    enabled: false
  oauth2:
    client:
      #id: ${vcap.services.config-server.credentials.client_id}
      #client-secret: ${vcap.services.config-server.credentials.client_secret}
      #access-token-uri: ${vcap.services.config-server.credentials.access_token_uri}
      id: p-config-server-9281df10-bc67-49a2-863b-48844a1ce724
      client-secret: UIcc1m6lvvHK
      access-token-uri: https://p-spring-cloud-services.uaa.domain.host.com/oauth/token 
      token-name: config-server-token   

感谢任何见解、提示或指示。

如果我能够在解决此 401 错误方面取得任何进展,我将继续发布此问题的后续信息。

关于它的价值的非描述性错误消息:

GET request for "https://config-fa3bfbbf-546c-a2c0-b07a-136da18a4fa1.host.domain.com/app/dev" resulted in 401 (Unauthorized); invoking error handler 
Could not locate PropertySource: 401 Unauthorized 

【问题讨论】:

    标签: spring-boot spring-security spring-security-oauth2 cloud-foundry spring-cloud-config


    【解决方案1】:

    原来我把问题复杂化了。 我的 pom 中缺少一个依赖项,它需要一个简化的 bootstrap.yml。

    最终的 bootstrap.yml:

    spring:
      profiles: cloud
      application:
        name: app
    

    这确保它仅在云上运行时使用(PCF 提供“云”配置文件),并且在向配置服务器询问属性文件时使用仅在 bootstrap.yml 中提供的应用程序名称(请参阅此文档:@987654321 @)

    在我的 pom.xml 中,我添加了这些依赖项:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
        <version>1.2.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>io.pivotal.spring.cloud</groupId>
        <artifactId>spring-cloud-services-starter-config-client</artifactId>
        <version>1.3.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security.oauth</groupId>
        <artifactId>spring-security-oauth2</artifactId>
    </dependency>
    

    我仍然不确定是否需要 oauth2 依赖项,但目前我还没有尝试过没有它。

    不向 spring.cloud.config 属性组提供任何额外配置的作用是允许 spring-cloud-services-starter-config 获取 vcap.services 中所需的任何属性并将应用程序绑定到配置服务器并填写访问所述配置服务器所需的所有属性。

    【讨论】:

      猜你喜欢
      • 2013-06-17
      • 1970-01-01
      • 2014-11-13
      • 1970-01-01
      • 1970-01-01
      • 2015-07-16
      • 2017-06-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多