|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* The MIT License (MIT) |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright (c) 2014-2018 Spomky-Labs |
|
9
|
|
|
* |
|
10
|
|
|
* This software may be modified and distributed under the terms |
|
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace U2FAuthentication\Fido2; |
|
15
|
|
|
|
|
16
|
|
|
class AuthenticatorSelectionCriteria implements \JsonSerializable |
|
17
|
|
|
{ |
|
18
|
|
|
public const AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE = null; |
|
19
|
|
|
public const AUTHENTICATOR_ATTACHMENT_PLATFORM = 'platform'; |
|
20
|
|
|
public const AUTHENTICATOR_ATTACHMENT_CROSS_PLATFORM = 'cross-platform'; |
|
21
|
|
|
|
|
22
|
|
|
public const USER_VERIFICATION_REQUIREMENT_REQUIRED = 'required'; |
|
23
|
|
|
public const USER_VERIFICATION_REQUIREMENT_PREFERRED = 'preferred'; |
|
24
|
|
|
public const USER_VERIFICATION_REQUIREMENT_DISCOURAGED = 'discouraged'; |
|
25
|
|
|
|
|
26
|
|
|
private $authenticatorAttachment; |
|
27
|
|
|
|
|
28
|
|
|
private $requireResidentKey; |
|
29
|
|
|
|
|
30
|
|
|
private $userVerification; |
|
31
|
|
|
|
|
32
|
|
|
public function __construct(?string $authenticatorAttachment = null, bool $requireResidentKey = false, string $userVerification = self::USER_VERIFICATION_REQUIREMENT_PREFERRED) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->authenticatorAttachment = $authenticatorAttachment; |
|
35
|
|
|
$this->requireResidentKey = $requireResidentKey; |
|
36
|
|
|
$this->userVerification = $userVerification; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function getAuthenticatorAttachment(): ?string |
|
40
|
|
|
{ |
|
41
|
|
|
return $this->authenticatorAttachment; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function isRequireResidentKey(): bool |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->requireResidentKey; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function getUserVerification(): string |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->userVerification; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function jsonSerialize() |
|
55
|
|
|
{ |
|
56
|
|
|
$json = [ |
|
57
|
|
|
'requireResidentKey' => $this->requireResidentKey, |
|
58
|
|
|
'userVerification' => $this->userVerification, |
|
59
|
|
|
]; |
|
60
|
|
|
if ($this->authenticatorAttachment) { |
|
61
|
|
|
$json['authenticatorAttachment'] = $this->authenticatorAttachment; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
return $json; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|