Jakob Külzer Ninja Coding Monkey goes Canada

14Aug/081

Grails and Logging: “No such property”

Today I am working on my software project again (after a big pile of paperwork - yuck!). Grails uses log4j as logging system which is IMHO quite a good choice. Configuration is done via the Config.groovy located in the grails-app/conf directory of a Grails application. There you add entries to the log4j block which sounds pretty easy at first, but there is a pitfall with this block.

Filed under: Grails Continue reading
8Aug/080

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. :-)

Filed under: Grails No Comments
5Aug/089

Custom Authentication Schemes with Grails and JSecurity

In my current software project a requirement is an authentication scheme consisting not of the usual user name an password, but user name, password and a store number. Each user name should be unique in for a store but could occur multiple times for all stores.

For several reasons I decided to implement authentication with JSecurity. The Grails plugin is a great help and the quickstart brings you up to speed pretty fast.

As the JSecurity documentation is pretty scarce on the topic of custom authentication schemes, I'm posting my findings here in my blog. Perhaps it is useful to other developers as well (actually i would love to see some comments on this :-) .