You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shiro.apache.org by "Maria Jurcovicova (JIRA)" <ji...@apache.org> on 2011/07/20 23:19:58 UTC

[jira] [Created] (SHIRO-314) Authorization ANTLR Grammar

Authorization ANTLR Grammar
---------------------------

                 Key: SHIRO-314
                 URL: https://issues.apache.org/jira/browse/SHIRO-314
             Project: Shiro
          Issue Type: New Feature
          Components: Authorization (access control) 
            Reporter: Maria Jurcovicova


Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 

Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13082676#comment-13082676 ] 

Les Hazlewood commented on SHIRO-314:
-------------------------------------

Hi Maria,

I personally haven't had the time to try it just yet, but don't worry - I will.  I'm excited to see this come to fruition.  I'll have to do it when I can step aside from work for a minute.  Thanks!

> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar, securedAnnotationAuthorizingExpressionLanguage.patch
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Maria Jurcovicova (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13068654#comment-13068654 ] 

Maria Jurcovicova commented on SHIRO-314:
-----------------------------------------

I started with a grammar and would like to get some feedback on it. Demo proof-of-concept parser is in the GrammarDemoProofOfConcept.rar attachment.

The grammar has four operators:
*  and &&
*  or  ||
*  not  !
*  parenthesis ( )

and two build-in functions:
* role,
* permission.

Example:
  @Secured("permission('account:1 0:test') && (permission('print paper') || !role('role'))")

--------------- Escaping: 
Theoretically, the symbol ' might be used in role or permission name. To escape it, use /.
Example:
  @Secured("permission('some role with /' symbol')") 
  @Secured("role('some role with // symbol')") 
 
The symbol \ is more standard, but that one has to be escaped in java. E.g. the user would have to write 
  role('name with \\' in it')) instead of role('name with /' in it')) to get "name with ' in it"
  role('name with \\\\ in it')) instead of role('name with // in it')) to get "name with \ in it" or "name with / in it"

--------------- Shortcut 1: 
As expressions might get too long, both role and permission functions takes n parameters:
* role(role_1, role_2,  ..., role_n),
* permission(permission_1, permission_2, ..., permission_n).

Role function returns true if currently logged user has all specified roles. Permission function returns true if currently logged user has all specified permissions.

Example:
  @Secured("role('traveling sales', 'employee')") 
  is equivalent to 
  @Secured("role('traveling sales') && role('employee')") 
  
  @Secured("permission('account:1', 'print')") 
  is equivalent to 
  @Secured("permission('account:1') && permission('print')") 

--------------- Shortcut 2: 
I assume that roles are used more often. If neither role nor permission function is specified, role is assumed.

Example:
  @Secured("'traveling sales' && 'employee' || 'some role')") 
  is equivalent to 
  @Secured("role('traveling sales') && role('employee') || role('some role')") 


> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>         Attachments: GrammarDemoProofOfConcept.rar
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Maria Jurcovicova (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069807#comment-13069807 ] 

Maria Jurcovicova commented on SHIRO-314:
-----------------------------------------

Hi Les, 
it is not a patch yet, only grammar proposal and demo parser (demonstration that grammar works as it should). I need more time to create a full patch. For now, I assume that there are no objections to my grammar. 

Sorry for the rar format, could not install anything new the computer I am using now :(.

> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Maria Jurcovicova (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13082203#comment-13082203 ] 

Maria Jurcovicova commented on SHIRO-314:
-----------------------------------------

Hi,

I just wanted to ask, whether you had time to try the patch. Was there a problem with it? 


> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar, securedAnnotationAuthorizingExpressionLanguage.patch
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Maria Jurcovicova (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maria Jurcovicova updated SHIRO-314:
------------------------------------

    Attachment: GrammarDemoProofOfConcept.rar

Demo proof-of-concept parser.

> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>         Attachments: GrammarDemoProofOfConcept.rar
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "DIALLO Mamadou BObo (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13188107#comment-13188107 ] 

DIALLO Mamadou BObo commented on SHIRO-314:
-------------------------------------------

I think that having an annotation processor is not a bad idea as much of the time the users won't have to worry about it.
This being said i think we got something here:

This implementation fit better if say we don't want a dependency on spring for some hypothetical reason and it is a simple but effective way.
                
> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar, securedAnnotationAuthorizingExpressionLanguage.patch
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Assigned] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Les Hazlewood reassigned SHIRO-314:
-----------------------------------

    Assignee: Les Hazlewood

> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Les Hazlewood (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13188080#comment-13188080 ] 

Les Hazlewood commented on SHIRO-314:
-------------------------------------

Yes, I think parameter references will be pretty much required.  As I understand it though, this will only work if DEBUG is enabled at compilation time, as method parameter names are only available as debug symbols.
                
> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar, securedAnnotationAuthorizingExpressionLanguage.patch
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Jared Bunting (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13188072#comment-13188072 ] 

Jared Bunting commented on SHIRO-314:
-------------------------------------

It would be really nice to be able to include references to parameters passed into the secured methods.  Thoughts?  I'm writing some similar stuff right now so if others think this seems like a good idea, I should be able to apply that knowledge.
                
> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar, securedAnnotationAuthorizingExpressionLanguage.patch
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Jared Bunting (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13188085#comment-13188085 ] 

Jared Bunting commented on SHIRO-314:
-------------------------------------

The solution that I'm looking at right now involves using an AnnotationProcessor to save off the parameter names at compile time.  This also allows us to do compile-time checking of the expression.  

I'm still evaluating if this is too much hocus-pocus, but right now I'm feeling good about it.
                
> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar, securedAnnotationAuthorizingExpressionLanguage.patch
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069643#comment-13069643 ] 

Les Hazlewood commented on SHIRO-314:
-------------------------------------

er - .rar

> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Les Hazlewood (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13069642#comment-13069642 ] 

Les Hazlewood commented on SHIRO-314:
-------------------------------------

Maria this is one of the biggest features I think for an upcoming release.  This is fantastic stuff!  Thanks so much for the patch - I'll let you know if I have any issues applying the patch.

> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (SHIRO-314) Authorization ANTLR Grammar

Posted by "Maria Jurcovicova (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SHIRO-314?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Maria Jurcovicova updated SHIRO-314:
------------------------------------

    Attachment: securedAnnotationAuthorizingExpressionLanguage.patch

Patch solves the issue. It changes two sub-projects shiro-aspectj and shiro-core. 

shiro-aspectj:
* changed pointcut to catch new @Secured annotation,
* added unit test for @Secured annotation.

shiro-core:
* added authorizing expression grammar file (/shiro-core/src/main/antlr3/org/apache/shiro/expressions/parser/AuthorizingExpressions.g),
* added ANTLR dependency and plugins to pom.xml,
* added @Secured annotation, its interceptor and handler,
* added authorization expression language parser and interpreter (org.apache.shiro.expressions package),
* added unit tests for parser and interpreter.

Authorization expression language is described in @Secured annotation javadoc.

> Authorization ANTLR Grammar
> ---------------------------
>
>                 Key: SHIRO-314
>                 URL: https://issues.apache.org/jira/browse/SHIRO-314
>             Project: Shiro
>          Issue Type: New Feature
>          Components: Authorization (access control) 
>            Reporter: Maria Jurcovicova
>            Assignee: Les Hazlewood
>         Attachments: GrammarDemoProofOfConcept.rar, securedAnnotationAuthorizingExpressionLanguage.patch
>
>
> Create a single annotation that would translate the expression into the relevant hasRole/isPermitted calls. 
> Details are on wiki https://cwiki.apache.org/confluence/display/SHIRO/Version+2+Brainstorming#Version2Brainstorming-AuthorizationANTLRGrammar . 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira