0

Is it possible to modify and let grails spring-security-core plugin utilize other beans defined in e.g /WEB-INF/applicationContext-security.xml?

Has anyone successfully been able to run for example a minimalistic case of spring-security:

<http>
    <http-basic/>
    <intercept-url pattern="/**" access="ROLE_ADMIN" />
</http>
<authentication-manager>
    <authentication-provider>
        <user-service>
            <user name="admin" password="pass" authorities="ROLE_ADMIN" />
        </user-service>
    </authentication-provider>
</authentication-manager>

Having Grails spring-security-core plugin installed, so that the grails plugin does not redirect it and use its own beans instead?

In that case, where and how do you specify this in order to make this possible?

dunn less
  • 623
  • 10
  • 26

1 Answers1

2

Don't edit /WEB-INF/applicationContext-security.xml - this is the Grails parent application context definition file. If you want to use XML syntax instead of resources.groovy, create a file called resources.xml in the same folder and put the bean definitions there. The format is the same as any Spring XML file.

But you can't mix Spring Security XML bean definitions with the plugin's, since the approach is very different, in particular several bean names are not the same.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
  • I added the applicationContext-security.xml myself and added it to the web.xml. I did not have this in my WEB-INF/ to begin with. So basically i should not bother trying to add new bean definitions even in the resource.xml since it will not play well with the plugin? – dunn less Oct 09 '12 at 14:08
  • Oops, sorry - I misread the file name. You can add additional files in WEB-INF and add them to web.xml, but the standard way in Grails is to do it in resources.xml. But yes - it won't work well in this case if you want to use the plugin too. See http://www.jayway.com/2009/11/23/spring-security-for-real-with-grails/ for a somewhat dated but mostly valid example of configuring Spring Security in XML without the plugin. – Burt Beckwith Oct 09 '12 at 17:03