Spring security Spring Security多个入口点-未找到登录进程URL

Spring security Spring Security多个入口点-未找到登录进程URL,spring-security,Spring Security,我重写了教程中的安全配置类 我尝试在没有登录的情况下输入条目,服务器重定向到登录页面,但提交用户凭据到登录处理URL返回页面未找到。我该怎么修 我的Spring安全配置: @配置 @启用Web安全性 公共类安全配置{ @自动连线 @限定符(“customUserDetailsService”) 用户详细信息服务用户详细信息服务; @自动连线 PersistentTokenRepository tokenRepository; @自动连线 public void configureGlobalSe

我重写了教程中的安全配置类

我尝试在没有登录的情况下输入条目,服务器重定向到登录页面,但提交用户凭据到登录处理URL返回页面未找到。我该怎么修

我的Spring安全配置:

@配置
@启用Web安全性
公共类安全配置{
@自动连线
@限定符(“customUserDetailsService”)
用户详细信息服务用户详细信息服务;
@自动连线
PersistentTokenRepository tokenRepository;
@自动连线
public void configureGlobalSecurity(AuthenticationManagerBuilder auth)引发异常{
auth.userDetailsService(userDetailsService);
auth.authenticationProvider(authenticationProvider());
}
@配置
@订单(1)
公共静态类MobileSecurityConfiguration扩展了WebSecurity配置适配器{
@凌驾
受保护的无效配置(HttpSecurity http)引发异常{
http
.antMatcher(“/mobile/**”)
.授权请求()
.anyRequest().hasRole(“移动”)
.及()
.formLogin()
.loginPage(“/mobile\u login”)
.loginProcessingUrl(“/mobile\u login\u processing\u url”)
.usernameParameter(“ssoId”)
.passwordParameter(“密码”)
.defaultSuccessUrl(“/mobile/menu”)
.及()
.logout()
.logoutUrl(“/mobile\u logout”)
.logoutSuccessUrl(“/mobile\u login?logout”)
.deleteCookies(“JSSessionID”)
.及()
.例外处理()
.accessDeniedPage(“/Access\u Denied”)
.defaultAuthenticationEntryPointFor(authenticationEntryPoint(),新的AntPathRequestMatcher(“/mobile/**”);
}
@豆子
公共身份验证入口点身份验证入口点(){
返回新的LoginUrlAuthenticationEntryPoint(“/mobile_login”);
}
}
@配置
@订单(2)
公共静态类WebSecurity配置扩展了WebSecurity配置适配器{
@自动连线
PersistentTokenRepository tokenRepository;
@凌驾
受保护的无效配置(HttpSecurity http)引发异常{
http
.授权请求()
.antMatchers(“/web/**”).hasRole(“管理员”)
.及()
.formLogin()
.loginPage(“/web\u login”)
.loginProcessingUrl(“/web\u login\u processing\u url”)
.usernameParameter(“ssoId”)
.passwordParameter(“密码”)
.defaultSuccessUrl(“/web/list”)
.及()
.logout()
.logoutUrl(“/logout”)
.logoutSuccessUrl(“/web\u login?logout”)
.deleteCookies(“JSSessionID”)
.及()
.exceptionHandling().accessDeniedPage(“/Access\u Denied”);
}
}
@豆子
公共密码编码器PasswordEncoder(){
返回新的BCryptPasswordEncoder();
}
@豆子
公共DaoAuthenticationProvider authenticationProvider(){
DaoAuthenticationProvider authenticationProvider=新的DaoAuthenticationProvider();
authenticationProvider.setUserDetailsService(userDetailsService);
setPasswordEncoder(passwordEncoder());
返回authenticationProvider;
}
@豆子
公共PersistentTokenBasedMemberMeservices GetPersistentTokenBasedMemberMeservices(){
PersistentTokenBasedRememberMeServices tokenBasedservice=新的PersistentTokenBasedRememberMeServices(
“记住我”,userDetailsService,tokenRepository);
返回基于令牌的服务;
}
@豆子
公共身份验证TrustResolver getAuthenticationTrustResolver(){
返回新的AuthenticationTrustResolverImpl();
}
}

您的登录处理URL
/mobile\u login\u processing\u URL
不可用

您配置了一个
formLogin
,它为
HttpSecurity
添加了一个
UsernamePasswordAuthenticationFilter
,请参阅:

将填充以下筛选器

  • UsernamePasswordAuthenticationFilter
但是您的
HttpSecurity
仅限于模式
/mobile/**
,请参阅:

允许将
HttpSecurity
配置为仅在匹配提供的ant模式时调用

因此,使用URL
/mobile\u login\u processing\u URL
时,不会调用
HttpSecurity
,因此永远不会应用
UsernamePasswordAuthenticationFilter
。如果没有此筛选器,则无法处理表单登录,请参阅:

处理身份验证表单提交

您必须将登录处理URL更改为
/mobile/mobile\u login\u processing\u URL
。查看您修改的配置:

@配置
@订单(1)
公共静态类MobileSecurityConfiguration扩展了WebSecurity配置适配器{
@凌驾
受保护的无效配置(HttpSecurity http)引发异常{
http
.antMatcher(“/mobile/**”)
.授权请求()
.anyRequest().hasRole(“移动”)
.及()
.formLogin()
.loginPage(“/mobile\u login”)
.loginProcessingUrl(“/mobile/mobile\u login\u processing\u url”)
.usernameParameter(“ssoId”)
.passwordParameter(“密码”)
.defaultSuccessUrl(“/mobile/menu”)
.及()
.logout()
.logoutUrl(“/mobile\u logout”)
.logoutSuccessUrl(“/mobile\u login?logout”)
.deleteCookies(“JSESSION