spring cloud config分布式配置中心安全保护

由于配置中心一些信息比较敏感,这就要求我们做点安全保护处理。由于微服务是构建在Spring Boot之上,所以整合Spring Security是最方便的方式。

第一步:在config-server服务注入依赖

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-security</artifactId>
</dependency>

第二步:application.properties文件中添加用户名和密码

spring.security.user.name=security
spring.security.user.password=123456

第三步:在全部config-client配置文件添加用户名和密码即可

spring:
  cloud:
    config:
      name: childdream-service
      profile: dev
      discovery:
        service-id: config-server
        enabled: true
      #configserver安全配置
      username: security
      password: 123456
  main:
    allow-bean-definition-overriding: true
      
eureka:
  client:
    service-url:
      defaultZone: http://eureka.didispace.com/eureka/
发布了22 篇原创文章 · 获赞 13 · 访问量 5784

猜你喜欢

转载自blog.csdn.net/weixin_43839457/article/details/93163190