|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace Xervice\Security\Business\Provider; |
|
5
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
use DataProvider\AuthenticatorDataProvider; |
|
|
|
|
|
|
8
|
|
|
use Xervice\DataProvider\DataProvider\AbstractDataProvider; |
|
9
|
|
|
use Xervice\Security\Business\Authenticator\AuthenticatorInterface; |
|
10
|
|
|
use Xervice\Security\Business\Exception\SecurityException; |
|
11
|
|
|
|
|
12
|
|
|
class SecurityProvider implements SecurityProviderInterface |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var \Xervice\Security\Business\Authenticator\AuthenticatorInterface[] |
|
16
|
|
|
*/ |
|
17
|
|
|
private $authenticatorList; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* SecurityProvider constructor. |
|
21
|
|
|
* |
|
22
|
|
|
* @param array $authenticatorList |
|
23
|
|
|
*/ |
|
24
|
3 |
|
public function __construct(array $authenticatorList) |
|
25
|
|
|
{ |
|
26
|
3 |
|
foreach ($authenticatorList as $name => $authClass) { |
|
27
|
3 |
|
$this->add( |
|
28
|
3 |
|
$name, |
|
29
|
3 |
|
new $authClass() |
|
30
|
|
|
); |
|
31
|
|
|
} |
|
32
|
3 |
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param string $name |
|
36
|
|
|
* @param \Xervice\Security\Business\Authenticator\AuthenticatorInterface $authenticator |
|
37
|
|
|
*/ |
|
38
|
3 |
|
public function add(string $name, AuthenticatorInterface $authenticator): void |
|
39
|
|
|
{ |
|
40
|
3 |
|
$this->authenticatorList[$name] = $authenticator; |
|
41
|
3 |
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @param string $name |
|
45
|
|
|
* |
|
46
|
|
|
* @return \Xervice\Security\Business\Authenticator\AuthenticatorInterface |
|
47
|
|
|
* @throws \Xervice\Security\Business\Exception\SecurityException |
|
48
|
|
|
*/ |
|
49
|
3 |
|
public function get(string $name): AuthenticatorInterface |
|
50
|
|
|
{ |
|
51
|
3 |
|
if (!isset($this->authenticatorList[$name])) { |
|
52
|
|
|
throw new SecurityException( |
|
53
|
|
|
sprintf( |
|
54
|
|
|
'Authenticator %s does not exist', |
|
55
|
|
|
$name |
|
56
|
|
|
) |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
3 |
|
return $this->authenticatorList[$name]; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param string $name |
|
65
|
|
|
* @param \DataProvider\AuthenticatorDataProvider $dataProvider |
|
66
|
|
|
* |
|
67
|
|
|
* @throws \Xervice\Security\Business\Exception\SecurityException |
|
68
|
|
|
*/ |
|
69
|
3 |
|
public function authenticate(string $name, AuthenticatorDataProvider $dataProvider): void |
|
70
|
|
|
{ |
|
71
|
3 |
|
$this->get($name)->authenticate($dataProvider); |
|
72
|
|
|
} |
|
73
|
|
|
} |
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