Search code examples
grailsgroovyspring-securitygrails-controllergrails-config

Spring Security and Grails - customizing URLS


In a current Grails app I'm working on all my account management now happens under an account controller which I would like to keep all those actions mapped under the /account/* URL pattern.

I'm using Spring Security Core. On a failed login the app still directs me to
/login/authfail?login_error=1
I want it to use
/account/authfail?login_error=1

So my question is how do I configure the default
SpringSecurityUtils.securityConfig.successHandler.defaultTargetUrl
and whatever the failure URL is also (I need to know the name of this property) Is this documented somewhere?


Solution

  • The spring-security-core plugin is actually one of the best documented plugins out there. You can find all the URL configuration options here. Specifically, you want failureHandler.defaultFailureUrl and possibly failureHandler.ajaxAuthFailUrl. Note that I believe these will be global changes. So if you need to lock down other aspets of your site other than "accounts" the URL for a failed attempt will be the same as you configured it.