Pritesh Shah
Pritesh Shah

Reputation: 887

Dynamic Role from database to show content to user based on their role

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

Answers (1)

Elorry
Elorry

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

Related Questions