Issue
My app architecture is like so:
MainWebApp
-> CustSecPlugin
-> Spring-Security-Core
So I have a plugin that I wrap around the spring-security plugins to provide extra implementation that is common across a number of web apps. One of the things I do is use a custom UserDetailsService
.
I have follow the guides for this and can get my custom security plugin running in standalone when the beans for the custom user details are defined in grails-app/conf/spring/resources.groovy
This file doesn't get read since its a plugin so I moved the beans into the doWithSpring {}
closure. This still works when ran standalone.
However what I am now finding is that when run with the webapp, my custom details service is ignored, and the Principal is now a standard GrailsUser
If i take my bean definitions and move them into the web-app's grails-app/conf/spring/resources.groovy
then it works. However I don't want to have to define these beans in every app that uses this plugin
I'm not sure what is happening. Why would the userDetailsService()
bean be ignored when its ran as a plugin in a web app? I can see other beans are being set properly (printed out all bean names and made myself a dummy bean). Its almost like its getting set back again.
Is there any where I could define this bean to make it definitely work?
How is the best way to get around this?
Solution
This is probably the load order of the plugins. You can change it in your plugin descriptor with:
def loadAfter = ["springSecurityCore"]
This will enforce that your beans will be loaded after the core plugin.
Answered By - user800014
Answer Checked By - Timothy Miller (JavaFixing Admin)