SpringBoot2.7.8 SpringBootAdmin 集成 Spring Security(一)
创始人
2025-05-29 10:03:38

核心组件版本

2.7.8
2021.0.5
2021.0.4.0

说明

本文只是一个测试用例,需要 admin client 和 server 都配置同一个账号,才能保证 server 和 client 都需要登录,而且 server 能访问 client 的 actuator/** 地址

SpringBootAdminServer

maven 依赖

spring-boot-admin-server-ui 在 spring-boot-admin-starter-server 中依赖,无需单独引入

org.springframework.bootspring-boot-starter-securityspring-boot-starter-loggingorg.springframework.bootde.codecentricspring-boot-admin-starter-server${spring.boot.version}com.alibaba.cloudspring-cloud-starter-alibaba-nacos-discoverycom.alibaba.cloudspring-cloud-starter-alibaba-nacos-config

properties 配置

nacos 微服务等配置忽略,贴出与 SpringBootAdmin 相关的配置

spring.web.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/assets/
spring.security.user.name=actuator
spring.security.user.password=actuator# spring admin server 下探每个 client actuator 时的账号,包括下探自己的 actuator
spring.boot.admin.instance-auth.enabled=true
spring.boot.admin.instance-auth.default-user-name=${spring.security.user.name}
spring.boot.admin.instance-auth.default-password=${spring.security.user.password}

SecurityConfig

SpringBootAdminServer 中的 SecurityConfig 有些特殊,参考 Securing Spring Boot Admin Server,
springboot2.7.x 已经废弃了 WebSecurityConfigurerAdapter ,方法改写下即可,参考 Spring Security without the WebSecurityConfigurerAdapter

启动 SpringBootAdminServer

账号密码是 actuator/actuator,登录即可

SpringBootAdminClient

maven 依赖

核心包 spring-boot-admin-starter-client

de.codecentricspring-boot-admin-starter-client${spring.boot.version}com.alibaba.cloudspring-cloud-starter-alibaba-nacos-discoverycom.alibaba.cloudspring-cloud-starter-alibaba-nacos-configorg.springframework.bootspring-boot-starter-securityspring-boot-starter-loggingorg.springframework.boot

properties 配置

nacos 微服务等配置忽略,只需要配置 springsecurity 登录账号即可

spring.security.user.name=actuator
spring.security.user.password=actuator

启动SpringBootAdminClient

因为客户端采用 actuator/actuator 登录,而 AdminServer 中配置了下探账号,所以 SpringBootAdminServer中能够访问到 client/actuator/**,能够获取到所有检测数据,同时,客户端正常情况下,需要登录才能访问数据,也不存在数据泄露的问题

相关内容

热门资讯

鸟哥的Linux私房菜 She... 第十二章、学习 Shell Scripts https://linux.vbird.org/linu...
2分钟快速了解!全网最详细的性...  目录:导读 Redis 简介 Redis 优势 Redis与其他key-value存...
设计模式-02 4,创建型模式 4.2 工厂模式 4.2.1 概述 需求:设计一个咖啡店...
纠错码中的汉明码,NAND F...      纠错码是一种用在不可靠的或者噪音比较大的通信信道中用来控制数据传输错误的技术。这种技术的核...
【Java】P14 面向对象(... 类的封装性封装性高内聚与低耦合何为封装性如何封装get 与 set 方法案例 封装性 高内聚与低耦...
【FPGA】Xilinx Co... 功能描述 1、Rotate Rotate 实现的功能是坐标的旋转。 输入 X, Y, Phase 输...
【Pytorch】使用Pyto... 文章目录1. 题目描述2. 代码实现验证写在最后 1. 题目描述 在这个例子中网络结构如下所示&#...
client-go disco... 1. 概述 discovery包主要用来发现服务器支持的API组、版本和资源的方法,及...
[LeetCode周赛复盘] ... [LeetCode周赛复盘] 第 100 场双周赛20230318 一、本周周赛总结二、 [Easy...
Matlab基础教学入门 Matlab是一种非常强大的数学计算工具,广泛应用于科学和工程领域。本篇文章将介绍一些...
设计模式-02 4,创建型模式 4.2 工厂模式 4.2.1 概述 需求:设计一个咖啡店...
条款21:优先考虑使用std:... 让我们先对std::make_unique和std::make_shared做个铺垫。std::ma...
Leetcode 第四天 动态... 来源:力扣(LeetCode) 链接:htt...
MongoDB用户管理授权 文章目录1 角色类型2 注意事项3 给单个数据库授权4 给一个用户授权多个数据库5 其它命令 1 角...
下载、安装JDK、sublim... 直接官网下载,jdk8或者jdk11。配置环境变量:如果不配置环境变量&...
算法的时间复杂度介绍 本文主要算法时间复杂度的相关知识。1 概述算法(Algorithm)是指...
编码方式概括 1.三种码表1.iso8859-1码表:是一种8位的单字节编码方式。它可以表示256个...
YOLOv5源码逐行超详细注释... 前言  本篇文章主要是对YOLOv5项目的验证部分。这个文件之前是叫test.py,后...
centos docker 安... 1、首先安装docker 下面是一键安装脚本 curl -fsSL https://get.dock...
线上操作规范 1.目的    1)为了避免测试线上随意操作给客户造成损失   2)为了...
查找算法之费氏搜寻法 给定一个大小为n的排序数组arr[],并在其中搜索一个元素x。如果x在数组中ÿ...
cv2报错:Unsupport... cv2 报错 error: OpenCV(4.6.0) /io/opencv/modules/img...
DVWA_xss 反射型xsslow直接在输入框输入提前准备的代码,就可以得到回显cookie信息 Me...
音视频开发编程技术(二):音频... 1. 音频简介   上一节讲过,视频的帧率即每秒钟采集多少张图片的概念。同理ÿ...
【Java学习笔记】33.Ja... 前言 本章介绍Java的HashSet及HashMap。 Java HashSet HashSet ...
RabbitMQ基础介绍及同步... 一、同步通讯与异步通讯 大多数情况下会使用同步,对并发没有很高的要求,但...
面试官:整理了一些react的... 请解释一下React生命周期。它们各自的作用是什么? React生命周期是指组件从创建...
【C++进阶】AVL树的实现 文章目录AVL树概念AVL树性质AVL树节点的结构AVL树的插入插入新节点更新整体节点的平衡因子旋转...
缺失的第一个正整数:给定一个未... 给定一个未排序的整数数组,找出其中未出现的最小正整数。 (本文获得CSDN质量评分...
[架构之路-141]-《软考-... 前言:如何“从无到有”设计一个企业信息系统?本文将探索这个话题。第1章 ...