1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\MFA\BackupCode; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Core\Injector\Injector; |
6
|
|
|
use SilverStripe\Core\Manifest\ModuleLoader; |
7
|
|
|
use SilverStripe\MFA\Method\Handler\VerifyHandlerInterface; |
8
|
|
|
use SilverStripe\MFA\Method\Handler\RegisterHandlerInterface; |
9
|
|
|
use SilverStripe\MFA\Method\MethodInterface; |
10
|
|
|
|
11
|
|
|
class Method implements MethodInterface |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Provide a localised name for this MFA Method. |
15
|
|
|
* |
16
|
|
|
* eg. "Authenticator app" |
17
|
|
|
* |
18
|
|
|
* @return string |
19
|
|
|
*/ |
20
|
|
|
public function getName(): string |
21
|
|
|
{ |
22
|
|
|
return _t(__CLASS__ . '.NAME', 'Recovery codes'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Get a URL segment for this method. This will be used in URL paths for performing authentication by this method |
27
|
|
|
* |
28
|
|
|
* @return string |
29
|
|
|
*/ |
30
|
|
|
public function getURLSegment(): string |
31
|
|
|
{ |
32
|
|
|
return 'backup-codes'; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Return the VerifyHandler that is used to start and check verification attempts with this method |
37
|
|
|
* |
38
|
|
|
* @return VerifyHandlerInterface |
39
|
|
|
*/ |
40
|
|
|
public function getVerifyHandler(): VerifyHandlerInterface |
41
|
|
|
{ |
42
|
|
|
return Injector::inst()->create(VerifyHandler::class); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Return the RegisterHandler that is used to perform registrations with this method |
47
|
|
|
* |
48
|
|
|
* @return RegisterHandlerInterface |
49
|
|
|
*/ |
50
|
|
|
public function getRegisterHandler(): RegisterHandlerInterface |
51
|
|
|
{ |
52
|
|
|
return Injector::inst()->create(RegisterHandler::class); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getThumbnail(): string |
56
|
|
|
{ |
57
|
|
|
return (string) ModuleLoader::getModule('silverstripe/mfa') |
58
|
|
|
->getResource('client/dist/images/locked-letter.svg') |
59
|
|
|
->getURL(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function applyRequirements(): void |
63
|
|
|
{ |
64
|
|
|
// This authenticator bundles client requirements in the main bundle. |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function isAvailable(): bool |
68
|
|
|
{ |
69
|
|
|
return true; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getUnavailableMessage(): string |
73
|
|
|
{ |
74
|
|
|
return ''; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|