首页 > 其他分享 >为SpringBoot Admin监控的服务端加上登录认证

为SpringBoot Admin监控的服务端加上登录认证

时间:2023-06-05 14:38:10浏览次数:44  
标签:SpringBoot Admin actuator springframework SpringSecurityActuatorConfig org impor


<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

为SpringBoot Admin监控的服务端加上登录认证_java

package com.ciih.refineinner.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@Slf4j
public class SpringSecurityActuatorConfig extends WebSecurityConfigurerAdapter {
    public SpringSecurityActuatorConfig() {
        log.info("SpringSecurityActuatorConfig... start");
    }
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        //  这个配置只针对  /actuator/** 的请求生效
        http.antMatcher("/actuator/**")
        // /actuator/下所有请求都要认证
                .authorizeRequests().anyRequest().authenticated()
        // 启用httpBasic认证模式,当springboot admin-client 配置了密码时,
        // admin-server走httpbasic的认证方式来拉取client的信息
                .and().httpBasic()
        // 禁用csrf
                .and().csrf().disable();
    }
}

标签:SpringBoot,Admin,actuator,springframework,SpringSecurityActuatorConfig,org,impor
From: https://blog.51cto.com/u_14121041/6415402

相关文章

  • 为SpringBoot Admin加上登录认证
    依赖<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency>配置server:port:8000spring:security:user:n......
  • SpringBoot Admin的基本使用(单体应用)
    springboot项目和springbootadmin项目不建议放在一起,因为目的是为了监控,如果放在一起的话,一旦springboot挂了,springbootadmin也就一起挂了,监控就失去意义.搭建监控项目:<dependencies><dependency><groupId>org.springframework.boot</groupId>......
  • SpringBoot2.x跨域问题(CrossOrigin失效问题)
    方法一SpringBoot版本的不同,CrossOrigin失效了,正确配置如下:@CrossOrigin(originPatterns="*",allowCredentials="true",maxAge=3600)方法二如果以上方法还是不生效,最后的终极方法可以进行硬编码进行跨域设置:对需要跨域的接口,进行Response对象设置可跨域URL设置(*代表......
  • kettle web springboot mvn dockerfile
    远程构建dcokerfileFROMopenjdk:8-jdk-alpineasTEMP_BUILD_IMAGERUNset-eux&&sed-i's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g'/etc/apk/repositoriesRUNapkupdate&&\apkadd--no-cachebashcurlwget&&......
  • SpringBoot2 缓存之王caffeine
    <dependency><groupId>com.github.ben-manes.caffeine</groupId><artifactId>caffeine</artifactId><version>2.9.0</version></dependency>顺便写了个工具类配合SpringBoot使用:packag......
  • SpringBoot配置多个RabbitMq
    YMLrabbitmq:first:username:${app.appkey}password:${app.appkey}virtual-host:${app.appid}addresses:x.x.x.x:5672,x.x.x.x:5672#集群second:username:guestpassword:guestvirtual-host:/host:......
  • springboot 项目打war包
    修改主类,参照以下格式EducationErverApplication.class@SpringBootApplication//war包启动类publicclassEducationErverApplicationextendsSpringBootServletInitializer{publicstaticvoidmain(String[]args){SpringApplication.run(EducationErve......
  • springboot 发送邮箱验证码
    0步骤总览开启邮箱的POP3/SMTP服务。新建springboot项目。导入依赖。配置配置文件。编写controller测试接口。postman中测试1开启邮箱的POP3/SMTP服务这里我用的网易邮箱,其它邮箱类似步骤,不清楚的可以百度。总之就是要打开pop3/smtp服务,如果按照我的方法......
  • springboot集成Knife4j
    1.springboot我用的2.7.X引入maven<!--整合Knife4j--><dependency><groupId>com.github.xiaoymin</groupId><artifactId>knife4j-spring-boot-starter</artifactId><version>3.0.3</version></dependency>......
  • SpringBoot中的定时任务的同步与异步
    SpringBoot中的定时任务的同步与异步你确定真的知道?授人以渔Java领域;架构知识;面试心得;互联网行业最新资讯定时任务调度功能在我们的开发中是非常常见的,随便举几个例子:定时清除一些过期的数据,定时发送邮件等等,实现定时任务调度的方式也十分多样,本篇文章主要学习各种实现定时任务......