-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix default profile assignment for user who lost all rights because no matched with authorization rules #21594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1417,6 +1417,25 @@ public function applyRightRules() | |
| $right->delete($db_profile); | ||
| } | ||
| } | ||
|
|
||
| // Check if user has any profile left after deletion, if not add default profile | ||
| $remaining_profiles = Profile_User::getForUser($this->fields["id"], false); | ||
| if (count($remaining_profiles) == 0) { | ||
| $default_profile = Profile::getDefault(); | ||
| if ($default_profile > 0) { | ||
| $affectation = [ | ||
| 'entities_id' => 0, // Root entity | ||
| 'profiles_id' => $default_profile, | ||
| 'is_recursive' => 1, | ||
|
Comment on lines
+1427
to
+1429
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we sure we want the user to have access to all entities? If there is not match with autorizarion rules, should we take the risk adding some default authorization? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. Basically, a user has rights by default, so it seemed logical to me to give them back their default rights when they no longer have any other rights. Because a user without rights is weird, isn't it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a security point of view, it's probably better to get an user without rights than an user with inappropriate ones. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what I am thinking too. You don't want to update GLPI and then notice out of nowhere that some users have new profiles, it might be a critical issue if people don't expect it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. The current behavior seems to be the correct one. If all authorization assignments are dynamic (applied by rules) and a user no longer matches those rules, we shouldn't force any authorizations on the user. It is up to the GLPI admin to define a default rule, or use the one that already existed, if they want that kind of behavior. There is also the case where a user is deleted in LDAP where an admin may have chosen to handle it by withdrawing authorizations but keeping the user out of the trash. If an authorization is forced, this goes against the admin's choice. |
||
| 'users_id' => $this->fields['id'], | ||
| 'is_dynamic' => 1, | ||
| 'is_default_profile' => 1, | ||
| ]; | ||
| $right = new Profile_User(); | ||
| $right->add($affectation); | ||
| } | ||
| } | ||
|
|
||
| $this->must_process_ruleright = false; | ||
| } | ||
| return $return; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.