SecurityConfig文件配置!

product
巴卫 2 years ago
parent 7df8f0aa8d
commit 98237cb7f7

@ -130,24 +130,24 @@
<artifactId>sqljdbc4</artifactId>
<version>${sqlserver.version}</version>
</dependency>-->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
<dependency>
<groupId>com.oracle.database.nls</groupId>
<artifactId>orai18n</artifactId>
</dependency>
<!-- dm -->
<dependency>
<groupId>com.dm</groupId>
<artifactId>DmJdbcDriver18</artifactId>
</dependency>
<!--人大金仓-->
<dependency>
<groupId>com.kingbase8</groupId>
<artifactId>kingbase8-jdbc</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.oracle.database.jdbc</groupId>-->
<!-- <artifactId>ojdbc8</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.oracle.database.nls</groupId>-->
<!-- <artifactId>orai18n</artifactId>-->
<!-- </dependency>-->
<!-- &lt;!&ndash; dm &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>com.dm</groupId>-->
<!-- <artifactId>DmJdbcDriver18</artifactId>-->
<!-- </dependency>-->
<!-- &lt;!&ndash;人大金仓&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>com.kingbase8</groupId>-->
<!-- <artifactId>kingbase8-jdbc</artifactId>-->
<!-- </dependency>-->
<!--PostGre-->
<dependency>
<groupId>org.postgresql</groupId>

@ -10,9 +10,6 @@ import org.springframework.security.config.annotation.authentication.builders.Au
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.core.userdetails.UserDetailsService;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
*
@ -23,23 +20,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
*/
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter implements WebMvcConfigurer {
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
//private UserDetailsServiceImpl userDetailsService;
private UserDetailsService userDetailsService;
private UserDetailsServiceImpl userDetailsService;
@Autowired
private MyPasswordEncoder passwordEncoder;
private static final String[] URL_WHITELIST = {
"/favicon.ico",
"/webjars/**",
"/img.icons/**",
"/swagger-resources/**",
"/v3/api-docs/**",
"/swagger-ui/**",
"/doc.html",
};
/**
*
@ -52,29 +39,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter implements WebM
http.headers().frameOptions().disable();
http.csrf().disable().authorizeRequests()
.antMatchers("/RSA/publicKey").permitAll()
.antMatchers("/jmreport/**").anonymous()
// 配置拦截规则
.and()
.authorizeRequests()
.antMatchers(URL_WHITELIST).permitAll()
.anyRequest().authenticated();
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations(
"classpath:/static/");
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
.antMatchers("/jmreport/**").anonymous();
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
}
/**

Loading…
Cancel
Save