补充错误处理器

This commit is contained in:
zlt2000
2020-06-11 00:06:00 +08:00
parent e9f4832c3f
commit c250fb582a
2 changed files with 6 additions and 0 deletions
@@ -134,6 +134,10 @@ public interface SecurityConstants {
* 登录页面
*/
String LOGIN_PAGE = "/login.html";
/**
* 登录失败页面
*/
String LOGIN_FAILURE_PAGE = LOGIN_PAGE + "?error";
/**
* 默认的OPENID登录请求处理url
*/
@@ -22,6 +22,7 @@ import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.LogoutHandler;
@@ -86,6 +87,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
filter.setAuthenticationManager(authenticationManager);
filter.setFilterProcessesUrl(SecurityConstants.OAUTH_LOGIN_PRO_URL);
filter.setAuthenticationSuccessHandler(authenticationSuccessHandler);
filter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler(SecurityConstants.LOGIN_FAILURE_PAGE));
return filter;
}