v 2.9.0 & maxkey-boot-monitor

v 2.9.0 & maxkey-boot-monitor
This commit is contained in:
MaxKey
2021-08-20 12:36:10 +08:00
parent 68dcbce728
commit ec0518f7c1
7 changed files with 172 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
package org.maxkey.boot.monitor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
@Configuration
@EnableAdminServer
@SpringBootApplication(
exclude={
RedisAutoConfiguration.class,
DruidDataSourceAutoConfigure.class,
DataSourceAutoConfiguration.class
})
public class MaxKeyBootMonitor {
private static final Logger _logger = LoggerFactory.getLogger(MaxKeyBootMonitor.class);
public static void main(String[] args) {
_logger.info("Start MaxKeyBootMonitor ...");
SpringApplication.run(MaxKeyBootMonitor.class, args);
}
}

View File

@@ -0,0 +1,45 @@
package org.maxkey.boot.monitor;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
@Configuration
@EnableWebSecurity
public class MonitorSecurityConfigurer extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// <20><>¼<EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
successHandler.setDefaultTargetUrl("/");
http.authorizeRequests()
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤
.antMatchers(
"/login", //<2F><>¼ҳ<C2BC><D2B3>
"/assets/**", //<2F><>̬<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
"/actuator/**", //springboot-admin<69><6E><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
"/instances/**" //springboot-admin<69><6E><EFBFBD>ص<EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
).permitAll()
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>¼
.anyRequest().authenticated()
//<2F><>¼
.and().formLogin().loginPage("/login").successHandler(successHandler)
//<2F>dz<EFBFBD>
.and().logout().logoutUrl("/logout").logoutSuccessUrl("/login")
.and().httpBasic()
.and().csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
.ignoringAntMatchers(
"/instances",
"/actuator/**"
);
}
}

View File

@@ -0,0 +1,26 @@
############################################################################
# Copyright [2021] [MaxKey of copyright http://www.maxkey.top]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
############################################################################
#MaxKey Title and Version #
############################################################################
application.title=MaxKey
spring.application.name=maxkey-boot-admin-server
application.formatted-version=v2.9.0 GA
server.port=9528
spring.security.user.name=monitor
spring.security.user.password=maxkey
spring.security.basic.enabled=false

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" monitorInterval="300">
<Appenders>
<Console name="consolePrint" target="SYSTEM_OUT">
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} %-5level [%t] %logger{36}:%L - %msg%n" />
</Console>
<!-- 输出到文件按天或者超过128MB分割 每天进行归档yyyy-MM-dd -->
<RollingFile name="RollingFile" fileName="logs/maxkey-boot-admin.log" filePattern="logs/$${date:yyyyMMdd}/maxkey-boot-admin-%d{yyyy-MM-dd}-%i.log.gz">
<!-- 需要记录的级别 -->
<!-- <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" /> -->
<PatternLayout pattern="%d{YYYY-MM-dd HH:mm:ss,SSS} %-5level [%t] %logger{36}:%L - %msg%n" />
<Policies>
<OnStartupTriggeringPolicy />
<TimeBasedTriggeringPolicy />
<SizeBasedTriggeringPolicy size="128 MB" />
</Policies>
<DefaultRolloverStrategy max="100"/>
</RollingFile>
</Appenders>
<Loggers>
<Logger level="INFO" name="org.springframework" ></Logger>
<Logger level="INFO" name="org.apache.logging" ></Logger>
<Logger level="DEBUG" name="org.maxkey" ></Logger>
<Root level="INFO">
<AppenderRef ref="consolePrint" />
<AppenderRef ref="RollingFile" />
</Root >
</Loggers>
</Configuration>