|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @author Christoph Wurst <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* Nextcloud - Two-factor Gateway |
|
9
|
|
|
* |
|
10
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
11
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
12
|
|
|
* as published by the Free Software Foundation. |
|
13
|
|
|
* |
|
14
|
|
|
* This program is distributed in the hope that it will be useful, |
|
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17
|
|
|
* GNU Affero General Public License for more details. |
|
18
|
|
|
* |
|
19
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
20
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
21
|
|
|
* |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace OCA\TwoFactorGateway\Provider; |
|
25
|
|
|
|
|
26
|
|
|
use OCA\TwoFactorGateway\Service\Gateway\IGateway; |
|
27
|
|
|
use OCA\TwoFactorGateway\Service\Gateway\Telegram\Gateway; |
|
28
|
|
|
use OCA\TwoFactorGateway\Service\StateStorage; |
|
29
|
|
|
use OCP\IL10N; |
|
30
|
|
|
use OCP\ISession; |
|
31
|
|
|
use OCP\Security\ISecureRandom; |
|
32
|
|
|
|
|
33
|
|
|
class TelegramProvider extends AProvider { |
|
34
|
|
|
|
|
35
|
|
|
public function __construct(Gateway $smsGateway, |
|
36
|
|
|
StateStorage $stateStorage, |
|
37
|
|
|
ISession $session, |
|
38
|
|
|
ISecureRandom $secureRandom, |
|
39
|
|
|
IL10N $l10n) { |
|
40
|
|
|
parent::__construct( |
|
41
|
|
|
'telegram', |
|
42
|
|
|
$smsGateway, |
|
43
|
|
|
$stateStorage, |
|
44
|
|
|
$session, |
|
45
|
|
|
$secureRandom, |
|
46
|
|
|
$l10n |
|
47
|
|
|
); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get unique identifier of this 2FA provider |
|
52
|
|
|
*/ |
|
53
|
|
|
public function getId(): string { |
|
54
|
|
|
return 'gateway_telegram'; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Get the display name for selecting the 2FA provider |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getDisplayName(): string { |
|
61
|
|
|
return $this->l10n->t('Telegram verification'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Get the description for selecting the 2FA provider |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getDescription(): string { |
|
68
|
|
|
return $this->l10n->t('Authenticate via Telegram'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|