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