添加admin 监控

master
zhangmeng 2021-11-17 10:14:40 +08:00
parent aaf4a121ec
commit c6ae35354d
16 changed files with 200 additions and 11 deletions

View File

@ -56,6 +56,12 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -57,4 +57,15 @@ mystyle:
- /doc.html
- /webjars/**
#
- /upload/decoToken
- /upload/decoToken
- /actuator/**
- /instances/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS
enabled: true

View File

@ -101,5 +101,11 @@
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -66,4 +66,15 @@ mystyle:
- /doc.html
- /webjars/**
#
- /upload/decoToken
- /upload/decoToken
- /actuator/**
- /instances/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS
enabled: true

View File

@ -52,6 +52,12 @@
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -83,4 +83,13 @@ spring:
predicates:
- Path=/mystyle-cloud-admin-monitor/**
filters:
- StripPrefix=1
- StripPrefix=1
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS
enabled: true

View File

@ -52,5 +52,11 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -85,6 +85,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
http.authorizeRequests()
// 跨域预检请求
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.antMatchers(securityProperty.getOpenApi()).permitAll()
.anyRequest().
authenticated(); // 其他地址需要认证授权
}

View File

@ -62,4 +62,14 @@ mapper:
mystyle:
security:
open-api:
- /
- /actuator/**
- /instances/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS
enabled: true

View File

@ -75,6 +75,10 @@
<artifactId>mystyle-cloud-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,79 @@
package com.zhangmeng.oauth.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author
* @date 202191416:50:47
* @version 1.0
* */
@Configuration
@ConfigurationProperties("mystyle.security")
public class SecurityProperty {
/**
*
* */
private boolean superAuthOpen;
/**
*
* */
private String superAdmin;
/**
*
* */
private String rememberKey;
/**
*
* */
private String[] openApi;
/**
* 线
* */
private Integer maximum = 1;
public boolean isSuperAuthOpen() {
return superAuthOpen;
}
public void setSuperAuthOpen(boolean superAuthOpen) {
this.superAuthOpen = superAuthOpen;
}
public String getSuperAdmin() {
return superAdmin;
}
public void setSuperAdmin(String superAdmin) {
this.superAdmin = superAdmin;
}
public String getRememberKey() {
return rememberKey;
}
public void setRememberKey(String rememberKey) {
this.rememberKey = rememberKey;
}
public String[] getOpenApi() {
return openApi;
}
public void setOpenApi(String[] openApi) {
this.openApi = openApi;
}
public Integer getMaximum() {
return maximum;
}
public void setMaximum(Integer maximum) {
this.maximum = maximum;
}
}

View File

@ -1,5 +1,6 @@
package com.zhangmeng.oauth.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
@ -18,6 +19,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Order(-1)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private SecurityProperty securityProperty;
/***
* BCryptPasswordEncoder
* @return
@ -35,11 +40,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
// 对静态资源放行
web.ignoring().antMatchers(
"/user/login",
"/user/logout",
"/oauth/login","/user/oauth/parseToken"
);
web.ignoring().antMatchers(securityProperty.getOpenApi());
}
/***

View File

@ -52,4 +52,22 @@ feign:
config:
default:
connect-timeout: 20000
read-timeout: 20000
read-timeout: 20000
mystyle:
security:
open-api:
- /user/login
- /user/logout
- /oauth/login
- /user/oauth/parseToken
- /actuator/**
- /instances/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS
enabled: true

View File

@ -51,5 +51,11 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -85,6 +85,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
http.authorizeRequests()
// 跨域预检请求
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.antMatchers(securityProperty.getOpenApi()).permitAll()
.anyRequest().
authenticated(); // 其他地址需要认证授权
}

View File

@ -65,4 +65,18 @@ mapper:
style: normal
enum-as-simple-type: true
identity: MYSQL
check-example-entity-class: true
check-example-entity-class: true
mystyle:
security:
open-api:
- /actuator/**
- /instances/**
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: ALWAYS
enabled: true