疯狂的狮子li
2021-08-02 f8ab5663ef7220f8adc0fd8fcbd7d0cf84c6d77d
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -3,7 +3,6 @@
import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
import de.codecentric.boot.admin.server.config.AdminServerProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
@@ -21,7 +20,7 @@
/**
 * spring security配置
 *
 *
 * @author ruoyi
 */
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
@@ -32,7 +31,7 @@
     */
    @Autowired
    private UserDetailsService userDetailsService;
    /**
     * 认证失败处理类
     */
@@ -57,9 +56,6 @@
    @Autowired
    private CorsFilter corsFilter;
    @Autowired
    private AdminServerProperties adminServerProperties;
    /**
     * 解决 无法直接注入 AuthenticationManager
     *
@@ -100,26 +96,24 @@
                .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
                // 过滤请求
                .authorizeRequests()
                // 对于登录login 验证码captchaImage 允许匿名访问
                .antMatchers("/login", "/captchaImage").anonymous()
                // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                .antMatchers("/login", "/register", "/captchaImage").anonymous()
                .antMatchers(
                        HttpMethod.GET,
                        "/",
                        "/*.html",
                        "/**/*.html",
                        "/**/*.css",
                        "/**/*.js"
                        "/**/*.js",
                        "/profile/**"
                ).permitAll()
                .antMatchers("/profile/**").anonymous()
                .antMatchers("/common/download**").anonymous()
                .antMatchers("/common/download/resource**").anonymous()
                .antMatchers("/swagger-ui.html").anonymous()
                .antMatchers("/doc.html").anonymous()
                .antMatchers("/swagger-resources/**").anonymous()
                .antMatchers("/webjars/**").anonymous()
                .antMatchers("/*/api-docs").anonymous()
                .antMatchers("/druid/**").anonymous()
                // Spring Boot Admin Server 的安全配置
                .antMatchers(adminServerProperties.getContextPath()).anonymous()
                .antMatchers(adminServerProperties.getContextPath() + "/**").anonymous()
                // Spring Boot Actuator 的安全配置
                .antMatchers("/actuator").anonymous()
                .antMatchers("/actuator/**").anonymous()
@@ -135,7 +129,6 @@
        httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
    }
    /**
     * 强散列哈希加密实现
     */