| | |
| | | package com.ruoyi.framework.config; |
| | | |
| | | import com.ruoyi.framework.config.properties.SecurityProperties; |
| | | import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; |
| | | import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl; |
| | | import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl; |
| | |
| | | @Autowired |
| | | private CorsFilter corsFilter; |
| | | |
| | | @Autowired |
| | | private SecurityProperties securityProperties; |
| | | |
| | | /** |
| | | * 解决 无法直接注入 AuthenticationManager |
| | | * |
| | |
| | | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and() |
| | | // 过滤请求 |
| | | .authorizeRequests() |
| | | // 对于登录login 注册register 验证码captchaImage 允许匿名访问 |
| | | .antMatchers("/login", "/register", "/captchaImage").anonymous() |
| | | .antMatchers( |
| | | HttpMethod.GET, |
| | | "/", |
| | |
| | | "/**/*.css", |
| | | "/**/*.js" |
| | | ).permitAll() |
| | | .antMatchers("/doc.html").anonymous() |
| | | .antMatchers("/swagger-resources/**").anonymous() |
| | | .antMatchers("/webjars/**").anonymous() |
| | | .antMatchers("/*/api-docs").anonymous() |
| | | .antMatchers("/druid/**").anonymous() |
| | | // Spring Boot Actuator 的安全配置 |
| | | .antMatchers("/actuator").anonymous() |
| | | .antMatchers("/actuator/**").anonymous() |
| | | .antMatchers(securityProperties.getAnonymous()).anonymous() |
| | | // 除上面外的所有请求全部需要鉴权认证 |
| | | .anyRequest().authenticated() |
| | | .and() |