GithubHelp home page GithubHelp logo

virtualdogbert / enforcer Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 5.0 1.28 MB

The Enforcer Grails plugin, is for enforcing business rules in Grails applications. Also it's an alternative to Spring Security ACL.

License: Apache License 2.0

Groovy 82.75% HTML 14.13% Shell 2.07% Batchfile 1.05%

enforcer's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

enforcer's Issues

For next version make the Ast applicable at the class level

So in the next version I want to make it so that the Enforce transform can be applied to a class, which means it would be applied to each method in the class, but if there is already a method annotation that one would take precedence over the class annotation.

Static type checking and Transactions scope

Hey Tucker,

Recently I noticed one weird bug with Static type checking and Transactional behavior.
Simple code snipped:

@Transactional
class MyService {

    @Enforce({hasRole('ADMIN')})
    void foo() {
        log.info("Hello from foo")
    }

}

Here, Enforce annotation has no Static compilation marker, and thus I assume that Static type checking will not be performed. But in fact, the code can not be compiled:

> Task :compileGroovy FAILED
startup failed:
.../grails-app/services/com/MyService.groovy: 11: [Static type checking] - Cannot find matching method com.MyService#hasRole(java.lang.String). Please check if the declared type is correct and if the method exists.
 @ line 11, column 15.
       @Enforce({hasRole('ADMIN')})
                 ^

1 error

If I replace Enforce annotation by EnforceS, than the output is the following:

> Task :server:compileGroovy FAILED
startup failed:
.../grails-app/services/com/MyService.groovy: 14: [Static type checking] - The variable [log] is undeclared.
 @ line 14, column 9.
           log.info("Hello from foo")
           ^

1 error

The code compiles correctly if I do one of the following:

  1. Replace Enforce by EnforceTS annotation
  2. Add another method marked by EnforceTS annotation
  3. Remove Transactional annotation from the class and from the method

I am not sure that this is correct behavior. Could you please take a look?

Where Closures

For some reason the where closures were causing me nothing but problems, so I swapped them with dynamic finders, but I'm not really happy with that as a solution, because, its pretty unreadable.

The where closure was returning records even when it shouldn't have, in the unit tests.

Not working with new Gorm 6.1 in Grails 3.3

Unable to produce AST for this phase due to earlier compilation error:
startup failed:
script1509283741398.groovy: 34: [Static type checking] - The variable [sp] is undeclared.
@ line 34, column 25.
@Enforce({isCreator(sp)})
^

script1509283741398.groovy: 34: [Static type checking] - Cannot find matching method com.security.TestService#isCreator(java.lang.Object). Please check if the declared type is right and if the method exists.
@ line 34, column 15.
@Enforce({isCreator(sp)})
^

2 errors

Fix the above error(s) and then press Refresh

My feealing after looking at the code, I think that this is the line that is biting me:
https://github.com/grails/grails-data-mapping/blob/master/grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/transform/AbstractMethodDecoratingTransformation.groovy#L225

There is a bug in the domainRole trait

I've already found the issue and fixed it, I just have to commit it up. The issue was how I was looking up the domain role and cheeking that it is in the role hierarchy. So the new code is ๐Ÿ‘

DomainRole domainRole = DomainRole.findByDomainNameAndDomainIdAndUser(domainName, domainObject.id, user)
role in roleHierarchy[domainRole?.role]

2.0 Eliminate use of Holders

So for an upgrade I'm going to bring the enforcer service into the plugin, and change the quick start script to an override, so that I can add the service in the ast, and just add the method call to it directory, rather than using Holders to look it up.

Grails compatibility ?

Documentation only makes it appear this plugin is compatible with grails 3.3.x. (Granted the plugin states def grailsVersion = '3.3.0 > *') I've tested the plugin and it seems to work in grails 4.0.x. Is there anyway you can specify the compatibility of the plugin in the documentation. I am getting some push back regarding this plugin in a project because it doesn't state explicitly compatibility with a non-end-of-life grails version.

Also, could you explain why this repo has a version of 1.3.4 and the latest release is 2.0.1 on the grails plugin website?

Thank you in advance for any clarification or updates you can provide.

Also, as a side note, we have tested in grails 4.0.x but also plan on updating our grails application to 5. So any information you might have in advance on compatibility with Grails 5 would also be beneficial.

Add the idea of creator to Domain objects

Add creator user field to domain object, and use it in the enforcer annotator for changeDomainRole, so that the original creator can add permission for themselves at the time of creation.

Add a check for isCreator to the DomainRoleTrait

Add documentation for creator.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.