Commit 76afd073 by 赵天增

监控

parent 4aa9591c
......@@ -30,6 +30,15 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.0.2-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
......
package com.medtap.monitor.admin;
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;
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
private final String adminContextPath;
public WebSecurityConfig(AdminServerProperties adminServerProperties) {
this.adminContextPath = adminServerProperties.getContextPath();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
http.authorizeRequests()
.antMatchers(adminContextPath + "/assets/**").permitAll()
.antMatchers(adminContextPath + "/login").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and()
.logout().logoutUrl(adminContextPath + "/logout").and()
.httpBasic().and()
.csrf().disable();
// @formatter:on
}
}
......@@ -2,6 +2,7 @@ eureka:
instance:
leaseRenewalIntervalInSeconds: 10
health-check-url-path: /actuator/health
instance-id: ${spring.cloud.client.ip-address}:${server.port}
client:
registryFetchIntervalSeconds: 5
serviceUrl:
......@@ -17,8 +18,11 @@ management:
show-details: ALWAYS
# 微服务列表,如果服务不存在会触发邮件提醒
spring:
security:
user:
name: "server-monitor"
password: "2lvoHcfXbXmTBvQm"
boot:
admin:
notify:
......@@ -66,4 +70,6 @@ spring:
YJY-PROVIDER-THIRD,
YJY-PROVIDER-USER,
YJY-SERVER-CONFIG
application:
name: monitor
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment