* [MOD] Use static types.

* [MOD] CORS headers.
* [MOD] Improve Forwarded header lookup.
* [ADD] Create interface for configuration data.

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2021-10-12 20:49:18 +02:00
parent 5424084a52
commit 58249da565
638 changed files with 21764 additions and 22315 deletions

View File

@@ -4,7 +4,7 @@
*
* @author nuxsmin
* @link https://syspass.org
* @copyright 2012-2020, Rubén Domínguez nuxsmin@$syspass.org
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
*
* This file is part of sysPass.
*
@@ -19,18 +19,17 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
*/
namespace SP\Modules\Web\Controllers;
use DI\DependencyException;
use DI\NotFoundException;
use SP\Core\Acl\Acl;
use SP\Core\Acl\ActionsInterface;
use SP\Core\Acl\UnauthorizedPageException;
use SP\Core\Events\Event;
use SP\Core\Events\EventMessage;
use SP\Core\Exceptions\SessionTimeout;
use SP\Http\JsonResponse;
use SP\Modules\Web\Controllers\Traits\ConfigTrait;
@@ -47,6 +46,7 @@ final class ConfigWikiController extends SimpleControllerBase
* @return bool
* @throws DependencyException
* @throws NotFoundException
* @throws \JsonException
*/
public function saveAction(): bool
{
@@ -61,7 +61,10 @@ final class ConfigWikiController extends SimpleControllerBase
// Valores para la conexión a la Wiki
if ($wikiEnabled && (!$wikiSearchUrl || !$wikiPageUrl || !$wikiFilter)) {
return $this->returnJsonResponse(JsonResponse::JSON_ERROR, __u('Missing Wiki parameters'));
return $this->returnJsonResponse(
JsonResponse::JSON_ERROR,
__u('Missing Wiki parameters')
);
}
if ($wikiEnabled) {
@@ -79,28 +82,37 @@ final class ConfigWikiController extends SimpleControllerBase
$eventMessage->addDescription(__u('Wiki disabled'));
}
return $this->saveConfig($configData, $this->config, function () use ($eventMessage) {
$this->eventDispatcher->notifyEvent('save.config.wiki', new Event($this, $eventMessage));
});
return $this->saveConfig(
$configData,
$this->config,
function () use ($eventMessage) {
$this->eventDispatcher->notifyEvent(
'save.config.wiki',
new Event($this, $eventMessage)
);
}
);
}
/**
* @return bool
* @throws DependencyException
* @throws NotFoundException
* @throws SessionTimeout
* @return void
* @throws \DI\DependencyException
* @throws \DI\NotFoundException
* @throws \JsonException
* @throws \SP\Core\Exceptions\SessionTimeout
*/
protected function initialize()
protected function initialize(): void
{
try {
$this->checks();
$this->checkAccess(Acl::CONFIG_WIKI);
$this->checkAccess(ActionsInterface::CONFIG_WIKI);
} catch (UnauthorizedPageException $e) {
$this->eventDispatcher->notifyEvent('exception', new Event($e));
$this->eventDispatcher->notifyEvent(
'exception',
new Event($e)
);
return $this->returnJsonResponseException($e);
$this->returnJsonResponseException($e);
}
return true;
}
}