ABAC using spring security

Recently I’ve been investigated the ways I can use spring-security to clean up the authorization code in one of our applications. Currently the access control code is spread out all over the code base. And it’s a mess.

What I’m trying to do is to to annotate the service methods with spring-security’s @PreAuthorize or @PostAuthorize methods, and delegate the access control decisions to “something”. The idea is to ask that “something” a generic question like “Can the current user READ object X?” Only 4 questions would be asked, one for each CRUD operation.

A first idea was to use an ACL model. In this approach, each object would have an ACL and each user would have a list of granted authorities. If one of the user’s granted authorities matches an item in the objects’ ACL, access would be granted. One downside of this approach is that the ACL can get long (depending on how you implement it). Another is that it can become unclear what the access rules actually are.

ABAC seemed like a candidate to fix these problems.

The wikipedia article on ABAC give a concise overview on the different components which are typically needed (e.g. PEP, PDP and PIP):

https://en.wikipedia.org/wiki/Attribute-based_access_control

The following video describes a framework (by Axiomatics), which integrates with spring-security, for doing ABAC:

https://www.youtube.com/watch?v=TZECXS1tlGk

Unfortunately the framework and the spring-security integration is not open-source (or free).

Axiomatics wrote a short article on ABAC, which indicates how the attributes are used to specify richer access control policies:

https://www.axiomatics.com/attribute-based-access-control/

Axiomatics has a lot of other articles and presentations on this topic.

Written on July 24, 2017