mirror of
https://gitee.com/log4j/pig.git
synced 2025-01-03 23:42:22 +08:00
修改monitor security 配置方式 解决类过期问题
This commit is contained in:
parent
6cebdacdae
commit
13fbfd301a
@ -35,8 +35,9 @@ public class YamlPropertySourceFactory implements PropertySourceFactory {
|
|||||||
}
|
}
|
||||||
catch (IllegalStateException e) {
|
catch (IllegalStateException e) {
|
||||||
Throwable cause = e.getCause();
|
Throwable cause = e.getCause();
|
||||||
if (cause instanceof FileNotFoundException)
|
if (cause instanceof FileNotFoundException) {
|
||||||
throw (FileNotFoundException) e.getCause();
|
throw (FileNotFoundException) e.getCause();
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,13 @@ package com.pig4cloud.pig.monitor.config;
|
|||||||
|
|
||||||
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
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.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,8 +33,8 @@ import org.springframework.security.web.authentication.SavedRequestAwareAuthenti
|
|||||||
* @author lishangbu
|
* @author lishangbu
|
||||||
* @date 2019/2/1
|
* @date 2019/2/1
|
||||||
*/
|
*/
|
||||||
@Configuration(proxyBeanMethods = false)
|
@EnableWebSecurity
|
||||||
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
public class WebSecurityConfigurer{
|
||||||
|
|
||||||
private final String adminContextPath;
|
private final String adminContextPath;
|
||||||
|
|
||||||
@ -38,32 +42,35 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
|||||||
this.adminContextPath = adminServerProperties.getContextPath();
|
this.adminContextPath = adminServerProperties.getContextPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
@SneakyThrows
|
* spring security 默认的安全策略
|
||||||
protected void configure(HttpSecurity http) {
|
* @param http security注入点
|
||||||
// @formatter:off
|
* @return SecurityFilterChain
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
SecurityFilterChain defaultSecurityFilterChain(HttpSecurity http) throws Exception {
|
||||||
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
||||||
successHandler.setTargetUrlParameter("redirectTo");
|
successHandler.setTargetUrlParameter("redirectTo");
|
||||||
successHandler.setDefaultTargetUrl(adminContextPath + "/");
|
successHandler.setDefaultTargetUrl(adminContextPath + "/");
|
||||||
|
|
||||||
http
|
http
|
||||||
.headers().frameOptions().disable()
|
.headers().frameOptions().disable()
|
||||||
.and().authorizeRequests()
|
.and().authorizeRequests()
|
||||||
.antMatchers(adminContextPath + "/assets/**"
|
.antMatchers(adminContextPath + "/assets/**"
|
||||||
, adminContextPath + "/login"
|
, adminContextPath + "/login"
|
||||||
, adminContextPath + "/instances/**"
|
, adminContextPath + "/instances/**"
|
||||||
, adminContextPath + "/actuator/**"
|
, adminContextPath + "/actuator/**"
|
||||||
).permitAll()
|
).permitAll()
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
.and()
|
.and()
|
||||||
.formLogin().loginPage(adminContextPath + "/login")
|
.formLogin().loginPage(adminContextPath + "/login")
|
||||||
.successHandler(successHandler).and()
|
.successHandler(successHandler).and()
|
||||||
.logout().logoutUrl(adminContextPath + "/logout")
|
.logout().logoutUrl(adminContextPath + "/logout")
|
||||||
.and()
|
.and()
|
||||||
.httpBasic().and()
|
.httpBasic().and()
|
||||||
.csrf()
|
.csrf()
|
||||||
.disable();
|
.disable();
|
||||||
// @formatter:on
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user