Skip to content
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

feat(users): Add users and group management to admin delegation #46418

Merged
merged 6 commits into from
Jul 24, 2024

Conversation

artonge
Copy link
Contributor

@artonge artonge commented Jul 10, 2024

Done

  • Fix some error handling in the front end
  • Create a IDelegatedSettings for users management
  • Show the 'Accounts' menu to delegated admins
  • Add the AuthorizedAdminSetting annotation to endpoints that are admin restricted
  • Tweak the inner permissions conditions in endpoints that are not admin restricted
  • Hide the 'Admins' section to delegated admins

I suspect the most critical part is to not let delegated admins escalate privileges to full admins. I tried to ensure that this is not possible. So a delegated admin cannot:

  • Create a user with admin rights
  • Delete, edit, wipe devices, disable an admin
  • Add a user to the admin group
  • Remove an admin from the admin group

But a delegated admin can:

  • Escalate admin settings delegation by adding himself to a group

But I might have missed a scenario.

@artonge artonge marked this pull request as draft July 10, 2024 15:56
@artonge artonge self-assigned this Jul 10, 2024
@artonge artonge added enhancement 2. developing Work in progress php Pull requests that update Php code labels Jul 10, 2024
@artonge artonge added this to the Nextcloud 30 milestone Jul 10, 2024
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
*/
public function getForm(): TemplateResponse {

return new /** @template-extends TemplateResponse<Http::STATUS_OK, array{}> */ class($this->appName, '') extends TemplateResponse {

Check failure

Code scanning / Psalm

InvalidTemplateParam Error

Extended template param S expects type int, type OCA\Provisioning_API\Settings\Admin\Http::STATUS_OK given
@@ -1300,7 +1318,10 @@

// If not permitted
$subAdminManager = $this->groupManager->getSubAdmin();
if (!$this->groupManager->isAdmin($currentLoggedInUser->getUID()) && !$subAdminManager->isUserAccessible($currentLoggedInUser, $targetUser)) {
$isAdmin = $this->groupManager->isAdmin($currentLoggedInUser->getUID()) || $this->groupManager->isDelegatedAdmin($currentLoggedInUser->getUID());

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method getUID on possibly null value
@@ -1329,7 +1350,8 @@
throw new OCSException('', OCSController::RESPOND_NOT_FOUND);
}

if ($targetUser->getUID() === $loggedInUser->getUID() || $this->groupManager->isAdmin($loggedInUser->getUID())) {
$isAdmin = $this->groupManager->isAdmin($loggedInUser->getUID()) || $this->groupManager->isDelegatedAdmin($loggedInUser->getUID());

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method getUID on possibly null value
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
@@ -1574,9 +1613,10 @@

// Check if admin / subadmin
$subAdminManager = $this->groupManager->getSubAdmin();
$isAdmin = $this->groupManager->isAdmin($currentLoggedInUser->getUID()) || $this->groupManager->isDelegatedAdmin($currentLoggedInUser->getUID());

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method getUID on possibly null value
@artonge artonge force-pushed the artonge/feat/user_admin_delegation branch from 2e9f01d to c255339 Compare July 11, 2024 10:11
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
apps/provisioning_api/lib/Controller/UsersController.php Dismissed Show dismissed Hide dismissed
@artonge artonge force-pushed the artonge/feat/user_admin_delegation branch from c255339 to 752f90c Compare July 11, 2024 10:22
@artonge artonge marked this pull request as ready for review July 11, 2024 10:25
@artonge artonge added 3. to review Waiting for reviews javascript and removed 2. developing Work in progress labels Jul 11, 2024
@artonge artonge force-pushed the artonge/feat/user_admin_delegation branch 5 times, most recently from 78d9bf1 to c710545 Compare July 16, 2024 13:35
@artonge artonge changed the title feat(users): Add users and group management to admin delegation - WIP feat(users): Add users and group management to admin delegation Jul 17, 2024
@artonge artonge force-pushed the artonge/feat/user_admin_delegation branch from e62a668 to 1c5d27c Compare July 17, 2024 10:27
@sorbaugh sorbaugh requested a review from Altahrim July 17, 2024 12:55
@artonge artonge force-pushed the artonge/feat/user_admin_delegation branch from 2a6824f to 544bfd4 Compare July 22, 2024 11:17
@artonge artonge requested review from blizzz and Pytal and removed request for miaulalala and tcitworld July 22, 2024 11:18
@artonge artonge force-pushed the artonge/feat/user_admin_delegation branch from 544bfd4 to a2b98a7 Compare July 22, 2024 13:42
@artonge artonge force-pushed the artonge/feat/user_admin_delegation branch 3 times, most recently from 28c2575 to fb37346 Compare July 22, 2024 14:18
Signed-off-by: Louis Chemineau <louis@chmn.me>
…nagement

Signed-off-by: Louis Chemineau <louis@chmn.me>
@artonge artonge force-pushed the artonge/feat/user_admin_delegation branch 3 times, most recently from 4371d2e to 15e73b4 Compare July 22, 2024 16:08
Signed-off-by: Louis Chemineau <louis@chmn.me>
Signed-off-by: Louis Chemineau <louis@chmn.me>
Signed-off-by: Louis Chemineau <louis@chmn.me>
Signed-off-by: Louis Chemineau <louis@chmn.me>
@artonge artonge merged commit 7266a9e into master Jul 24, 2024
167 checks passed
@artonge artonge deleted the artonge/feat/user_admin_delegation branch July 24, 2024 09:15
@artonge artonge removed the pending documentation This pull request needs an associated documentation update label Jul 24, 2024
@blizzz blizzz mentioned this pull request Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants