这篇文章给大家介绍怎么进行Spring Cloud Eureka的安全配置,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
基于SpringCloud-Dalston.SR5
一般的,Eureka在内网服务,我们不会对于外网暴露Eureka端口,所以一般Eureka不做任何验证。假设我们想进一步增强Eureka的安全性,可以结合spring security
来简单配置一些安全设置
首先在Spring Cloud Eureka Server所在的项目中添加对于spring security
的依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
然后在项目配置文件application.properties
中加入安全认证,注意三点配置,用户名,密码,还有Eureka服务地址:
#打开security
security.basic.enabled=true
security.user.name=username
security.user.password=password
#这里的用户名密码就是上面配置的
eureka.client.service-url.defaultZone=http://username:password@localhost:8761/eureka # 安全的注册地址
关于怎么进行Spring Cloud Eureka的安全配置就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。