Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/private/Settings/DeclarativeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ public function getFormsWithValues(IUser $user, ?string $type, ?string $section)
if ($section !== null && $schema['section_id'] !== $section) {
continue;
}
// If listing all fields skip the admin fields which a non-admin user has no access to
if ($type === null && $schema['section_type'] === 'admin' && !$isAdmin) {
// Skip admin declarative forms for non-admin users. They have no access to
// these fields even when they are allowed to view the section through admin
// delegation, which only covers non-declarative settings.
if ($schema['section_type'] === DeclarativeSettingsTypes::SECTION_TYPE_ADMIN && !$isAdmin) {
continue;
}

Expand Down
9 changes: 8 additions & 1 deletion tests/lib/Settings/DeclarativeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,15 @@ public function testAdminFormUserUnauthorized(): void {
$schema = self::validSchemaAllFields;
$this->declarativeManager->registerSchema($app, $schema);

// A non-admin user must not receive admin declarative forms, but this must not
// throw: it would abort rendering of a section a user can legitimately access
// through admin delegation (which only covers non-declarative settings).
$forms = $this->declarativeManager->getFormsWithValues($this->user, $schema['section_type'], $schema['section_id']);
$this->assertEmpty($forms);

// Writing to an admin declarative form is still forbidden for a non-admin user.
$this->expectException(\Exception::class);
$this->declarativeManager->getFormsWithValues($this->user, $schema['section_type'], $schema['section_id']);
$this->declarativeManager->setValue($this->user, $app, $schema['id'], 'some_real_setting', '120m');
}

/**
Expand Down
Loading