0

ピボットクラウドファウンドリでホストされているSpringクラウド設定のコンフィグレーションサーバ(サービス)に接続しようとしています。クライアントアプリケーション用のspring.cloud.configプロパティグループに関する完全なドキュメントを探す

設定サービスはOAuth2で保護されており、クライアントに設定サーバーを認証させることができません。私は401 Unauthorizedメッセージを絶えず受け取っています。

bootstrap.ymlで適切なプロパティの組み合わせを見つけることができませんでした。

ここに私の現在のbootstrap.ymlがあります。あなたが試したさまざまな構成がたくさんあることがわかります。これまでのところ、Pivo​​tal Cloud Foundryを式から削除して、自分のlocalhostからヒットしようとしています私はこれらのセキュリティエラーに取り組んでいます。

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 

答えて

0

は、私はこの問題を、複雑に超えていたが判明します。 私は自分のポームに依存していないし、単純化されたbootstrap.ymlが必要でした。

最終bootstrap.yml:

spring: 
    profiles: cloud 
    application: 
    name: app 

これは(PCFは、「クラウドのプロファイルを提供)、クラウド上で動作しているときにのみ使用していますが保証、およびONLY bootstrap.ymlで提供されたアプリケーション名が使用されているを求めてプロパティファイル用のコンフィグサーバ(このドキュメントを参照してください:https://cloud.spring.io/spring-cloud-config/spring-cloud-config.html)を

そして、私の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> 

私はsのよoauth2の依存関係が必要なのかどうかは分かりませんが、現時点ではこれを試していません。

spring.cloud.configプロパティグループに追加の設定を加えないことにより、これは、spring-cloud-services-starter-configがvcap.servicesで必要なプロパティを取得し、アプリケーションをconfigサーバにアクセスするために必要なすべてのプロパティを入力します。

関連する問題