简体   繁体   中英

Login failed when using custom Grails Spring Security filter

I am using Grails with the Spring Security plugin.

I have crafted a custom filter, authentication provider, and token and registered them as beans and into filter chain:

SpringSecurityUtils.clientRegisterFilter('myFilter',SecurityFilterPosition.SECURITY_CONTEXT_FILTER.order + 10) 

(I am not really sure what the order should be)

I POST to j_spring_security_check .

All seems to run smoothly to my successfulAuthentication where I set:

SecurityContextHolder.getContext().setAuthentication(authResult);

with no errors and SecurityContextHolder.getContext().getAuthentication() is set.

However Grails redirects me to login failed page.

Is something wrong with the j_spring_security_check page? Where is the error?

It was the url j_spring_security_check - it somehow rewrote the security context. So on using custom filters DO NOT use post url "j_spring_security_check", not necessary also.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM