Skip to content

Commit

Permalink
Merge branch 'master' into mrv/mfa-check-final
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvahedi68 authored Jul 31, 2023
2 parents e206efd + 8c846ce commit cdd894e
Show file tree
Hide file tree
Showing 42 changed files with 614 additions and 370 deletions.
4 changes: 2 additions & 2 deletions apps/files/l10n/gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ OC.L10N.register(
"Target folder \"{dir}\" does not exist any more" : "O cartafol de destino «{dir}» xa non existe",
"Not enough free space" : "Non hai espazo libre abondo",
"An unknown error has occurred" : "Produciuse un erro descoñecido",
"File could not be uploaded" : "Non foi posíbel cargar o ficheiro",
"File could not be uploaded" : "Non foi posíbel enviar o ficheiro",
"Uploading …" : "Enviando…",
"{loadedSize} of {totalSize} ({bitrate})" : "{loadedSize} de {totalSize} ({bitrate})",
"Uploading that item is not supported" : "Non se admite o envío deste elemento",
Expand Down Expand Up @@ -76,7 +76,7 @@ OC.L10N.register(
"_%n file_::_%n files_" : ["%n ficheiro","%n ficheiros"],
"{dirs} and {files}" : "{dirs} e {files}",
"_including %n hidden_::_including %n hidden_" : ["incluíndo %n agachado","incluíndo %n agochados"],
"You do not have permission to upload or create files here" : "Non ten permiso para cargar ou crear ficheiros aquí",
"You do not have permission to upload or create files here" : "Non ten permiso para enviar ou crear ficheiros aquí",
"_Uploading %n file_::_Uploading %n files_" : ["Enviando %n ficheiro","Enviando %n ficheiros"],
"New file/folder menu" : "Novo menú ficheiro/cartafol",
"Select file range" : "Seleccionar o intervalo de ficheiros ",
Expand Down
4 changes: 2 additions & 2 deletions apps/files/l10n/gl.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"Target folder \"{dir}\" does not exist any more" : "O cartafol de destino «{dir}» xa non existe",
"Not enough free space" : "Non hai espazo libre abondo",
"An unknown error has occurred" : "Produciuse un erro descoñecido",
"File could not be uploaded" : "Non foi posíbel cargar o ficheiro",
"File could not be uploaded" : "Non foi posíbel enviar o ficheiro",
"Uploading …" : "Enviando…",
"{loadedSize} of {totalSize} ({bitrate})" : "{loadedSize} de {totalSize} ({bitrate})",
"Uploading that item is not supported" : "Non se admite o envío deste elemento",
Expand Down Expand Up @@ -74,7 +74,7 @@
"_%n file_::_%n files_" : ["%n ficheiro","%n ficheiros"],
"{dirs} and {files}" : "{dirs} e {files}",
"_including %n hidden_::_including %n hidden_" : ["incluíndo %n agachado","incluíndo %n agochados"],
"You do not have permission to upload or create files here" : "Non ten permiso para cargar ou crear ficheiros aquí",
"You do not have permission to upload or create files here" : "Non ten permiso para enviar ou crear ficheiros aquí",
"_Uploading %n file_::_Uploading %n files_" : ["Enviando %n ficheiro","Enviando %n ficheiros"],
"New file/folder menu" : "Novo menú ficheiro/cartafol",
"Select file range" : "Seleccionar o intervalo de ficheiros ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
'OCA\\Provisioning_API\\Listener\\UserDeletedListener' => $baseDir . '/../lib/Listener/UserDeletedListener.php',
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => $baseDir . '/../lib/Middleware/ProvisioningApiMiddleware.php',
'OCA\\Provisioning_API\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php',
);
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ComposerStaticInitProvisioning_API
'OCA\\Provisioning_API\\Listener\\UserDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/UserDeletedListener.php',
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__ . '/..' . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ProvisioningApiMiddleware.php',
'OCA\\Provisioning_API\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php',
);

