13
I’m using the spring-security
to authenticate my user, until then beauty, now I want to be able to exchange the user’s role for managed bean
, someone has an idea?
Type I have several modules and each user has a role for each module so when he click on the module I want to get the session user to see in the database which is the role of it and then direct to the module.
In other words, I have a screen where the user logs into the system and appears the modules he has access to but I did not load his permissions in each module when I click on the module I want to go to the bank and pick up the scroll that has access to this module, below the screen example:
you will see that I have a login with the role_root role and when he clicks on the SAR he has to have the role_user.
Paul, I don’t understand one thing. You want to change the role dynamically, that is, adding new roles to a logged-in user? Or would it be only a matter of checking if the user is allowed to access the XPTO resource?
– utluiz
This add new roles, because a user who has role_admin in one model sometimes he is role_user in another
– paulohddias
Paulo, that’s not how Spring works. In this case, you should use independent roles. Example:
role_admin_feature_1
androle_admin_feature_2
.– utluiz
I edited it to see if it’s clearer
– paulohddias
Okay, in that case you should do more or less what I did in mine another issue on Spring Security, this is, replace the decision-making mechanism with a logic entirely of its own. In this case, you do not need to inject the roles into Sprign Security, just load the database data and run the logic based on the area of the system being accessed by the user. In this implementation it is possible to access session and request data.
– utluiz
I’ll take a look thank you
– paulohddias
An alternative would be you create a list of strings with all the roles that the user has, and your entire system would run 'reading' if your list contains the required scroll, this would work for all system permissions, and if you wanted, you could increment your list at runtime by inserting or removing new permissions. If you are using spring it is very simple to use this functionality by changing the authentication and or athorization. You think that would suit your need?
– Michel Simões