gpt4 book ai didi

Grails 3.2.4 : custom authentication filter not called

转载 作者:行者123 更新时间:2023-12-02 09:35:23 25 4
gpt4 key购买 nike

从 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'
]

资源.grrovy

customAuthenticationFilter(CustomAuthenticationFilter) {
authenticationManager = ref('authenticationManager')
sessionAuthenticationStrategy = ref('sessionAuthenticationStrategy')
authenticationFailureHandler = ref('internalAuthenticationFailureHandler')
}

最佳答案

filterNames 映射定义如下:

**grails.plugin.springsecurity.filterChain.filterNames**= [  
**pattern**:'/**',
**filters**:'securityContextPersistenceFilter',
'logoutFilter',
'customAuthenticationFilter',
'rememberMeAuthenticationFilter',
'anonymousAuthenticationFilter',
'exceptionTranslationFilter',
'filterInvocationInterceptor'
]

关于Grails 3.2.4 : custom authentication filter not called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41918653/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com