public static function getInitializer(ClassLoader $loader)
Expand Down
10 changes: 10 additions & 0 deletions apps/provisioning_api/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @copyright Copyright (c) 2021 Vincent Petry <vincent@nextcloud.com>
*
* @author Vincent Petry <vincent@nextcloud.com>
* @author Kate Döen <kate.doeen@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
Expand Down Expand Up @@ -37,6 +38,15 @@ public function __construct(IAppManager $appManager) {

/**
* Function an app uses to return the capabilities
*
* @return array{
* provisioning_api: array{
* version: string,
* AccountPropertyScopesVersion: int,
* AccountPropertyScopesFederatedEnabled: bool,
* AccountPropertyScopesPublishedEnabled: bool,
* },
* }
*/
public function getCapabilities() {
$federatedScopeEnabled = $this->appManager->isEnabledForUser('federation');
Expand Down
15 changes: 10 additions & 5 deletions apps/provisioning_api/lib/Controller/AUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use OC\User\Backend;
use OC\User\NoUserException;
use OC_Helper;
use OCA\Provisioning_API\ResponseDefinitions;
use OCP\Accounts\IAccountManager;
use OCP\Accounts\PropertyDoesNotExistException;
use OCP\AppFramework\Http;
Expand All @@ -52,6 +53,10 @@
use OCP\User\Backend\ISetDisplayNameBackend;
use OCP\User\Backend\ISetPasswordBackend;

/**
* @psalm-import-type ProvisioningApiUserDetails from ResponseDefinitions
* @psalm-import-type ProvisioningApiUserDetailsQuota from ResponseDefinitions
*/
abstract class AUserData extends OCSController {
public const SCOPE_SUFFIX = 'Scope';

Expand Down Expand Up @@ -99,12 +104,12 @@ public function __construct(string $appName,
*
* @param string $userId
* @param bool $includeScopes
* @return array
* @return ProvisioningApiUserDetails|null
* @throws NotFoundException
* @throws OCSException
* @throws OCSNotFoundException
*/
protected function getUserData(string $userId, bool $includeScopes = false): array {
protected function getUserData(string $userId, bool $includeScopes = false): ?array {
$currentLoggedInUser = $this->userSession->getUser();
assert($currentLoggedInUser !== null, 'No user logged in');

Expand All @@ -123,7 +128,7 @@ protected function getUserData(string $userId, bool $includeScopes = false): arr
} else {
// Check they are looking up themselves
if ($currentLoggedInUser->getUID() !== $targetUserObject->getUID()) {
return $data;
return null;
}
}

Expand Down Expand Up @@ -225,7 +230,7 @@ protected function getUserData(string $userId, bool $includeScopes = false): arr
* Get the groups a user is a subadmin of
*
* @param string $userId
* @return array
* @return string[]
* @throws OCSException
*/
protected function getUserSubAdminGroupsData(string $userId): array {
Expand All @@ -247,7 +252,7 @@ protected function getUserSubAdminGroupsData(string $userId): array {

/**
* @param string $userId
* @return array
* @return ProvisioningApiUserDetailsQuota
* @throws OCSException
*/
protected function fillStorageInfo(string $userId): array {
Expand Down
53 changes: 39 additions & 14 deletions apps/provisioning_api/lib/Controller/AppConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author Joas Schilling <coding@schilljs.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Kate Döen <kate.doeen@nextcloud.com>
*
* @license GNU AGPL version 3 or any later version
*
Expand Down Expand Up @@ -84,7 +85,9 @@ public function __construct(string $appName,
}

/**
* @return DataResponse
* Get a list of apps
*
* @return DataResponse<Http::STATUS_OK, array{data: string[]}, array{}>
*/
public function getApps(): DataResponse {
return new DataResponse([
Expand All @@ -93,8 +96,13 @@ public function getApps(): DataResponse {
}

/**
* @param string $app
* @return DataResponse
* Get the config keys of an app
*
* @param string $app ID of the app
* @return DataResponse<Http::STATUS_OK, array{data: string[]}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}>
*
* 200: Keys returned
* 403: App is not allowed
*/
public function getKeys(string $app): DataResponse {
try {
Expand All @@ -108,10 +116,15 @@ public function getKeys(string $app): DataResponse {
}

/**
* @param string $app
* @param string $key
* @param string $defaultValue
* @return DataResponse
* Get a the config value of an app
*
* @param string $app ID of the app
* @param string $key Key
* @param string $defaultValue Default returned value if the value is empty
* @return DataResponse<Http::STATUS_OK, array{data: string}, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}>
*
* 200: Value returned
* 403: App is not allowed
*/
public function getValue(string $app, string $key, string $defaultValue = ''): DataResponse {
try {
Expand All @@ -128,10 +141,16 @@ public function getValue(string $app, string $key, string $defaultValue = ''): D
* @PasswordConfirmationRequired
* @NoSubAdminRequired
* @NoAdminRequired
* @param string $app
* @param string $key
* @param string $value
* @return DataResponse
*
* Update the config value of an app
*
* @param string $app ID of the app
* @param string $key Key to update
* @param string $value New value for the key
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}>
*
* 200: Value updated successfully
* 403: App or key is not allowed
*/
public function setValue(string $app, string $key, string $value): DataResponse {
$user = $this->userSession->getUser();
Expand All @@ -156,9 +175,15 @@ public function setValue(string $app, string $key, string $value): DataResponse

/**
* @PasswordConfirmationRequired
* @param string $app
* @param string $key
* @return DataResponse
*
* Delete a config key of an app
*
* @param string $app ID of the app
* @param string $key Key to delete
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>|DataResponse<Http::STATUS_FORBIDDEN, array{data: array{message: string}}, array{}>
*
* 200: Key deleted successfully
* 403: App or key is not allowed
*/
public function deleteKey(string $app, string $key): DataResponse {
try {
Expand Down
35 changes: 26 additions & 9 deletions apps/provisioning_api/lib/Controller/AppsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* @author Lukas Reschke <lukas@statuscode.ch>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tom Needham <tom@owncloud.com>
* @author Kate Döen <kate.doeen@nextcloud.com>
*
* @license AGPL-3.0
*
Expand All @@ -29,13 +30,18 @@
namespace OCA\Provisioning_API\Controller;

use OC_App;
use OCA\Provisioning_API\ResponseDefinitions;
use OCP\App\AppPathNotFoundException;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCS\OCSException;
use OCP\AppFramework\OCSController;
use OCP\IRequest;

/**
* @psalm-import-type ProvisioningApiAppInfo from ResponseDefinitions
*/
class AppsController extends OCSController {
/** @var IAppManager */
private $appManager;
Expand All @@ -51,16 +57,19 @@ public function __construct(
}

/**
* @param string|null $filter
* @return DataResponse
* Get a list of installed apps
*
* @param ?string $filter Filter for enabled or disabled apps
* @return DataResponse<Http::STATUS_OK, array{apps: string[]}, array{}>
* @throws OCSException
*/
public function getApps(string $filter = null): DataResponse {
public function getApps(?string $filter = null): DataResponse {
$apps = (new OC_App())->listAllApps();
$list = [];
foreach ($apps as $app) {
$list[] = $app['id'];
}
/** @var string[] $list */
if ($filter) {
switch ($filter) {
case 'enabled':
Expand All @@ -80,8 +89,10 @@ public function getApps(string $filter = null): DataResponse {
}

/**
* @param string $app
* @return DataResponse
* Get the app info for an app
*
* @param string $app ID of the app
* @return DataResponse<Http::STATUS_OK, ProvisioningApiAppInfo, array{}>
* @throws OCSException
*/
public function getAppInfo(string $app): DataResponse {
Expand All @@ -95,8 +106,11 @@ public function getAppInfo(string $app): DataResponse {

/**
* @PasswordConfirmationRequired
* @param string $app
* @return DataResponse
*
* Enable an app
*
* @param string $app ID of the app
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
* @throws OCSException
*/
public function enable(string $app): DataResponse {
Expand All @@ -110,8 +124,11 @@ public function enable(string $app): DataResponse {

/**
* @PasswordConfirmationRequired
* @param string $app
* @return DataResponse
*
* Disable an app
*
* @param string $app ID of the app
* @return DataResponse<Http::STATUS_OK, array<empty>, array{}>
*/
public function disable(string $app): DataResponse {
$this->appManager->disableApp($app);
Expand Down
Loading

0 comments on commit cdd894e

Please sign in to comment.