Reputation: 887
How can i have dynamic role from database for a user in @PreAuthorize("hasRole('ROLE_ADMIN')") or ?
I want ROLE_ADMIN to be dynamic instead of static or hard code.
Upvotes: 0
Views: 713
Reputation: 33
Maybe you want to store the different ROLES in a Properties file and get them in the code, like:
@PreAuthorize("hasRole(" + PropertyManager.getProperty("role.admin") + "')" + '"')
Or when you configure the GRANT permissions to the different users you are possibility to select different columns for each role. So in the Controller of the app redirect to the specific method
Upvotes: 1