wlzboy
5 天以前 7de1396e315896dbc72a9d54e44f77434ea90f18
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -20,6 +20,8 @@
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;
@@ -78,6 +80,18 @@
    private RequestMappingHandlerMapping requestMappingHandlerMapping;
    /**
     * 微信认证提供者
     */
    @Autowired
    private WechatAuthenticationProvider wechatAuthenticationProvider;
    /**
     * 企业微信认证提供者
     */
    @Autowired
    private QyWechatAuthenticationProvider qyWechatAuthenticationProvider;
    /**
     * 获取所有标注了@Anonymous的URL
     */
    private Set<String> getAnonymousUrls() {
@@ -98,14 +112,18 @@
    /**
     * 身份验证实现
     * 支持用户名密码认证、微信认证和企业微信认证
     */
    @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);
    }
    /**