从grails 2.5升级到grails 3.x时,用户名密码验证过滤器不会被触发。
我正在使用spring-security核心插件3.1.1
这就是自定义过滤器的样子
class CustomAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
@Override
protected String obtainUsername(HttpServletRequest request) {
return (new CustomPrincipal(request.getParameter('company'), request.getParameter('username'))).toString()
}
@Override
protected String obtainPassword(HttpServletRequest request) {
return request.getParameter('password')
}
}
application.groovy
grails.plugin.springsecurity.filterChain.filterNames = [
'securityContextPersistenceFilter',
'logoutFilter',
'customAuthenticationFilter',
'rememberMeAuthenticationFilter',
'anonymousAuthenticationFilter',
'exceptionTranslationFilter',
'filterInvocationInterceptor'
]
resources.grrovy
customAuthenticationFilter(CustomAuthenticationFilter) {
authenticationManager = ref('authenticationManager')
sessionAuthenticationStrategy = ref('sessionAuthenticationStrategy')
authenticationFailureHandler = ref('internalAuthenticationFailureHandler')
}
答案 0 :(得分:0)
过滤器名称映射 ,如下所示:
**grails.plugin.springsecurity.filterChain.filterNames**= [
**pattern**:'/**',
**filters**:'securityContextPersistenceFilter',
'logoutFilter',
'customAuthenticationFilter',
'rememberMeAuthenticationFilter',
'anonymousAuthenticationFilter',
'exceptionTranslationFilter',
'filterInvocationInterceptor'
]