Grails and JSecurity Tags
As I'm making progress with my software project, I keep learning things about JSecurity. It's a great library, but the available documentation is incomplete at some points.
Today I polished the user interface a bit. This includes hiding navigational links to pages the current user is not authorized to use. The JSecurity plugin for grails offers a few very handy tags however they are not documented very well. The quick summary of tags gets you an idea what is possible but not how.
The tags of interest are hasRole, lacksRole, hasPermission and lacksPermission. The documentation says that its content will only displayed if the authenticated user has the appropriate Role or Permission. How to specify such a role or permission is not stated. So i tried various attributes, e.g. role or roleName but no one worked. So I had a look at the source code and voilá, it's so simple: the attribute is name. Example:
<jsec:hasRole name="Administrators">
<!-- Show some admin stuff -->
</jsec:hasRole>
The same applies to the other tags lacksRole, hasPermission and lacksPermission.
This information seems trivial when you know it, but can cost you quite a few minutes if not. Hopefully i could save you a few minutes.
