Hi Folks,
We are integrating Spring Security into a new application and have implemented permission-based authorisation at the service layer. We are not using Roles or ACLs, but instead provide our own PermissionEvaluator implementation to do permission checking with the hasPermission() expression in pre- and postAuthorize annotations.
This is working well for us, with one slight ugliness: the hasPermission() expression forces the passing of a domain object reference (or id and type). In some cases, we just want to check if the current authentication has a specific permission. We don't want to consider any domain object (there may not even be a relevant domain object).
In other words, we'd like the hasPermission() expression to have a third valid form that just takes the required permission:
This would result in a callback to a new method on PermissionEvaluator interface:Code:@PreAuthorize("hasPermission('CREATE_FOO')") public void createFoo(String name, String description) { ... }
At the moment, we are working around this by passing null:Code:hasPermission(Authentication authentication, Object requestedPermission);
which is ugly.Code:@PreAuthorize("hasPermission(null, 'CREATE_FOO')") public void createFoo(String name, String description) { ... }
Please let me know what you think of this, or if there is another way that I've missed in overcoming this problem.
Cheers,
-Brendan


Reply With Quote
