mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 12:39:05 +08:00
Merge branch 'master' into leng_dev
This commit is contained in:
commit
5a3493c33e
4 files changed
+10
-3
No files matched your search
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.pig4cloud.pigx.auth.config;
|
||||
|
||||
import com.pig4cloud.pigx.common.core.util.SpringContextHolder;
|
||||
import com.pig4cloud.pigx.common.security.component.PigxDaoAuthenticationProvider;
|
||||
import com.pig4cloud.pigx.common.security.grant.CustomAppAuthenticationProvider;
|
||||
import com.pig4cloud.pigx.common.security.handler.FormAuthenticationFailureHandler;
|
||||
@@ -27,6 +28,7 @@ import com.pig4cloud.pigx.common.security.handler.SsoLogoutSuccessHandler;
|
||||
import com.pig4cloud.pigx.common.security.handler.TenantSavedRequestAwareAuthenticationSuccessHandler;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
@@ -71,11 +73,16 @@ public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
|
||||
protected void configure(AuthenticationManagerBuilder auth) {
|
||||
PigxDaoAuthenticationProvider daoAuthenticationProvider = new PigxDaoAuthenticationProvider();
|
||||
daoAuthenticationProvider.setPasswordEncoder(passwordEncoder());
|
||||
// 注入自定义异常国际化文件处理器
|
||||
MessageSource messageSource = SpringContextHolder.getBean("securityMessageSource");
|
||||
daoAuthenticationProvider.setMessageSource(messageSource);
|
||||
|
||||
// 处理默认的密码模式认证
|
||||
auth.authenticationProvider(daoAuthenticationProvider);
|
||||
// 自定义的认证模式
|
||||
auth.authenticationProvider(new CustomAppAuthenticationProvider());
|
||||
CustomAppAuthenticationProvider customAppAuthenticationProvider = new CustomAppAuthenticationProvider();
|
||||
customAppAuthenticationProvider.setMessageSource(messageSource);
|
||||
auth.authenticationProvider(customAppAuthenticationProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class PigxSecurityMessageSourceConfiguration implements WebMvcConfigurer
|
||||
@Bean
|
||||
public MessageSource securityMessageSource() {
|
||||
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
|
||||
messageSource.addBasenames("classpath:org/springframework/security/messages");
|
||||
messageSource.addBasenames("classpath:errors/messages");
|
||||
return messageSource;
|
||||
}
|
||||
|
||||
|
||||
File renamed without changes.
+1
-1
@@ -101,7 +101,7 @@ public class GlobalBizExceptionHandler {
|
||||
public R handleBodyValidException(BindException exception) {
|
||||
List<FieldError> fieldErrors = exception.getBindingResult().getFieldErrors();
|
||||
// 插入log 的逻辑
|
||||
return R.failed(fieldErrors.get(0).getDefaultMessage());
|
||||
return R.failed(String.format("%s %s", fieldErrors.get(0).getField(), fieldErrors.get(0).getDefaultMessage()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user