| | |
| | | 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; |
| | |
| | | |
| | | /** |
| | | * spring security配置 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) |
| | |
| | | */ |
| | | @Autowired |
| | | private UserDetailsService userDetailsService; |
| | | |
| | | |
| | | /** |
| | | * 认证失败处理类 |
| | | */ |
| | |
| | | @Autowired |
| | | private CorsFilter corsFilter; |
| | | |
| | | @Autowired |
| | | private AdminServerProperties adminServerProperties; |
| | | |
| | | /** |
| | | * 解决 无法直接注入 AuthenticationManager |
| | | * |
| | |
| | | .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() |
| | |
| | | httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 强散列哈希加密实现 |
| | | */ |