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