mirror of
https://github.com/nextcloud/server.git
synced 2026-11-26 16:15:53 +01:00
Audit entries are added for app password creation, deletion and scope changes, remote wipe requests, WebAuthn devices, two-factor enforcement, mail server settings and credentials, admin delegation, presets, declarative settings and log file downloads. The existing AI settings entry keeps its message and now carries an operation (settings.ai.updated) and named parameters. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Ghassen kefi <ghassen.kefi.dev@gmail.com>
55 lines
1.7 KiB
PHP
55 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace OCA\Settings\Controller;
|
|
|
|
use OC\Authentication\TwoFactorAuth\EnforcementState;
|
|
use OC\Authentication\TwoFactorAuth\MandatoryTwoFactor;
|
|
use OCP\AppFramework\Controller;
|
|
use OCP\AppFramework\Http\Attribute\PasswordConfirmationRequired;
|
|
use OCP\AppFramework\Http\JSONResponse;
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
|
use OCP\IRequest;
|
|
use OCP\Log\Audit\CriticalActionPerformedEvent;
|
|
|
|
class TwoFactorSettingsController extends Controller {
|
|
|
|
public function __construct(
|
|
string $appName,
|
|
IRequest $request,
|
|
private MandatoryTwoFactor $mandatoryTwoFactor,
|
|
private IEventDispatcher $eventDispatcher,
|
|
) {
|
|
parent::__construct($appName, $request);
|
|
}
|
|
|
|
public function index(): JSONResponse {
|
|
return new JSONResponse($this->mandatoryTwoFactor->getState());
|
|
}
|
|
|
|
#[PasswordConfirmationRequired(strict: true)]
|
|
public function update(bool $enforced, array $enforcedGroups = [], array $excludedGroups = []): JSONResponse {
|
|
$this->mandatoryTwoFactor->setState(
|
|
new EnforcementState($enforced, $enforcedGroups, $excludedGroups)
|
|
);
|
|
$this->eventDispatcher->dispatchTyped(new CriticalActionPerformedEvent(
|
|
'Two-factor authentication enforcement was set to "%s" with enforced groups "%s" and excluded groups "%s"',
|
|
[
|
|
'enforced' => $enforced ? 'enabled' : 'disabled',
|
|
'enforcedGroups' => implode(', ', $enforcedGroups),
|
|
'excludedGroups' => implode(', ', $excludedGroups),
|
|
],
|
|
false,
|
|
'auth.twofactor_enforcement.updated',
|
|
));
|
|
|
|
return new JSONResponse($this->mandatoryTwoFactor->getState());
|
|
}
|
|
}
|