I am new to Spring Security. I have been working on creating a custom voter that will decide whether to grant permission or not based on the value of an attribute of the object. That is, if object instance A has attribute X with value i, user with ROLE_MGR has access. If object instance B has value j in the X attribute, then ROLE_MGR does not have access. is it possible to do that and if so, what do I need to do? if this is not possible we may decide not to use Spring Security.
Share
I figured it out. I need to use a custom permission evaluator. The snippets from my code are provided below for anyone that might be trying to do something similar:
security.xml
Service Interface
@PostFilter(“hasPermission(filterObject, ‘READ’)”)
public List getAll();
Custom Permissions Evaluator