1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\MFA\RequestHandler; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Core\Injector\Injector; |
6
|
|
|
use SilverStripe\MFA\Service\MethodRegistry; |
7
|
|
|
use SilverStripe\MFA\Store\StoreInterface; |
8
|
|
|
use SilverStripe\Security\Member; |
9
|
|
|
use SilverStripe\SecurityExtensions\Service\SudoModeServiceInterface; |
|
|
|
|
10
|
|
|
use SilverStripe\View\Requirements; |
11
|
|
|
|
12
|
|
|
trait BaseHandlerTrait |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* A "session store" object that helps contain MFA specific session detail |
16
|
|
|
* |
17
|
|
|
* @var StoreInterface |
18
|
|
|
*/ |
19
|
|
|
protected $store; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Perform the necessary "Requirements" calls to ensure client side scripts are available in the response |
23
|
|
|
* |
24
|
|
|
* @param bool $frontEndRequirements Indicates dependencies usually provided by admin should also be required |
25
|
|
|
*/ |
26
|
|
|
protected function applyRequirements(bool $frontEndRequirements = true): void |
27
|
|
|
{ |
28
|
|
|
// Run through requirements |
29
|
|
|
if ($frontEndRequirements) { |
30
|
|
|
Requirements::javascript('silverstripe/mfa: client/dist/js/injector.js'); |
31
|
|
|
Requirements::javascript('silverstripe/admin: client/dist/js/i18n.js'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
Requirements::add_i18n_javascript('silverstripe/mfa: client/lang'); |
|
|
|
|
35
|
|
|
|
36
|
|
|
$suffix = $frontEndRequirements ? '' : '-cms'; |
37
|
|
|
Requirements::javascript("silverstripe/mfa: client/dist/js/bundle{$suffix}.js"); |
38
|
|
|
Requirements::css("silverstripe/mfa: client/dist/styles/bundle{$suffix}.css"); |
39
|
|
|
|
40
|
|
|
// Plugin module requirements |
41
|
|
|
foreach (MethodRegistry::singleton()->getMethods() as $method) { |
42
|
|
|
$method->applyRequirements(); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return StoreInterface|null |
48
|
|
|
*/ |
49
|
|
|
protected function getStore(): ?StoreInterface |
50
|
|
|
{ |
51
|
|
|
if (!$this->store) { |
52
|
|
|
$spec = Injector::inst()->getServiceSpec(StoreInterface::class); |
53
|
|
|
$class = is_string($spec) ? $spec : $spec['class']; |
54
|
|
|
$this->store = call_user_func([$class, 'load'], $this->getRequest()); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $this->store; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param StoreInterface $store |
62
|
|
|
* @return $this |
63
|
|
|
*/ |
64
|
|
|
public function setStore(StoreInterface $store): self |
65
|
|
|
{ |
66
|
|
|
$this->store = $store; |
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param Member $member |
72
|
|
|
* @return StoreInterface |
73
|
|
|
*/ |
74
|
|
|
protected function createStore(Member $member): StoreInterface |
75
|
|
|
{ |
76
|
|
|
$store = Injector::inst()->create(StoreInterface::class, $member); |
77
|
|
|
// Ensure use of the getter returns the new store |
78
|
|
|
$this->store = $store; |
79
|
|
|
return $store; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Returns a sudo mode service instance |
84
|
|
|
* |
85
|
|
|
* @return SudoModeServiceInterface |
86
|
|
|
*/ |
87
|
|
|
protected function getSudoModeService(): SudoModeServiceInterface |
88
|
|
|
{ |
89
|
|
|
return Injector::inst()->get(SudoModeServiceInterface::class); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths