Admin 服务端配置

添加 POM 引用

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

配置  yml

spring:
# profiles:
# active: dev
resources:
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
security:
user:
name: vipsoft
password: VipSoftOps

添加配置类

import de.codecentric.boot.admin.server.config.AdminServerProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository; /**
* 授权配置类
* @author Jimmy
*/
@Configuration
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter { private final String adminContextPath; public SecuritySecureConfig(AdminServerProperties adminServerProperties) {
this.adminContextPath = adminServerProperties.getContextPath();
} @Override
protected void configure(HttpSecurity http) throws Exception {
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
successHandler.setDefaultTargetUrl(adminContextPath + "/");
http.authorizeRequests()
//1.配置所有静态资源和登录页可以公开访问
.antMatchers(adminContextPath + "/assets/**").permitAll()
.antMatchers(adminContextPath + "/login").permitAll()
.anyRequest().authenticated()
.and()
//2.配置登录和登出路径
.formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and()
.logout().logoutUrl(adminContextPath + "/logout").and()
//3.开启http basic支持,admin-client注册时需要使用
.httpBasic().and()
.csrf()
//4.开启基于cookie的csrf保护
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
//5.忽略这些路径的csrf保护以便admin-client注册
.ignoringAntMatchers(
adminContextPath + "/instances",
adminContextPath + "/actuator/**"
);
} }

运行Admin 后,出现登录框

Client 配置

spring:
boot:
admin:
client:
url: http://192.168.3.95:22589 #这里配置admin server 的地址
username: vipsoft #boot admin 中配置的用户名
password: VipSoftOps #boot admin 中配置的密码
instance:
name: VipSoft His Api Dev
service-url: http://192.168.0.66:22586 # 对于IP 映射或 Docker 很方便
prefer-ip: true #true 注册时 admin 中显示IP地址不显示主机名

运行命令

title VipSoft Admin 22589
java -jar vipsoft-boot-admin-1.0.0.jar --server.port=22589 --spring.security.user.name=vipsoft --spring.security.user.password=VipSoftOps

Spring Boot Admin 授权配置的更多相关文章

  1. Spring Boot 2.X(十七):应用监控之 Spring Boot Admin 使用及配置

    Admin 简介 Spring Boot Admin 是 Spring Boot 应用程序运行状态监控和管理的后台界面.最新UI使用vue.js重写里. Spring Boot Admin 为已注册的 ...

  2. Springboot监控之二:Spring Boot Admin对Springboot服务进行监控

    概述 Spring Boot 监控核心是 spring-boot-starter-actuator 依赖,增加依赖后, Spring Boot 会默认配置一些通用的监控,比如 jvm 监控.类加载.健 ...

  3. spring boot admin项目的集成和开发

    Spring Boot Admin是一个Github上的一个开源项目,它在Spring Boot Actuator的基础上提供简洁的可视化WEB UI,是用来管理 Spring Boot 应用程序的一 ...

  4. Spring Boot Admin 的使用 2

    http://blog.csdn.net/kinginblue/article/details/52132113 ******************************************* ...

  5. Spring Boot Admin简介及实践

    问题 在若干年前的单体应用时代,我们可以相对轻松地对整个业务项目进行健康检查.指标监控.配置管理等等项目治理.如今随着微服务的发展,我们将大型单体应用按业务模型进行划分,以此形成众多小而自治的微服务, ...

  6. Spring Boot Admin的使用

    http://www.jianshu.com/p/e20a5f42a395 ******************************* 上一篇文章中了解了Spring Boot提供的监控接口,例如 ...

  7. Spring Boot admin 2.0 详解

    一.什么是Spring Boot Admin ? Spring Boot Admin是一个开源社区项目,用于管理和监控SpringBoot应用程序. 应用程序作为Spring Boot Admin C ...

  8. SpringBoot | 第二十八章:监控管理之Spring Boot Admin使用

    前言 上一章节,我们介绍了Actuator的使用,知道了可通过访问不同的端点路径,获取相应的监控信息.但使用后也能发现,返回的监控数据都是以JSON串的形式进行返回的,对于实施或者其他人员来说,不是很 ...

  9. 【Spring Boot】利用 Spring Boot Admin 进行项目监控管理

    利用 Spring Boot Admin 进行项目监控管理 一.Spring Boot Admin 是什么 Spring Boot Admin (SBA) 是一个社区开源项目,用于管理和监视 Spri ...

  10. spring boot:用spring security加强spring boot admin的安全(spring boot admin 2.3.0 / spring boot 2.3.3)

    一,spring boot admin的安全环节: 1,修改context-path,默认时首页就是admin, 我们修改这个地址可以更安全 2,配置ip地址白名单,有ip限制才安全, 我们使用了sp ...

随机推荐

  1. Python利用pandas进行数据合并

    当使用Python中的pandas库时,merge函数是用于合并(或连接)两个数据框(DataFrame)的重要工具.它类似于SQL中的JOIN操作,允许你根据一个或多个键(key)将两个数据框连接起 ...

  2. 对 .NET程序2G虚拟地址紧张崩溃 的最后一次反思

    一:背景 1. 讲故事 最近接连遇到了几起 2G 虚拟地址紧张 导致的程序崩溃,基本上 90% 都集中在医疗行业,真的很无语,他们用的都是一些上古的 XP,Windows7 x86,我也知道技术人很难 ...

  3. Head First Java学习:第八章-接口和抽象类

    第八章:接口和抽象类 深入多态 1.抽象类:有些类不应该被初始化 在类声明前面加上抽象类的关键字,abstract. 防止类被初始化,即不能被"new"创建该类的实例(要求) 还是 ...

  4. Storm 集群的搭建及其Java编程进行简单统计计算

    一.Storm集群构建 编写storm 与 zookeeper的yml文件 storm yml文件的编写 具体如下: version: '2' services: zookeeper1: image: ...

  5. 年度盘点,四年的精华合集「GitHub 热点速览」

    今年是 GPT 年,无论是 GitHub 还是朋友圈还是技术平台,即便你不关心 GPT 的发展情况,同大模型.AI 相关的项目总能进入你的信息流.到这期为止,热度速览也连载了四年,从一开始习惯看 Gi ...

  6. JavaScript String对象及方法总结

    String 对象创建方法: new String() var txt1 = new String("string"); var txt2 = "string" ...

  7. iMessage群发,iMessage群发基础知识,iMessage群发源代码分享

    在当今的数字化时代,即时通讯已经成为我们日常生活和工作中不可或缺的一部分,其中,苹果的iMessage服务因其出色的用户体验和无缝的设备间同步而备受用户喜爱. 然而,你是否想过如何利用iMessage ...

  8. ASR项目实战-项目交付历程

    本文记录,作为项目主要负责人,完整参与语音识别项目的交付历程. 2019年12月中旬 接到项目交付任务,收集基本知识,启动业务分析工作. 2020年1月 完成竞品分析的整理. 梳理合作伙伴的清单,整理 ...

  9. Windows Server 2012 R2 远程桌面服务部署指南

    著作权归作者所有:来自51CTO博客作者mabofeng的原创作品,请联系作者获取转载授权,否则将追究法律责任 01-Windows Server 2012 R2 远程桌面服务部署指南文章来源:htt ...

  10. shell的变量

    变量含义 学生时代所学的数学方程式,如x=1,y=2,那会称之为x,y是未知数 对于计算机角度,x=1,y=2等于定义了两个变量,名字分别是x,y,且赋值了1和2 变量是暂时存储数据的地方,变量临时存 ...