spring_security自定义filter解决remember_me失效问题

[b]一[/b].最近项目要进行第三方登陆,由于项目用到了spring_security对于登陆方面需要自己重写 filter.
org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter

[b]二[/b].自己重写了这个filter,根据自己的业务需求去重写
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException

[b]三[/b].需要将[b]auto-config[/b]设为[b]false[/b],因为你不能再靠spring_security来进行filter拦截了,将自己重写[b]loginfilter[/b],替换[b]FORM_LOGIN_FILTER[/b]
[img]http://dl2.iteye.com/upload/attachment/0091/3312/a3f213a3-b185-3413-a5e8-ce0d2cb0b8d0.jpg[/img]
1.在[b]auto-config[/b]为[b][color=red]true[/color][/b],未自定义[b]filter[/b]时,下列用法是可行的.

[b]四[/b],解决remeber失效问题,如下操作.配置remeberservice,以及remember.provider.
[img]http://dl2.iteye.com/upload/attachment/0091/3314/efbbd5c9-e614-31ab-be0b-0900e31c19a4.jpg[/img]
[b]五[/b],最重要的就是,记得注入.自定义的loginfilter中,以及authentication-manager中.
[img]http://dl2.iteye.com/upload/attachment/0091/3316/59f903c6-97c7-3257-bf7a-e07d1b67dd95.jpg[/img]
[img]http://dl2.iteye.com/upload/attachment/0091/3318/33f240e6-7868-3b8f-8083-fcd983d0f5b3.jpg[/img]

如果有疑问,可以联系本人QQ1286814049

你可能感兴趣的:(spring,security,开源软件)