嗨kabal -
我有非常类似的要求,我跟着你的和zagyi的和lion's后,但我似乎仍然松散/登录页面上的原始请求参数。
这是我有:
public class AuthenticationProcessingFilterEntryPoint extends LoginUrlAuthenticationEntryPoint {
@Override
protected String determineUrlToUseForThisRequest(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) {
String url = super.determineUrlToUseForThisRequest(request, response, exception);
return url + "?" + request.getQueryString();
}
}
protected void configure(final HttpSecurity httpSecurity) throws Exception {
httpSecurity.
formLogin().loginPage("/signIn").permitAll().
and().
authorizeRequests().
antMatchers(managementContextPath + "/**").permitAll().
anyRequest().authenticated().withObjectPostProcessor(objectPostProcessor).
and().
csrf().disable().
contentTypeOptions().
xssProtection().
cacheControl().
httpStrictTransportSecurity().
and().
requestCache().requestCache(new RedisRequestCache(savedRequestRedisTemplate())).
and().
sessionManagement().sessionAuthenticationStrategy(sessionAuthenticationStrategy).
and().
addFilter(new ExceptionTranslationFilter(new AuthenticationProcessingFilterEntryPoint()));
}
我可以看到AuthenticationProcessingFilterEntryPoint部署,但它并没有打一个断点。
根据documentation,这似乎只有在出现AuthenticationException或AccessDeniedException时才会启动。在上面的配置中,我不确定当这种情况发生时,Spring是否会引发这种异常。
此外,我想保留着陆页上的查询参数,无论身份验证是否成功。
我确实添加了成功和失败处理程序,但没有人会采取行动。
protected void configure(final HttpSecurity httpSecurity) throws Exception {
httpSecurity.
formLogin().
successHandler(new PropogateQueryStringAuthenticationSuccessHandlerImpl()).
failureHandler(new SimpleUrlAuthenticationFailureHandlerImpl(new QueryStringPropagateRedirectStrategy())).
and().
authorizeRequests().
antMatchers(managementContextPath + "/**").permitAll().
anyRequest().authenticated().withObjectPostProcessor(objectPostProcessor).
and().
csrf().disable().
contentTypeOptions().
xssProtection().
cacheControl().
httpStrictTransportSecurity().
and().
requestCache().requestCache(new RedisRequestCache(savedRequestRedisTemplate())).
and().
sessionManagement().sessionAuthenticationStrategy(sessionAuthenticationStrategy);
}
我使用的弹簧引导1.1.6.RELEASE(又使用Spring框架4.0.7.RELEASE)
谢谢,弹簧安全3.2.4.RELEASE 圣
来源
2014-12-17 05:52:04
San
你可以使用弹簧安全3.1吗?作为Maksym –
我建议使用与您的spring-framework相同版本的spring-security。 – tom
@MaksymDemidas是的,我可能会升级到弹簧安全3.1。 – kabal