How to Secure Spring Cloud Config Server

后端 未结 3 838
情话喂你
情话喂你 2021-02-01 19:20

I understand that a Spring Cloud Config Server can be protected using an user name and password , which has to be provided by the accessing clients.

How c

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-01 19:34

    Basic authentication configuration that works for me.

    Server-side:

    Needed depedency: org.springframework.boot:spring-boot-starter-security

    bootstrap.yml

    server:
      port: 8888
    
    spring:
      cloud:
        config:
          server:
            git:
              uri: git@bitbucket.org:someRepo/repoName.git
              hostKeyAlgorithm: ssh-rsa
              hostKey: "general hostKey for bitbucket.org"
    
      security:
        user:
          name: yourUser
          password: yourPassword
    

    Client-side:

    bootstrap.yml

    spring:
      application:
        name: config
      profiles:
        active: dev
      cloud:
        config:
          uri: http://localhost:8888
          username: yourUser
          password: yourPassword
    
    management:
      security:
        enabled: false
    

    Sources: Spring doc security feautres, Spring cloud config client security

提交回复
热议问题