| | |
| | | import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; |
| | | import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl; |
| | | import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl; |
| | | import com.ruoyi.framework.security.WechatAuthenticationProvider; |
| | | import com.ruoyi.framework.security.QyWechatAuthenticationProvider; |
| | | import com.ruoyi.common.annotation.Anonymous; |
| | | import org.springframework.security.web.util.matcher.RequestMatcher; |
| | | import org.springframework.web.method.HandlerMethod; |
| | |
| | | private RequestMappingHandlerMapping requestMappingHandlerMapping; |
| | | |
| | | /** |
| | | * 微信认证提供者 |
| | | */ |
| | | @Autowired |
| | | private WechatAuthenticationProvider wechatAuthenticationProvider; |
| | | |
| | | /** |
| | | * 企业微信认证提供者 |
| | | */ |
| | | @Autowired |
| | | private QyWechatAuthenticationProvider qyWechatAuthenticationProvider; |
| | | |
| | | /** |
| | | * 获取所有标注了@Anonymous的URL |
| | | */ |
| | | private Set<String> getAnonymousUrls() { |
| | |
| | | if (anonymous != null) { |
| | | Set<String> patterns = entry.getKey().getPatternValues(); |
| | | urls.addAll(patterns); |
| | | System.out.println("✅ 检测到匿名接口: " + patterns + " - " + handlerMethod.getMethod().getName()); |
| | | } |
| | | } |
| | | System.out.println("📜 所有匿名接口列表: " + urls); |
| | | return urls; |
| | | } |
| | | |
| | | /** |
| | | * 身份验证实现 |
| | | * 支持用户名密码认证、微信认证和企业微信认证 |
| | | */ |
| | | @Bean |
| | | public AuthenticationManager authenticationManager() |
| | | { |
| | | // 用户名密码认证提供者 |
| | | DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider(); |
| | | daoAuthenticationProvider.setUserDetailsService(userDetailsService); |
| | | daoAuthenticationProvider.setPasswordEncoder(bCryptPasswordEncoder()); |
| | | return new ProviderManager(daoAuthenticationProvider); |
| | | |
| | | // 返回ProviderManager,支持多种认证方式 |
| | | return new ProviderManager(daoAuthenticationProvider, wechatAuthenticationProvider, qyWechatAuthenticationProvider); |
| | | } |
| | | |
| | | /** |