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. 树莓派4B使用串口登录的设置方法

    -特别提示- 本文具有时效性. 当前我使用的是pi4硬件, 镜像版本 raspberrypi 5.15.61 32位. 在我解决该问题的时候, 在网上查找了很多方法, 有些方法被实际测试发现是不行的. ...

  2. upload—labs

    首先 常见黑名单绕过 $file_name = deldot($file_name);//删除文件名末尾的点上传 shell.php. $file_ext = strtolower($file_ext ...

  3. AtCoder Beginner Contest 237 G - Range Sort Query

    原题链接 G - Range Sort Query 思路: \(x\)是固定的,所以考虑将排序维护成0 1串,为\(p_i < x\)为\(0\),那么\(p_i \geq x\)为\(1\), ...

  4. (Good topic)二分法:x的平方根

      计算并返回 x 的平方根,其中 x 是非负整数. 由于返回类型是整数,结果只保留整数的部分,小数部分将被舍去. 示例 1: 输入: 4输出: 2 示例 2: 输入: 8输出: 2说明: 8 的平方 ...

  5. Android 11 使用 BroadcastReceiver 监听短消息

    使用装有MIUI系统的小米手机,静态注册的广播接收器监听短消息. 在AndroidManifest.xml中声明权限 <uses-permission android:name="an ...

  6. preparedStatement.setObject()为什么要这样写?

    setObject就是给JDBC的SQL语句的占位符赋值的,即是下面的"?" 预编译的SQL:参数使用?作为占位符 注意:sql的参数使用?作为占位符. 如: select * f ...

  7. Markdown References

    每次写文章,用到都要查一下的Markdown语法 字体颜色 [Markdown笔记]设置字体颜色 字体颜色 Font colors Decrsiption Demonstration Effect 选 ...

  8. ASR项目实战-架构设计

    一般而言,业务诉求作为架构设计的输入. 需求清单 对于语音识别产品而言,需满足的需求,举例如下: 功能需求 文件转写. 长文件转写,时长大于60秒,小于X小时,X可以指定为5. 短文件转写,时长小于6 ...

  9. Python——第一章:数据类型介绍

    数据类型: 区分不同的数据.不同的数据类型应该有不同的操作 数字: 做加减乘除+-*/ 整数,int 小数,float a= 10 #整数 b = 20 print(a + b) #加法运算 c = ...

  10. CentOS7,配置rsyslog客户端地址

    在CentOS 7系统,将所有日志转发到 192.168.168.168 日志服务器,你可以按照以下步骤进行配置: 确保rsyslog已经被安装 rpm -qa|grep rsyslog 1.打开 r ...