1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace SimpleSAML\Module\webauthn\Controller; |
||
6 | |||
7 | use Exception; |
||
8 | use SimpleSAML\Auth; |
||
9 | use SimpleSAML\Configuration; |
||
10 | use SimpleSAML\Error; |
||
11 | use SimpleSAML\HTTP\RunnableResponse; |
||
12 | use SimpleSAML\Logger; |
||
13 | use SimpleSAML\Module\webauthn\Auth\Source\AuthSourceOverloader; |
||
0 ignored issues
–
show
|
|||
14 | use SimpleSAML\Session; |
||
15 | use Symfony\Component\HttpFoundation\{Request, Response}; |
||
16 | |||
17 | /** |
||
18 | * Controller class for the webauthn module. |
||
19 | * |
||
20 | * This class serves the different views available in the module. |
||
21 | * |
||
22 | * @package SimpleSAML\Module\webauthn |
||
23 | */ |
||
24 | class PushbackUserPass |
||
25 | { |
||
26 | /** @var \SimpleSAML\Auth\State|string */ |
||
27 | protected $authState = Auth\State::class; |
||
28 | |||
29 | /** @var \SimpleSAML\Logger|string */ |
||
30 | protected $logger = Logger::class; |
||
31 | |||
32 | /** |
||
33 | * Controller constructor. |
||
34 | * |
||
35 | * It initializes the global configuration and session for the controllers implemented here. |
||
36 | * |
||
37 | * @param \SimpleSAML\Configuration $config The configuration to use by the controllers. |
||
38 | * @param \SimpleSAML\Session $session The session to use by the controllers. |
||
39 | * |
||
40 | * @throws \Exception |
||
41 | */ |
||
42 | public function __construct( |
||
43 | protected Configuration $config, |
||
44 | protected Session $session, |
||
45 | ) { |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Inject the \SimpleSAML\Auth\State dependency. |
||
50 | * |
||
51 | * @param \SimpleSAML\Auth\State $authState |
||
52 | */ |
||
53 | public function setAuthState(Auth\State $authState): void |
||
54 | { |
||
55 | $this->authState = $authState; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Inject the \SimpleSAML\Logger dependency. |
||
60 | * |
||
61 | * @param \SimpleSAML\Logger $logger |
||
62 | */ |
||
63 | public function setLogger(Logger $logger): void |
||
64 | { |
||
65 | $this->logger = $logger; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
70 | * @return ( |
||
0 ignored issues
–
show
|
|||
71 | * \Symfony\Component\HttpFoundation\RedirectResponse| |
||
72 | * \SimpleSAML\HTTP\RunnableResponse |
||
73 | * ) A Symfony Response-object. |
||
74 | */ |
||
75 | public function main(Request $request): Response |
||
76 | { |
||
77 | $this->logger::info('FIDO2 Supercharged - Redirecting to username/password validation'); |
||
78 | |||
79 | $stateId = $request->query->get('StateId'); |
||
80 | if ($stateId === null) { |
||
81 | throw new Error\BadRequest('Missing required StateId query parameter.'); |
||
82 | } |
||
83 | |||
84 | $state = $this->authState::loadState($stateId, 'webauthn:request'); |
||
85 | |||
86 | $authsources = Configuration::getConfig('authsources.php')->toArray(); |
||
87 | $authsourceString = $state['pushbackAuthsource']; |
||
88 | $authsourceClass = Auth\Source::getById($authsourceString); |
||
89 | if (is_null($authsourceClass)) { |
||
90 | throw new Exception("password authsource not found"); |
||
91 | } |
||
92 | $classname = get_class($authsourceClass); |
||
93 | class_alias($classname, '\SimpleSAML\Module\webauthn\Auth\Source\AuthSourceOverloader'); |
||
94 | $overrideSource = new class ( |
||
95 | ['AuthId' => $authsourceString], |
||
96 | $authsources[$authsourceString], |
||
97 | ) extends AuthSourceOverloader |
||
98 | { |
||
99 | public function loginOverload(string $username, string $password): array |
||
100 | { |
||
101 | return $this->login($username, $password); |
||
102 | } |
||
103 | }; |
||
104 | |||
105 | $attribs = $overrideSource->loginOverload( |
||
106 | $request->request->get("username"), |
||
107 | $request->request->get("password"), |
||
108 | ); |
||
109 | |||
110 | // this is the confirmed username, we store it just like the Passwordless |
||
111 | // one would have been |
||
112 | $state['Attributes'][$state['FIDO2AttributeStoringUsername']] = [ $request->request->get("username") ]; |
||
113 | |||
114 | // we deliberately do not store any additional attributes - these have |
||
115 | // to be retrieved from the same authproc that would retrieve them |
||
116 | // in Passwordless mode |
||
117 | unset($attribs); |
||
118 | |||
119 | // now properly return our final state to the framework |
||
120 | return new RunnableResponse([Auth\Source::class, 'completeAuth'], [&$state]); |
||
121 | } |
||
122 | |||
123 | public function login(string $username, string $password): array |
||
124 | { |
||
125 | throw new Exception("Ugh ($username, $password)."); |
||
126 | } |
||
127 | } |
||
128 |
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