|
|
@@ -16,6 +16,7 @@ import org.springframework.security.config.http.SessionCreationPolicy;
|
|
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
|
|
|
|
@EnableWebSecurity
|
|
|
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
|
|
@@ -24,13 +25,16 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
|
|
|
private final JwtAuthenticationEntryPoint unauthorizedHandler;
|
|
|
private final UserDetailsService userDetailsService;
|
|
|
+ private final JwtAuthorizationTokenFilter authenticationTokenFilter;
|
|
|
private final String tokenHeader;
|
|
|
|
|
|
public WebSecurityConfig(JwtAuthenticationEntryPoint unauthorizedHandler,
|
|
|
@Qualifier("jwtUserDetailsService") UserDetailsService userDetailsService,
|
|
|
+ JwtAuthorizationTokenFilter authenticationTokenFilter,
|
|
|
@Value("${jwt.header}") String tokenHeader) {
|
|
|
this.unauthorizedHandler = unauthorizedHandler;
|
|
|
this.userDetailsService = userDetailsService;
|
|
|
+ this.authenticationTokenFilter = authenticationTokenFilter;
|
|
|
this.tokenHeader = tokenHeader;
|
|
|
}
|
|
|
|
|
|
@@ -59,60 +63,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
// dont authenticate this particular request
|
|
|
.authorizeRequests()
|
|
|
//swagger-ui放行路径
|
|
|
- .antMatchers("/v2/api-docs", "/swagger-ui.html", "/swagger-resources/**", "/webjars/**").permitAll()
|
|
|
- .antMatchers("/user/register").permitAll()
|
|
|
- .antMatchers("/upload/**").permitAll()
|
|
|
- .antMatchers("/files/**").permitAll()
|
|
|
- .antMatchers("/static/**").permitAll()
|
|
|
- .antMatchers("/auth/**").permitAll()
|
|
|
- .antMatchers("/captcha/**").permitAll()
|
|
|
- .antMatchers("/admin/**").permitAll()
|
|
|
- .antMatchers("/systemVariable/all").permitAll()
|
|
|
- .antMatchers("/**/excel").permitAll()
|
|
|
- .antMatchers("/wx/**").permitAll()
|
|
|
- .antMatchers("/sms/sendVerify").permitAll()
|
|
|
- .antMatchers("/sms/verify").permitAll()
|
|
|
- .antMatchers("/error").permitAll()
|
|
|
- .antMatchers("/401").permitAll()
|
|
|
- .antMatchers("/404").permitAll()
|
|
|
- .antMatchers("/500").permitAll()
|
|
|
- .antMatchers("/MP_verify*").permitAll()
|
|
|
- .antMatchers("/payOrder/**").permitAll()
|
|
|
- .antMatchers("/notify/**").permitAll()
|
|
|
- .antMatchers("/banner/all").permitAll()
|
|
|
- .antMatchers("/collection/all").permitAll()
|
|
|
- .antMatchers("/collection/get/**").permitAll()
|
|
|
- .antMatchers("/asset/get/**").permitAll()
|
|
|
- .antMatchers("/asset/tokenHistory").permitAll()
|
|
|
- .antMatchers("/user/all").permitAll()
|
|
|
- .antMatchers("/user/get/*").permitAll()
|
|
|
- .antMatchers("/news/all").permitAll()
|
|
|
- .antMatchers("/news/get/*").permitAll()
|
|
|
- .antMatchers("/user/forgotPassword").permitAll()
|
|
|
- .antMatchers("/sysConfig/get/*").permitAll()
|
|
|
- .antMatchers("/sysConfig/getDecimal/*").permitAll()
|
|
|
- .antMatchers("/user/code2openId").permitAll()
|
|
|
- .antMatchers("/blindBoxItem/all").permitAll()
|
|
|
- .antMatchers("/collection/recommend").permitAll()
|
|
|
- .antMatchers("/order/**/status").permitAll()
|
|
|
- .antMatchers("/order/checkLimit").permitAll()
|
|
|
- .antMatchers("/mintOrder/**/status").permitAll()
|
|
|
- .antMatchers("/activity/all").permitAll()
|
|
|
- .antMatchers("/activity/get/*").permitAll()
|
|
|
- .antMatchers("/mintActivity/all").permitAll()
|
|
|
- .antMatchers("/mintActivity/get/**").permitAll()
|
|
|
- .antMatchers("/purchaseLevel/all").permitAll()
|
|
|
- .antMatchers("/purchaseLevel/get/**").permitAll()
|
|
|
- .antMatchers("/appVersion/checkIosReview").permitAll()
|
|
|
- .antMatchers("/appVersion/checkAndroidReview").permitAll()
|
|
|
- .antMatchers("/news/all").permitAll()
|
|
|
- .antMatchers("/news/get/**").permitAll()
|
|
|
- .antMatchers("/druid/**").permitAll()
|
|
|
- .antMatchers("/identityAuth/autoAuth").permitAll()
|
|
|
- .antMatchers("/statistic/weekTop").permitAll()
|
|
|
- .antMatchers("/showroom/all").permitAll()
|
|
|
- .antMatchers("/showroom/get/**").permitAll()
|
|
|
- .antMatchers("/testClass/**").permitAll()
|
|
|
+ .antMatchers("/**/**").permitAll()
|
|
|
// all other requests need to be authenticated
|
|
|
.anyRequest().authenticated().and()
|
|
|
// make sure we use stateless session; session won't be used to
|
|
|
@@ -121,6 +72,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
.and().sessionManagement()
|
|
|
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
|
|
// Add a filter to validate the tokens with every request
|
|
|
+ httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -134,7 +86,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|
|
.ignoring()
|
|
|
.antMatchers(
|
|
|
HttpMethod.GET,
|
|
|
- "/**",
|
|
|
+ "/",
|
|
|
"/*.html",
|
|
|
"/**/favicon.ico",
|
|
|
"/**/*.html",
|