如何使用Grails/Spring Security Core强制进行程序化注销?

Mar*_*rco 4 grails spring-security

如何使用Spring Security Core强制为登录用户注销程序?我不想重定向到注销页面等..但需要在服务中进行.

小智 5

这是另一种方法.我从bean"logoutHandlers"获取注销处理程序并在每个注销中执行注销:

def logoutHandlers
def logout(request,response) {
    Authentication auth = SecurityContextHolder.context.authentication
    if (auth) {
        logoutHandlers.each  { handler->
            handler.logout(request,response,auth)
        }
    }

}
Run Code Online (Sandbox Code Playgroud)