我从登录页面重定向身份验证链接时遇到麻烦。我将链接添加到我在JSF中的登录页面中,如下所示:
<div>
<a href="pageToRedirect.xhtml">Login via Testinium Cloud</a>
</div>
我的春季安全配置是这样的:
and()
.authorizeRequests()
.antMatchers(DEFAULT_URL).permitAll()
.antMatchers("/javax.faces.resource/**").permitAll()
.antMatchers("/jsfPages/*").permitAll()
.antMatchers("/errorPages/*").permitAll()
.anyRequest().authenticated()
.and()
.exceptionHandling()
.accessDeniedHandler(jsfAccessDeniedHandler())
.authenticationEntryPoint(jsfAuthenticationEntryPoint())
.and()
.formLogin()
.loginPage(LOGIN_PAGE).permitAll()
.failureUrl(LOGIN_PAGE).permitAll()
.defaultSuccessUrl(DEFAULT_URL)
.successHandler(authSuccessHandler)
.and()
.logout()
.logoutUrl(LOGOUT_URL).permitAll()
.invalidateHttpSession(true)
.logoutSuccessHandler(logoutSuccessHandler)
.and()
.exceptionHandling().accessDeniedPage("/error/403.xhtml");
我该如何从登录页面重定向我的链接而又不会出现身份验证错误。我试过了
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/api/v1/signup");
}
但这对我没有用。谢谢!
如果要在不覆盖Web安全性的情况下从Spring安全性配置中排除页面,则可以使用authenticated()方法在代码中添加连接到“ antMatchers”方法的“ not”方法,如下所示:
.authorizeRequests()
.antMatchers(DEFAULT_URL).permitAll()
.antMatchers("/javax.faces.resource/**").permitAll()
.antMatchers("/jsfPages/*").permitAll()
.antMatchers("/errorPages/*").permitAll()
.antMatchers(LOGIN_TESTINIUM).not().authenticated()
.anyRequest().authenticated()
.and()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句