From 5dfa5e28da54b1f64ffbf909fceb2c4dde7ff284 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 9 Mar 2021 11:27:13 +0100 Subject: [PATCH] User: Add property `$unrestricted` --- .../Icinga/Authentication/AdmissionLoader.php | 1 + library/Icinga/User.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/library/Icinga/Authentication/AdmissionLoader.php b/library/Icinga/Authentication/AdmissionLoader.php index 6d755992b..c1f8af64a 100644 --- a/library/Icinga/Authentication/AdmissionLoader.php +++ b/library/Icinga/Authentication/AdmissionLoader.php @@ -206,6 +206,7 @@ class AdmissionLoader } } + $user->setIsUnrestricted($isUnrestricted); $user->setRestrictions($isUnrestricted ? [] : $restrictions); $user->setPermissions($permissions); $user->setRoles(array_values($roles)); diff --git a/library/Icinga/User.php b/library/Icinga/User.php index 491f29660..529018f64 100644 --- a/library/Icinga/User.php +++ b/library/Icinga/User.php @@ -73,6 +73,13 @@ class User */ protected $externalUserInformation = array(); + /** + * Whether restrictions should not apply to this user + * + * @var bool + */ + protected $unrestricted = false; + /** * Set of permissions * @@ -202,6 +209,30 @@ class User return in_array($group, $this->groups); } + /** + * Get whether restrictions should not apply to this user + * + * @return bool + */ + public function isUnrestricted() + { + return $this->unrestricted; + } + + /** + * Set whether restrictions should not apply to this user + * + * @param bool $state + * + * @return $this + */ + public function setIsUnrestricted($state) + { + $this->unrestricted = (bool) $state; + + return $this; + } + /** * Get the user's permissions *