“djh”
3 days ago aad364bb323a1eaa0389ee5c6389bdc0ea7ed526
hazmat-framework/src/main/java/com/gkhy/hazmat/framework/security/SecurityConfig.java
@@ -1,6 +1,7 @@
package com.gkhy.hazmat.framework.security;
import com.gkhy.hazmat.framework.security.filter.JwtAuthenticationTokenFilter;
import com.gkhy.hazmat.framework.security.filter.ThirdPartyTokenFilter;
import com.gkhy.hazmat.framework.security.handle.AuthenticationEntryPointImpl;
import com.gkhy.hazmat.framework.security.handle.LogoutSuccessHandlerImpl;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,6 +52,9 @@
     */
    @Autowired
    private JwtAuthenticationTokenFilter authenticationTokenFilter;
    @Autowired
    private ThirdPartyTokenFilter thirdPartyTokenFilter;
    
    /**
     * 跨域过滤器
@@ -101,7 +105,7 @@
        httpSecurity
                // CSRF禁用,因为不使用session
                .cors().and()
//                .cors().and()
                .csrf().disable()
                // 禁用HTTP响应标头
                .headers().cacheControl().disable().and()
@@ -111,6 +115,7 @@
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
                // 过滤请求
                .authorizeRequests()
                .antMatchers("/api/hazmat/zkd/data/**").permitAll()
                // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                .antMatchers("/**/login", "/register", "/system/captcha/captchaImage").permitAll()
                // 静态资源,可匿名访问
@@ -123,10 +128,11 @@
        // 添加Logout filter
        httpSecurity.logout().logoutUrl("/logout").logoutSuccessHandler(logoutSuccessHandler);
        // 添加JWT filter
        httpSecurity.addFilterBefore(corsFilter, UsernamePasswordAuthenticationFilter.class);
        // 2. 第三方固定Token过滤器
        httpSecurity.addFilterBefore(thirdPartyTokenFilter, UsernamePasswordAuthenticationFilter.class);
        // 3. 登录用户JWT过滤器
        httpSecurity.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
        // 添加CORS filter
        httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class);
        httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
    }
    /**