how to implement spring cloud config server security with docker

时间:2016-02-03 03:27:08

标签: spring spring-security spring-boot spring-cloud

I want to use spring cloud config server security :

I find the example in : https://github.com/spring-cloud-samples/config-repo/blob/master/application.yml

 profile:
    cloud:
            config:
              uri: ${vcap.services.${PREFIX:}configserver.credentials.uri:http://user:password@${PREFIX:}configserver.${application.domain:cfapps.io}}

But: i can not understand : whats the some words meaning ?

e.g.

  1. vcap.services
  2. ${PREFIX:}configserver.credentials.uri
  3. ${PREFIX:}
  4. ${PREFIX:}configserver
  5. ${PREFIX:}sso.credentials.tokenUr

And , if i use docker instead of cloud profile , like this :

docker
    config:
      uri: http://${CONFIGSERVER_1_PORT_8888_TCP_ADDR:localhost}:8888

client:
    serviceUrl:
      defaultZone: http://${EUREKA_1_PORT_8761_TCP_ADDR:localhost}:8761/eureka/

when i try this :

in coifing-server application.yml :

security:
  user:
    password: 1

in client-server application.yml

spring:
  cloud:
    config:
      uri: http://user:1@localhost:8888

The client-server console has errors :

 c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
  c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: label not found

Whole Code is in : https://github.com/keryhu/coud-config-security

How do i implement security config ?

can help me?

2 个答案:

答案 0 :(得分:2)

您需要在bootstrap.yml(或.properties)中设置配置服务器URI,因为在引导阶段需要它。

答案 1 :(得分:0)

您是否配置了自定义弹簧安全配置? 需要在引导阶段

中设置访问配置服务器的URL和凭据

您可以使用WebSecurityConfigurer更改安全性 @Configuration @EnableWebMvcSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter {