Overwrite GSP plugin and controller in another plugin

I have a rather complicated dependency structure of the Grails plugin in my project, and I am having problems redefining classes from the security plugin.

My structure is a little something like this:

Web App |_ Audit Plugin |_ Spring Security Core Plugin |_ Security Wrapper Plugin |_ Audit Plugin |_ Spring Security Core Plugin 

The reason this happens is because the audit is distributed between some applications that have a security shell, and some do not, so it pulls in the Security-Core (this requires at least the ability to get the current core).

Similarly, the shell is distributed among several web applications, so we put it in the plugin. My problem occurs after updating Spring-Security-Core to version 2.

My wrapper has an auth.gsp client and LoginController.groovy. In the old security version, this was fine, since the plugin modeled them and made them available in the source of the installation plugin.

However, now these files are internal to the plugin, and although I know that you can override them in the main application, trying to override them in another plugin, I get some fancy results.

The Spring-Security-Core version of the login page always overrides my custom login page. I cannot make mine have an advantage.

The second problem is that LoginController.groovy from the Spring-Security-Core plugin sometimes takes precedence over my shell. It seems almost random between the assemblies for which it will be used.

Is there any right way to make sure my views and controllers take precedence?

+4
spring-security grails grails-plugin
source share
1 answer

OK, playing with things, I found a solution that seems to work for me:

Firstly, I could not change the order of loading plugins, since the security wrapper does a lot with spring beans, and it should be loaded after the main plugin works. Therefore, after a little jerk in ( DefaultSecurityConfig.groovy ), I noticed that you can set the following properties:

 grails.plugin.springsecurity.failureHandler.defaultFailureUrl = '/login/authfail? login_error=1' grails.plugin.springsecurity.failureHandler.ajaxAuthFailUrl = '/login/authfail?ajax=true' grails.plugin.springsecurity.auth.loginFormUrl = '/login/auth' 

So, I created a user controller and login page that have a different name for those used in the main plugin, and changed these properties to indicate my locations.

To put this together, in UrlMappings for the shell (named: SecWrapperUrlMappings) I put the mapping from / login / ** into / seclogin / **.

Make sure these new locations are not blocked so people can access them, and this seems to work well. Now I’m sure, I know, no matter what order they load on my login page and login controller.

+5
source share

All Articles