1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\MFA\Tests\Stub\BasicMath; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Control\Director; |
6
|
|
|
use SilverStripe\Core\Manifest\ModuleLoader; |
7
|
|
|
use SilverStripe\Dev\TestOnly; |
8
|
|
|
use SilverStripe\MFA\Method\Handler\RegisterHandlerInterface; |
9
|
|
|
use SilverStripe\MFA\Method\Handler\VerifyHandlerInterface; |
10
|
|
|
use SilverStripe\MFA\Method\MethodInterface; |
11
|
|
|
|
12
|
|
|
class Method implements MethodInterface, TestOnly |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Get a URL segment for this method. This will be used in URL paths for performing authentication by this method |
16
|
|
|
* |
17
|
|
|
* @return string |
18
|
|
|
*/ |
19
|
|
|
public function getURLSegment(): string |
20
|
|
|
{ |
21
|
|
|
return 'basic-math'; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Return the VerifyHandler that is used to start and check verification attempts with this method |
26
|
|
|
* |
27
|
|
|
* @return VerifyHandlerInterface |
28
|
|
|
*/ |
29
|
|
|
public function getVerifyHandler(): VerifyHandlerInterface |
30
|
|
|
{ |
31
|
|
|
return new MethodVerifyHandler(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Return the RegisterHandler that is used to perform registrations with this method |
36
|
|
|
* |
37
|
|
|
* @return RegisterHandlerInterface |
38
|
|
|
*/ |
39
|
|
|
public function getRegisterHandler(): RegisterHandlerInterface |
40
|
|
|
{ |
41
|
|
|
return new MethodRegisterHandler(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function getThumbnail(): string |
45
|
|
|
{ |
46
|
|
|
return (string) ModuleLoader::getModule('silverstripe/mfa') |
47
|
|
|
->getResource('client/dist/images/totp.svg') |
48
|
|
|
->getURL(); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function applyRequirements(): void |
52
|
|
|
{ |
53
|
|
|
// noop |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function isAvailable(): bool |
57
|
|
|
{ |
58
|
|
|
return Director::isDev(); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function getUnavailableMessage(): string |
62
|
|
|
{ |
63
|
|
|
return 'This is a test authenticator, only available in dev mode for tests.'; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function getName(): string |
67
|
|
|
{ |
68
|
|
|
return 'Math problem'; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|