Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Got HTTP Status 405 in case of logout from Grails application with Spring Security Plugin

I'm adding Spring Security plugin(2.0 RC3) to my Grails app(2.4.4). However, once clicking 'Logout' link i see the web page with HTTP Status 405.

How this could be fixed?

like image 917
Vasyl Shyrochuk Avatar asked Feb 07 '15 14:02

Vasyl Shyrochuk


1 Answers

The reason of that could be found by analysis of LogoutController code

class LogoutController {

    def index() {

        if (!request.post && SpringSecurityUtils.getSecurityConfig().logout.postOnly) {
            response.sendError HttpServletResponse.SC_METHOD_NOT_ALLOWED // 405
            return
        }

        // TODO put any pre-logout code here
        redirect uri: SpringSecurityUtils.securityConfig.logout.filterProcessesUrl 
    }
}

So there are two fixes available:

1) Change 'Logout' link to send POST request.

<form name="logout" method="POST" action="${createLink(controller:'logout') }"> 
<input type="submit" value="logout"></form> 

2) Or just add following line to Config.groovy

grails.plugin.springsecurity.logout.postOnly = false
like image 197
Vasyl Shyrochuk Avatar answered Sep 28 '22 15:09

Vasyl Shyrochuk