aboutsummaryrefslogtreecommitdiffstats
path: root/apps/admin_audit/lib/Actions/Security.php
blob: 203090795fbc429ce675f506b4b0750b0d8c9b70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php

declare(strict_types=1);
/**
 * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\AdminAudit\Actions;

use OCP\Authentication\TwoFactorAuth\IProvider;
use OCP\IUser;

/**
 * Class Sharing logs the sharing actions
 *
 * @package OCA\AdminAudit\Actions
 */
class Security extends Action {
	/**
	 * Logs failed twofactor challenge
	 */
	public function twofactorFailed(IUser $user, IProvider $provider): void {
		$params = [
			'displayName' => $user->getDisplayName(),
			'uid' => $user->getUID(),
			'provider' => $provider->getDisplayName(),
		];

		$this->log(
			'Failed two factor attempt by user %s (%s) with provider %s',
			$params,
			[
				'displayName',
				'uid',
				'provider',
			]
		);
	}

	/**
	 * Logs successful twofactor challenge
	 */
	public function twofactorSuccess(IUser $user, IProvider $provider): void {
		$params = [
			'displayName' => $user->getDisplayName(),
			'uid' => $user->getUID(),
			'provider' => $provider->getDisplayName(),
		];

		$this->log(
			'Successful two factor attempt by user %s (%s) with provider %s',
			$params,
			[
				'displayName',
				'uid',
				'provider',
			]
		);
	}
}