自定义注销处理程序不工作的Grails

时间:2015-05-24 07:18:17

标签: grails spring-security

我在grails中实现了自定义Logout处理程序。由于某些原因,它无法正常工作。我在stackoverflow上检查了一个类似的问题 spring security logout handler not working,但它对我不起作用。问题是我的自定义方法没有被调用。 我的代码如下:

Config.groovy

    grails.plugin.springsecurity.filterChain.chainMap = [
    '/api/v1/login/**': 'authenticationProcessingFilter,restAuthenticationFilter,restTokenValidationFilter,filterInvocationInterceptor,restExceptionTranslationFilter',
    '/api/v1/logout/**': 'authenticationProcessingFilter,restAuthenticationFilter,restExceptionTranslationFilter,restLogoutFilter',
    '/**': 'securityContextPersistenceFilter,anonymousAuthenticationFilter,restAuthenticationFilter,restTokenValidationFilter,restExceptionTranslationFilter,filterInvocationInterceptor']

    grails.plugin.springsecurity.useSecurityEventListener = true

    grails.plugin.springsecurity.logout.handlerNames =
    ['rememberMeServices', 'myHandler' ,
     'securityEventListener',
     'securityContextLogoutHandler']

resources.groovy

    beans = {
myHandler(com.as.rest.handlers.CustomSecurityContextLogoutHandler) }

CustomSecurityContextLogoutHandler.groovy

    package com.as.rest.handlers

    import org.springframework.security.core.Authentication
    import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler

    import javax.servlet.http.HttpServletRequest
    import javax.servlet.http.HttpServletResponse


    class CustomSecurityContextLogoutHandler extends SecurityContextLogoutHandler {

@Override
void logout(HttpServletRequest request, HttpServletResponse response,
            Authentication authentication) {

    println("#############################################")
    println("#############################################")
    println("#############################################")
    println("logout")
}

    }

0 个答案:

没有答案