Note that there are some explanatory texts on larger screens.

plurals
  1. POGrails filters or acl
    primarykey
    data
    text
    <p>I'm planning to create a customer private area on a web site written in Groovy/Grails where each customer can login and view it's own data, edit it, and so forth.</p> <p>Reviewing the mechanisms available that come with Grails, I've seen two of them that seem to be suitable: 1) <strong>filters</strong> 2) <strong>spring-security-acl</strong></p> <p>I've worked through the acl tutorial and I find the acl plugin VERY fine grain. I'm not sure whether I really need that high degree of being able to grant rights. In the end, all I need is to restrict each user to only see/edit his own data which is spread over about 20 tables (all normaized, some of them with compound keys, all of them represented by domain classes). As far as I can see it, I will be fine with filters. Am I seeing this right? Is there any example for this on the web? (I mean, an application secured by filters).</p> <p>As I understand reading the docs, I should in any way work also with Services, not only with controllers in order to be able to fine grain control what's happening, whether I user 1) or 2). Also right?</p> <p>TIA &amp; thanks for your patience with these beginner questions</p> <p>Michael</p> <p>Edit: I've modified the list() method within my Contract Controller and added a criteria, asking your opinion about it. I think it will pretty much do the job. Of course I also have to work on all the other methods, like create(), save(), etc. and add that criteria there, too. Otherwise I will be able to e.g. edit ANY contract. (The user class has a reference to the client class.)</p> <pre><code>def list(Integer max) { def user = springSecurityService.getCurrentUser() params.max = Math.min(max ?: 10, 100) def c = Contract.createCriteria() def isAdmin = org.codehaus.groovy.grails.plugins.springsecurity.SpringSecurityUtils.ifAllGranted('ROLE_ADMIN') def results = c.list (params) { if (!isAdmin) { eq("client", user.client) } } [contractInstanceList: results, contractInstanceTotal: results.getTotalCount()] } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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