Note that there are some explanatory texts on larger screens.

plurals
  1. POApplying Spring Security to a plugin
    primarykey
    data
    text
    <p>I'm developing a plugin to provide some specific functionality. The plugin "has it all": the complete vertical slice (services, controllers, domain-classes, GSPs). On the plugin level no security is used.</p> <p>Now I want to integrate the plugin into the main app, and apply some security rules like <code>@Secured(['ROLE_SUPER'])</code>. </p> <p>The way I'm doing it now is not too elegant:</p> <pre><code>@Secured(['ROLE_SUPER']) class SomeController extends SomePluginController {} </code></pre> <p>This mass of such zero-value code grows along with the number of controllers.</p> <p>What can be improved here?</p> <p>TIA</p> <p>UPDATE: the <code>grails.plugin.springsecurity.controllerAnnotations.staticRules</code> map doesn't work.</p> <p>I have a plugin AggregationPlugin with TaskController and index-action inside.</p> <p>I tried to put it so:</p> <pre><code> grails.plugin.springsecurity.controllerAnnotations.staticRules = [ '/task/**': ['ROLE_SUPER'], '/aggregation/**': ['ROLE_SUPER'], '/plugins/aggregation-0.1/**': ['ROLE_SUPER'], ] </code></pre> <p>but I still can access the page anonymously. </p> <p>I'm using <code>Grails 1.3.7</code> and <code>spring-security-core 1.2.7.2</code></p> <p>UPDATE #2:</p> <p>So, after some attempts I found the most elegant solution. Instead of staticRules which doesn't work for some reason in my setup and which can become really big, if you have many plugins to apply security to, I added a dependency to the plugin:</p> <pre><code>compile( 'org.springframework.security:spring-security-core:3.0.7.RELEASE' ) </code></pre> <p>so that I can use the <code>@Secured</code> in my controllers now without the whole security plugin. Upon installation into the main app they will be picked automatically by the security plugin.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload