Commit 5b42d5f6 authored by fangxinjiang's avatar fangxinjiang

鉴权-fxj

parent dc7a4215
......@@ -18,6 +18,7 @@ package com.yifu.cloud.plus.v1.yifu.auth.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yifu.cloud.plus.v1.yifu.auth.filter.PasswordDecoderFilter;
import com.yifu.cloud.plus.v1.yifu.auth.filter.WxLoginAuthenticationFilter;
import com.yifu.cloud.plus.v1.yifu.auth.handler.YifuAuthenticationFailureHandlerImpl;
import com.yifu.cloud.plus.v1.yifu.auth.handler.YifuClientLoginSuccessHandler;
import com.yifu.cloud.plus.v1.yifu.common.security.component.CasAuthenticationProvider;
......@@ -84,11 +85,11 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
@SneakyThrows
protected void configure(HttpSecurity http) {
http.addFilterBefore(getPasswordDecoderFilter(),PasswordDecoderFilter.class)
.formLogin().loginPage("/token/login").loginProcessingUrl("/token/form")
.failureHandler(authenticationFailureHandler()).and().logout()
.logoutSuccessHandler(logoutSuccessHandler()).deleteCookies("JSESSIONID").invalidateHttpSession(true)
.and()
.authorizeRequests().antMatchers("/**/login","/token/**", "/actuator/**", "/mobile/**", "/oauth/token","/weixin/callback","**/oauth/wxLogin").permitAll()
//.formLogin().loginPage("/token/login").loginProcessingUrl("/token/form")
//.failureHandler(authenticationFailureHandler()).and().logout()
//.logoutSuccessHandler(logoutSuccessHandler()).deleteCookies("JSESSIONID").invalidateHttpSession(true)
//.and()
.authorizeRequests().antMatchers("/**/login","/token/**", "/actuator/**", "/mobile/**", "/oauth/token","/weixin/callback","/oauth/**", "/wxLogin").permitAll()
.anyRequest().authenticated().and().csrf().disable();
}
......@@ -186,6 +187,25 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter {
return filter;
}
/**
* @param
* @Author: fxj
* @Date: 2025-01-10
* @Description: 微信登录
**/
@Bean
public WxLoginAuthenticationFilter wxLoginAuthenticationFilter() {
WxLoginAuthenticationFilter filter = new WxLoginAuthenticationFilter();
try {
filter.setAuthenticationManager(this.authenticationManagerBean());
} catch (Exception e) {
log.error("WebSecurityConfigurer>>>>",e);
}
filter.setAuthenticationSuccessHandler(yifuClientLoginSuccessHandler());
filter.setAuthenticationFailureHandler(yifuAuthenticationFailureHandler());
return filter;
}
private AuthenticationFailureHandler yifuAuthenticationFailureHandler() {
return YifuAuthenticationFailureHandlerImpl.builder()
.objectMapper(objectMapper).build();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment