SecurityConfig文件配置!

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

@ -130,24 +130,24 @@
<artifactId>sqljdbc4</artifactId> <artifactId>sqljdbc4</artifactId>
<version>${sqlserver.version}</version> <version>${sqlserver.version}</version>
</dependency>--> </dependency>-->
<dependency> <!-- <dependency>-->
<groupId>com.oracle.database.jdbc</groupId> <!-- <groupId>com.oracle.database.jdbc</groupId>-->
<artifactId>ojdbc8</artifactId> <!-- <artifactId>ojdbc8</artifactId>-->
</dependency> <!-- </dependency>-->
<dependency> <!-- <dependency>-->
<groupId>com.oracle.database.nls</groupId> <!-- <groupId>com.oracle.database.nls</groupId>-->
<artifactId>orai18n</artifactId> <!-- <artifactId>orai18n</artifactId>-->
</dependency> <!-- </dependency>-->
<!-- dm --> <!-- &lt;!&ndash; dm &ndash;&gt;-->
<dependency> <!-- <dependency>-->
<groupId>com.dm</groupId> <!-- <groupId>com.dm</groupId>-->
<artifactId>DmJdbcDriver18</artifactId> <!-- <artifactId>DmJdbcDriver18</artifactId>-->
</dependency> <!-- </dependency>-->
<!--人大金仓--> <!-- &lt;!&ndash;人大金仓&ndash;&gt;-->
<dependency> <!-- <dependency>-->
<groupId>com.kingbase8</groupId> <!-- <groupId>com.kingbase8</groupId>-->
<artifactId>kingbase8-jdbc</artifactId> <!-- <artifactId>kingbase8-jdbc</artifactId>-->
</dependency> <!-- </dependency>-->
<!--PostGre--> <!--PostGre-->
<dependency> <dependency>
<groupId>org.postgresql</groupId> <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.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 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.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 @Configuration
@EnableWebSecurity @EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter implements WebMvcConfigurer { public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired @Autowired
//private UserDetailsServiceImpl userDetailsService; private UserDetailsServiceImpl userDetailsService;
private UserDetailsService userDetailsService;
@Autowired @Autowired
private MyPasswordEncoder passwordEncoder; 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.headers().frameOptions().disable();
http.csrf().disable().authorizeRequests() http.csrf().disable().authorizeRequests()
.antMatchers("/RSA/publicKey").permitAll() .antMatchers("/RSA/publicKey").permitAll()
.antMatchers("/jmreport/**").anonymous() .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/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
} }
/** /**

Loading…
Cancel
Save