This representative example:
There is an admin user A and a normal user B.
A can see and change x,y,z.
B can see x,y (not z) and change x (not y,z) only when z has certain value.
public class U{
private Long id;
private String x;
private String y;
private String z;
[... getter and setter]
}
The question is how to realize this with Spring Data Rest generically. ResourceProcessor only seems to be applicable for links and a Validator can't see if an user has changed a field...
I have implemented an Attribute-Based Access Control, so I can create and save roles, permissions and policies(using SpEl), which determine who can see and change a specific field, in database easily.
Update 1
I've added a Jackson BeanSerializerModifier to filter attributes, but there is the problem that I don't know the original (database) value of z and can't check if B has permission to change x.
Update 2
I've added a custom Jackson Std(De)Serializer, but now I can't use it for every entity dynamically, because I had to write the complete (de)serialzer for each entity.
Update 3
After two weeks with many unsuccessful attempts to solve this problem, I am going to try to integrate filters into SDR.
Update 4
While I added a filter for PUT and PATCH requests I relized that https://jira.spring.io/browse/DATAREST-373 and https://jira.spring.io/browse/DATAREST-428 would be better solutions. Now I'm going to find solutions for them.