1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\WebAuthn; |
4
|
|
|
|
5
|
|
|
use CBOR\Decoder; |
6
|
|
|
use CBOR\OtherObject\OtherObjectManager; |
7
|
|
|
use CBOR\Tag\TagObjectManager; |
8
|
|
|
use Webauthn\AttestationStatement\AttestationObjectLoader; |
9
|
|
|
use Webauthn\AttestationStatement\AttestationStatementSupportManager; |
10
|
|
|
use Webauthn\AttestationStatement\FidoU2FAttestationStatementSupport; |
11
|
|
|
use Webauthn\AttestationStatement\NoneAttestationStatementSupport; |
12
|
|
|
use Webauthn\PublicKeyCredentialLoader; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Contains logic which is shared between both WebAuthn's RegisterHandler and VerifyHandler, such as |
16
|
|
|
* the attestation configuration options. |
17
|
|
|
*/ |
18
|
|
|
trait BaseHandlerTrait |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @return Decoder |
22
|
|
|
*/ |
23
|
|
|
protected function getDecoder(): Decoder |
24
|
|
|
{ |
25
|
|
|
return new Decoder(new TagObjectManager(), new OtherObjectManager()); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param Decoder $decoder |
30
|
|
|
* @return AttestationStatementSupportManager |
31
|
|
|
*/ |
32
|
|
|
protected function getAttestationStatementSupportManager(Decoder $decoder): AttestationStatementSupportManager |
33
|
|
|
{ |
34
|
|
|
$manager = new AttestationStatementSupportManager(); |
35
|
|
|
$manager->add(new NoneAttestationStatementSupport()); |
36
|
|
|
$manager->add(new FidoU2FAttestationStatementSupport($decoder)); |
37
|
|
|
return $manager; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param AttestationStatementSupportManager $attestationStatementSupportManager |
42
|
|
|
* @param Decoder $decoder |
43
|
|
|
* @return AttestationObjectLoader |
44
|
|
|
*/ |
45
|
|
|
protected function getAttestationObjectLoader( |
46
|
|
|
AttestationStatementSupportManager $attestationStatementSupportManager, |
47
|
|
|
Decoder $decoder |
48
|
|
|
): AttestationObjectLoader { |
49
|
|
|
return new AttestationObjectLoader($attestationStatementSupportManager, $decoder); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param AttestationObjectLoader $attestationObjectLoader |
54
|
|
|
* @param Decoder $decoder |
55
|
|
|
* @return PublicKeyCredentialLoader |
56
|
|
|
*/ |
57
|
|
|
protected function getPublicKeyCredentialLoader( |
58
|
|
|
AttestationObjectLoader $attestationObjectLoader, |
59
|
|
|
Decoder $decoder |
60
|
|
|
): PublicKeyCredentialLoader { |
61
|
|
|
return new PublicKeyCredentialLoader($attestationObjectLoader, $decoder); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|