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. 解决 IAR中 Warning[Pa082] 的警告问题

    这个警告不属于严重问题 在 IAR (for STM8)的编译中,经常有如下的警告: Warning[Pa082]: undefined behavior: the order of volatile ...

  2. STM32F407 MCO输出的配置问题

    当前使用IDE: RT-Thread Studio 版本: 2.1.0 构建ID: 202103221400 配置如下: int MCO1_GPIO_INIT(void) { GPIO_InitTyp ...

  3. L3-009 长城

    #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using ll = lon ...

  4. Codeforces Round #701 (Div. 2) A~C 题解

    写在前边 链接:Codeforces Round #701 (Div. 2) 数学场,题目描述简单粗暴,思路很妙,代码短的不行,都是好神奇的一些题目. A. Add and Divide 链接:A题链 ...

  5. NPOI获取Excel文件里的形状/图片的坐标/锚点

    有个妹纸找我请教如何获取图片坐标,因此我到家后花了点时间,写了这份代码. 实测下来,可以正确获取 Excel 2003 版本的形状和图片这两种的坐标/锚点,以及 Excel 2007 版本的图片的坐标 ...

  6. Shell必备三剑客

    Top 目录 Sed--三剑客之一 基本格式 选项及含义 命令flags标记及功能 支持正则表达式, 扩展正则表达式 高级命令 命令格式 注意: 命令示例 字符串替换----'s' 行内容替换--'c ...

  7. 【Javaweb】html frame标签的使用 | 导航栏右侧内容的实现

    问题的产生: 是我和同伴做了一个导航栏,但是我们不知道怎么实现右侧内容的切换 然后我们查了很多资料,但是有一些是垂直的,但是就如图可见,我们是水平的,那么怎么实现水平切换呢? 上网看到了frame标签 ...

  8. .NET 程序员-开源项目【藏】

    Json.NET http://json.codeplex.com/ Json.Net是一个读写Json效率比较高的.Net框架.Json.Net 使得在.Net环境下使用Json更加简单.通过Lin ...

  9. springboot操作nosql的mongodb,或者是如何在mongodb官网创建服务器并进行操作

    第一步:在mongodb的官网里面创建云服务器 点进去 这是免费的,由于是一个项目只可以创建一个,这里我已经创建好了 用本地的mongodb服务也是可以的 第二步:点击connect,下载连接mong ...

  10. [ABC317G] Rearranging

    Problem Statement There is a grid with $N$ rows and $M$ columns. The square at the $i$-th row from t ...