SpringCloud集成Security安全(Config配置中心)
1.说明
为了保护配置中心的敏感数据,
需要对Config Server进行安全保护,
本文基于Spring Security方案,
为Config Server增加最简单的Basic安全认证。
2.Config Server添加安全依赖
修改pom.xml,添加spring-boot-starter-security依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
3.Config Server配置用户名密码
修改application.yml,配置用户名密码:
spring:
security:
user:
name: config
password: config123456
4.启动Config Server,测试验证
先只启动Config Server,
通过浏览器的URL访问配置中心,
http://localhost:9009/master/application-dev.yml
首先会跳到登录界面,
要求输入用户名密码:
认证成功后,访问到对应的配置:
5.Config Client配置用户名密码
客户端要访问配置中心,
需要修改bootstrap.yml,
配置上面的用户名密码:
spring:
cloud:
config:
discovery:
enabled: true
service-id: config-server
username: config
password: config123456
上面是通过service-id指定配置中心,
如果使用uri方式指定配置中心,
不仅可以通过username和password配置用户名密码:
spring:
cloud:
config:
uri: http://localhost:9009
username: config
password: config123456
还可以在uri中配置用户名密码:
spring:
cloud:
config:
uri: http://config:config123456@localhost:9009
如果在uri中指定了用户名密码,
又在下面设置username和password,
则以username和password配置的为准:
spring:
cloud:
config:
label: master
name: config-client-demo
profile: test
uri: http://config:configXXX@localhost:9009
username: config
password: config123456
上面的配置中uri的密码错误了,
但是password配置的是正确的,
Config Client仍然能够正确访问配置中心。
SpringCloud集成Security安全(Config配置中心)的更多相关文章
- 微服务SpringCloud之Spring Cloud Config配置中心Git
微服务以单个接口为颗粒度,一个接口可能就是一个项目,如果每个项目都包含一个配置文件,一个系统可能有几十或上百个小项目组成,那配置文件也会有好多,对后续修改维护也是比较麻烦,就和前面的服务注册一样,服务 ...
- 微服务SpringCloud之Spring Cloud Config配置中心服务化
在前面两篇Spring Cloud Config配置中心的博客中都是需要指定配置服务的地址url:spring.cloud.config.uri,客户端都是直接调用配置中心的server端来获取配置文 ...
- SpringCloud Netflix (六):Config 配置中心
------------恢复内容开始------------ SpringCloud Config 配置中心 Config 配置中心 Spring Cloud Config为分布式系统中的外部化配置提 ...
- springcloud 入门 8 (config配置中心)
Spring Cloud Config: 配置中心为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件,它就是Spring Cloud Config. 在分布式系统中,由于服务数量巨多, ...
- 微服务SpringCloud之Spring Cloud Config配置中心SVN
在回来的路上看到一个个的都抱着花,吃了一路的狗粮,原本想着去旁边的工业园里跑跑步呢,想想还是算了,人家过七夕,俺们过巴西.上一博客学习了Spring Cloud Config使用git作为配置中心,本 ...
- SpringCloud集成Security安全(Eureka注册中心)
1.说明 为了保护注册中心的服务安全, 避免恶意服务注册到Eureka, 需要对Eureka Server进行安全保护, 本文基于Spring Security方案, 为Eureka Server增加 ...
- 跟我学SpringCloud | 第七篇:Spring Cloud Config 配置中心高可用和refresh
SpringCloud系列教程 | 第七篇:Spring Cloud Config 配置中心高可用和refresh Springboot: 2.1.6.RELEASE SpringCloud: Gre ...
- SpringCloud之Config配置中心+BUS消息总线原理及其配置
一.配置中心作用 在常规的开发中,每个微服务都包含代码和配置.其配置包含服务配置.各类开关和业务配置.如果系统结构中的微服务节点较少,那么常规的代码+配置的开发方式足以解决问题.当系统逐步迭代,其微服 ...
- spring-cloud config配置中心
这里那些概念不说,主要是记录下spring cloud config配置中心的服务端和客户端的一个demo. 服务端即提供统一配置文件 客户端即从服务端读取配置 1.新建一个spring boot项目 ...
随机推荐
- minSdkVersion、targetSdkVersion、targetApiLevel的区别
在AndroidMenifest.xml中,常常会有下面的语句: <uses-sdk android:minSdkVersion="4" android:targetSdk ...
- Java Timestamp 类的使用
很简单,我们可以这样声明 Timestamp ts=new Timestamp(new Date().getTime());这样我们就可以得到时间比较具体的一个类型转换!!! 在开发web应用中,针对 ...
- 【Matlab】CFAR/phased.CFARDetector2D
| CFAR学习进行时ing... | CFAR原理.参数 检测阈值\(T = αP_n\) \(P_n\)是噪声功率估计,\(α\)是比例因子 训练单元:训练噪声,估计\(P_n = \frac{1 ...
- Nginx模块之nginx_upstream_check_module
目录 一.介绍 二.使用 三.参数 一.介绍 大家都知道,前端nginx做反代,如果后端服务器宕掉的话,nginx是不能把这台realserver剔除upstream的,所以还会有请求转发到后端的这台 ...
- malloc实现
任何一个用过或学过C的人对malloc都不会陌生.大家都知道malloc可以分配一段连续的内存空间,并且在不再使用时可以通过free释放 掉.但是,许多程序员对malloc背后的事情并不熟悉,许多人甚 ...
- Android: Client-Server communication by JSON
Refer to: http://osamashabrez.com/client-server-communication-android-json/ This is a sequel to my l ...
- NTLM验证过程
中我们介绍Kerberos认证的整个流程.在允许的环境下,Kerberos是首选的认证方式.在这之前,Windows主要采用另一种认证协议 --NTLM(NT Lan Manager).NTLM使用在 ...
- [BUUCTF]REVERSE——[BJDCTF 2nd]8086
[BJDCTF 2nd]8086 附件 步骤: 首先查壳儿,无壳,直接上ida,检索字符串,程序里就一个字符串 没法f5反编译出伪代码,大致看了一下汇编,start函数之后调用了sub_10030函数 ...
- Python pyecharts绘制水球图
一.水球图Liquid.add()方法简介 Liquid.add()方法签名add(name, data, shape='circle', liquid_color=None, is_liquid_a ...
- 主要视图展示(Project)
<Project2016 企业项目管理实践>张会斌 董方好 编著 有同学拿Excel做甘特图的(咳咳,我也做过),这行为,其实目的就是为了--消食-- 好吧,也是为了学习Excel中图表或 ...