1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\MFA\Tests\Stub\Null; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Dev\TestOnly; |
6
|
|
|
use SilverStripe\MFA\Method\Handler\RegisterHandlerInterface; |
7
|
|
|
use SilverStripe\MFA\Method\Handler\VerifyHandlerInterface; |
8
|
|
|
use SilverStripe\MFA\Method\MethodInterface; |
9
|
|
|
|
10
|
|
|
class Method implements MethodInterface, TestOnly |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Provide a localised name for this MFA Method. |
14
|
|
|
* |
15
|
|
|
* eg. "Authenticator app" |
16
|
|
|
* |
17
|
|
|
* @return string |
18
|
|
|
*/ |
19
|
|
|
public function getName(): string |
20
|
|
|
{ |
21
|
|
|
// TODO: Implement getName() method. |
22
|
|
|
} |
|
|
|
|
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Get a URL segment for this method. This will be used in URL paths for performing authentication by this method |
26
|
|
|
* |
27
|
|
|
* @return string |
28
|
|
|
*/ |
29
|
|
|
public function getURLSegment(): string |
30
|
|
|
{ |
31
|
|
|
return 'null'; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Return the VerifyHandler that is used to start and check verification attempts with this method |
36
|
|
|
* |
37
|
|
|
* @return VerifyHandlerInterface |
38
|
|
|
*/ |
39
|
|
|
public function getVerifyHandler(): VerifyHandlerInterface |
40
|
|
|
{ |
41
|
|
|
return new VerifyHandler(); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Return the RegisterHandler that is used to perform registrations with this method |
46
|
|
|
* |
47
|
|
|
* @return RegisterHandlerInterface |
48
|
|
|
*/ |
49
|
|
|
public function getRegisterHandler(): RegisterHandlerInterface |
50
|
|
|
{ |
51
|
|
|
return new RegisterHandler(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Return a URL to an image to be used as a thumbnail in the MFA login/registration grid for all MFA methods |
56
|
|
|
* |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
public function getThumbnail(): string |
60
|
|
|
{ |
61
|
|
|
// TODO: Implement getThumbnail() method. |
62
|
|
|
} |
|
|
|
|
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Leverage the Requirements API to ensure client requirements are included. This is called just after the base |
66
|
|
|
* module requirements are specified |
67
|
|
|
* |
68
|
|
|
* @return void |
69
|
|
|
*/ |
70
|
|
|
public function applyRequirements(): void |
71
|
|
|
{ |
72
|
|
|
// TODO: Implement applyRequirements() method. |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Returns whether the method is available to be used from a backend perspective. |
77
|
|
|
* |
78
|
|
|
* @return bool |
79
|
|
|
*/ |
80
|
|
|
public function isAvailable(): bool |
81
|
|
|
{ |
82
|
|
|
return true; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* If not available to be used, provide a message to display on the frontend to explain why. |
87
|
|
|
* |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
|
|
public function getUnavailableMessage(): string |
91
|
|
|
{ |
92
|
|
|
// TODO: Implement getUnavailableMessage() method. |
93
|
|
|
} |
|
|
|
|
94
|
|
|
} |
95
|
|
|
|
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: