|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (C) 2016 SURFnet. |
|
4
|
|
|
* |
|
5
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
6
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
7
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
8
|
|
|
* License, or (at your option) any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* This program is distributed in the hope that it will be useful, |
|
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13
|
|
|
* GNU Affero General Public License for more details. |
|
14
|
|
|
* |
|
15
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
16
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace SURFnet\VPN\Node; |
|
20
|
|
|
|
|
21
|
|
|
use Psr\Log\LoggerInterface; |
|
22
|
|
|
use SURFnet\VPN\Common\Http\InputValidation; |
|
23
|
|
|
use SURFnet\VPN\Common\HttpClient\ServerClient; |
|
24
|
|
|
|
|
25
|
|
|
class TwoFactor |
|
26
|
|
|
{ |
|
27
|
|
|
/** @var \Psr\Log\LoggerInterface */ |
|
28
|
|
|
private $logger; |
|
29
|
|
|
|
|
30
|
|
|
/** @var \SURFnet\VPN\Common\HttpClient\ServerClient */ |
|
31
|
|
|
private $serverClient; |
|
32
|
|
|
|
|
33
|
|
|
public function __construct(LoggerInterface $logger, ServerClient $serverClient) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->logger = $logger; |
|
36
|
|
|
$this->serverClient = $serverClient; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function verify(array $envData) |
|
40
|
|
|
{ |
|
41
|
|
|
$otpType = InputValidation::twoFactorType($envData['username']); |
|
42
|
|
|
$commonName = InputValidation::commonName($envData['common_name']); |
|
43
|
|
|
$otpValue = InputValidation::twoFactorValue($envData['password']); |
|
44
|
|
|
|
|
45
|
|
|
$this->serverClient->post('verify_two_factor', ['common_name' => $commonName, 'two_factor_type' => $otpType, 'two_factor_value' => $otpValue]); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|