Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
use OC\AppConfig;
use OC\AppFramework\Middleware\Security\Exceptions\NotAdminException;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\IAppConfig;
Expand Down Expand Up @@ -93,9 +95,7 @@ public function getValue(string $app, string $key, string $defaultValue = ''): D
}

/**
* @PasswordConfirmationRequired
* @NoSubAdminRequired
* @NoAdminRequired
*
* Update the config value of an app
*
Expand All @@ -107,6 +107,8 @@ public function getValue(string $app, string $key, string $defaultValue = ''): D
* 200: Value updated successfully
* 403: App or key is not allowed
*/
#[PasswordConfirmationRequired]
#[NoAdminRequired]
public function setValue(string $app, string $key, string $value): DataResponse {
$user = $this->userSession->getUser();
if ($user === null) {
Expand All @@ -130,8 +132,6 @@ public function setValue(string $app, string $key, string $value): DataResponse
}

/**
* @PasswordConfirmationRequired
*
* Delete a config key of an app
*
* @param string $app ID of the app
Expand All @@ -141,6 +141,7 @@ public function setValue(string $app, string $key, string $value): DataResponse
* 200: Key deleted successfully
* 403: App or key is not allowed
*/
#[PasswordConfirmationRequired]
public function deleteKey(string $app, string $key): DataResponse {
try {
$this->verifyAppId($app);
Expand Down
7 changes: 3 additions & 4 deletions apps/provisioning_api/lib/Controller/AppsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCSController;
Expand Down Expand Up @@ -84,8 +85,6 @@ public function getAppInfo(string $app): DataResponse {
}

/**
* @PasswordConfirmationRequired
*
* Enable an app
*
* @param string $app ID of the app
Expand All @@ -94,6 +93,7 @@ public function getAppInfo(string $app): DataResponse {
*
* 200: App enabled successfully
*/
#[PasswordConfirmationRequired]
public function enable(string $app): DataResponse {
try {
$this->appManager->enableApp($app);
Expand All @@ -104,15 +104,14 @@ public function enable(string $app): DataResponse {
}

/**
* @PasswordConfirmationRequired
*
* Disable an app
*
* @param string $app ID of the app
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
*
* 200: App disabled successfully
*/
#[PasswordConfirmationRequired]
public function disable(string $app): DataResponse {
$this->appManager->disableApp($app);
return new DataResponse();
Expand Down
29 changes: 12 additions & 17 deletions apps/provisioning_api/lib/Controller/GroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
namespace OCA\Provisioning_API\Controller;

use OCA\Provisioning_API\ResponseDefinitions;
use OCA\Settings\Settings\Admin\Sharing;
use OCA\Settings\Settings\Admin\Users;
use OCP\Accounts\IAccountManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCS\OCSForbiddenException;
Expand Down Expand Up @@ -60,8 +63,6 @@ public function __construct(string $appName,
}

/**
* @NoAdminRequired
*
* Get a list of groups
*
* @param string $search Text to search for
Expand All @@ -71,6 +72,7 @@ public function __construct(string $appName,
*
* 200: Groups returned
*/
#[NoAdminRequired]
public function getGroups(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function ($group) {
Expand All @@ -82,9 +84,6 @@ public function getGroups(string $search = '', ?int $limit = null, int $offset =
}

/**
* @NoAdminRequired
* @AuthorizedAdminSetting(settings=OCA\Settings\Settings\Admin\Sharing)
*
* Get a list of groups details
*
* @param string $search Text to search for
Expand All @@ -94,6 +93,8 @@ public function getGroups(string $search = '', ?int $limit = null, int $offset =
*
* 200: Groups details returned
*/
#[NoAdminRequired]
#[AuthorizedAdminSetting(settings: Sharing::class)]
public function getGroupsDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$groups = $this->groupManager->search($search, $limit, $offset);
$groups = array_map(function ($group) {
Expand All @@ -112,8 +113,6 @@ public function getGroupsDetails(string $search = '', ?int $limit = null, int $o
}

/**
* @NoAdminRequired
*
* Get a list of users in the specified group
*
* @param string $groupId ID of the group
Expand All @@ -124,13 +123,12 @@ public function getGroupsDetails(string $search = '', ?int $limit = null, int $o
*
* 200: Group users returned
*/
#[NoAdminRequired]
public function getGroup(string $groupId): DataResponse {
return $this->getGroupUsers($groupId);
}

/**
* @NoAdminRequired
*
* Get a list of users in the specified group
*
* @param string $groupId ID of the group
Expand All @@ -141,6 +139,7 @@ public function getGroup(string $groupId): DataResponse {
*
* 200: User IDs returned
*/
#[NoAdminRequired]
public function getGroupUsers(string $groupId): DataResponse {
$groupId = urldecode($groupId);

Expand Down Expand Up @@ -173,8 +172,6 @@ public function getGroupUsers(string $groupId): DataResponse {
}

/**
* @NoAdminRequired
*
* Get a list of users details in the specified group
*
* @param string $groupId ID of the group
Expand All @@ -187,6 +184,7 @@ public function getGroupUsers(string $groupId): DataResponse {
*
* 200: Group users details returned
*/
#[NoAdminRequired]
public function getGroupUsersDetails(string $groupId, string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
$groupId = urldecode($groupId);
$currentUser = $this->userSession->getUser();
Expand Down Expand Up @@ -231,8 +229,6 @@ public function getGroupUsersDetails(string $groupId, string $search = '', ?int
}

/**
* @PasswordConfirmationRequired
*
* Create a new group
*
* @param string $groupid ID of the group
Expand All @@ -243,6 +239,7 @@ public function getGroupUsersDetails(string $groupId, string $search = '', ?int
* 200: Group created successfully
*/
#[AuthorizedAdminSetting(settings:Users::class)]
#[PasswordConfirmationRequired]
public function addGroup(string $groupid, string $displayname = ''): DataResponse {
// Validate name
if (empty($groupid)) {
Expand All @@ -264,8 +261,6 @@ public function addGroup(string $groupid, string $displayname = ''): DataRespons
}

/**
* @PasswordConfirmationRequired
*
* Update a group
*
* @param string $groupId ID of the group
Expand All @@ -277,6 +272,7 @@ public function addGroup(string $groupid, string $displayname = ''): DataRespons
* 200: Group updated successfully
*/
#[AuthorizedAdminSetting(settings:Users::class)]
#[PasswordConfirmationRequired]
public function updateGroup(string $groupId, string $key, string $value): DataResponse {
$groupId = urldecode($groupId);

Expand All @@ -296,8 +292,6 @@ public function updateGroup(string $groupId, string $key, string $value): DataRe
}

/**
* @PasswordConfirmationRequired
*
* Delete a group
*
* @param string $groupId ID of the group
Expand All @@ -307,6 +301,7 @@ public function updateGroup(string $groupId, string $key, string $value): DataRe
* 200: Group deleted successfully
*/
#[AuthorizedAdminSetting(settings:Users::class)]
#[PasswordConfirmationRequired]
public function deleteGroup(string $groupId): DataResponse {
$groupId = urldecode($groupId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OCA\Provisioning_API\Controller;

use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
use OCP\Config\BeforePreferenceDeletedEvent;
Expand Down Expand Up @@ -39,7 +40,6 @@ public function __construct(
}

/**
* @NoAdminRequired
* @NoSubAdminRequired
*
* Update multiple preference values of an app
Expand All @@ -52,6 +52,7 @@ public function __construct(
* 200: Preferences updated successfully
* 400: Preference invalid
*/
#[NoAdminRequired]
public function setMultiplePreferences(string $appId, array $configs): DataResponse {
$userId = $this->userSession->getUser()->getUID();

Expand Down Expand Up @@ -84,7 +85,6 @@ public function setMultiplePreferences(string $appId, array $configs): DataRespo
}

/**
* @NoAdminRequired
* @NoSubAdminRequired
*
* Update a preference value of an app
Expand All @@ -97,6 +97,7 @@ public function setMultiplePreferences(string $appId, array $configs): DataRespo
* 200: Preference updated successfully
* 400: Preference invalid
*/
#[NoAdminRequired]
public function setPreference(string $appId, string $configKey, string $configValue): DataResponse {
$userId = $this->userSession->getUser()->getUID();

Expand Down Expand Up @@ -125,7 +126,6 @@ public function setPreference(string $appId, string $configKey, string $configVa
}

/**
* @NoAdminRequired
* @NoSubAdminRequired
*
* Delete multiple preferences for an app
Expand All @@ -137,6 +137,7 @@ public function setPreference(string $appId, string $configKey, string $configVa
* 200: Preferences deleted successfully
* 400: Preference invalid
*/
#[NoAdminRequired]
public function deleteMultiplePreference(string $appId, array $configKeys): DataResponse {
$userId = $this->userSession->getUser()->getUID();

Expand Down Expand Up @@ -167,7 +168,6 @@ public function deleteMultiplePreference(string $appId, array $configKeys): Data
}

/**
* @NoAdminRequired
* @NoSubAdminRequired
*
* Delete a preference for an app
Expand All @@ -179,6 +179,7 @@ public function deleteMultiplePreference(string $appId, array $configKeys): Data
* 200: Preference deleted successfully
* 400: Preference invalid
*/
#[NoAdminRequired]
public function deletePreference(string $appId, string $configKey): DataResponse {
$userId = $this->userSession->getUser()->getUID();

Expand Down
Loading