This use case cannot be performed using the default role-based access control (RBAC) function, because user permissions change dynamically at run time depending on some user-related data.
This is actually a use case for which access control lists ( ACLs ) are intended.
Spring Security has ACL support by adding spring -acl jar. This is a quote from the spring section for Acl security:
In complex applications, it is often necessary to determine access rights not just during a web request or method call level. Instead, security solutions should contain both those who (Authentication), where (MethodInvocation) and what (SomeDomainObject). In other words, authorization decisions must also take into account the actual object instance of the object object of the method call.
See Spring Security Guide in Section 16.1 for details on how spring security ACLs work. This is a tutorial on how to use spring security ACLs.
But spring ACLs mean 4 additional database tables, etc., so if this is one case in your application, it is probably best to create a custom decision manager with some coded rules.
But if this use case is often used in your application, you should consider switching to ACL instead of RBAC, hope this helps.
Angular university
source share