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