diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 491e9e104..ece0f58d1 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -45,8 +45,10 @@ require_once __DIR__ . '/../../vendor/autoload.php'; class Application extends App implements IBootstrap { + public const APP_ID = 'user_saml'; + public function __construct(array $urlParams = []) { - parent::__construct('user_saml', $urlParams); + parent::__construct(self::APP_ID, $urlParams); } public function register(IRegistrationContext $context): void { @@ -95,7 +97,7 @@ public function boot(IBootContext $context): void { $params = []; // Setting up the one login config may fail, if so, do not catch the requests later. - switch ($config->getAppValue('user_saml', 'type')) { + switch ($config->getAppValue(self::APP_ID, 'type')) { case 'saml': $type = 'saml'; break; @@ -116,11 +118,11 @@ public function boot(IBootContext $context): void { try { OC_User::handleApacheAuth(); } catch (LoginException $e) { - if ($request->getPathInfo() === '/apps/user_saml/saml/error') { + if ($request->getPathInfo() === '/apps/' . self::APP_ID . '/saml/error') { return; } $targetUrl = $urlGenerator->linkToRouteAbsolute( - 'user_saml.SAML.genericError', + self::APP_ID . '.SAML.genericError', [ 'message' => $e->getMessage() ] @@ -136,11 +138,11 @@ public function boot(IBootContext $context): void { if ($user !== null) { $enabled = $user->isEnabled(); if ($enabled === false) { - if ($request->getPathInfo() === '/apps/user_saml/saml/error') { + if ($request->getPathInfo() === '/apps/' . self::APP_ID . '/saml/error') { return; } $targetUrl = $urlGenerator->linkToRouteAbsolute( - 'user_saml.SAML.genericError', + self::APP_ID . '.SAML.genericError', [ 'message' => $l10n->t('This user account is disabled, please contact your administrator.') ] @@ -182,7 +184,7 @@ public function boot(IBootContext $context): void { } $targetUrl = $urlGenerator->linkToRouteAbsolute( - 'user_saml.SAML.selectUserBackEnd', + self::APP_ID . '.SAML.selectUserBackEnd', [ 'redirectUrl' => $redirectUrl ] @@ -204,7 +206,7 @@ public function boot(IBootContext $context): void { $csrfToken = $csrfTokenManager->getToken(); $targetUrl = $urlGenerator->linkToRouteAbsolute( - 'user_saml.SAML.login', + self::APP_ID . '.SAML.login', [ 'requesttoken' => $csrfToken->getEncryptedValue(), 'originalUrl' => $originalUrl, @@ -216,7 +218,7 @@ public function boot(IBootContext $context): void { } }); } catch (Throwable $e) { - Server::get(LoggerInterface::class)->critical('Error when loading user_saml app', [ + Server::get(LoggerInterface::class)->critical('Error when loading ' . self::APP_ID . ' app', [ 'exception' => $e, ]); } diff --git a/lib/Command/ConfigGet.php b/lib/Command/ConfigGet.php index 998f8c5c8..dcfc5cc7b 100644 --- a/lib/Command/ConfigGet.php +++ b/lib/Command/ConfigGet.php @@ -35,11 +35,7 @@ protected function configure(): void { protected function execute(InputInterface $input, OutputInterface $output): int { $providerId = (int)$input->getOption('providerId'); - if (!empty($providerId)) { - $providerIds = [$providerId]; - } else { - $providerIds = array_keys($this->samlSettings->getListOfIdps()); - } + $providerIds = !empty($providerId) ? [$providerId] : array_keys($this->samlSettings->getListOfIdps(); $settings = []; foreach ($providerIds as $pid) {