1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Modules\WebAuthentication; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Controller; |
5
|
|
|
use Redaxscript\Head; |
6
|
|
|
use Redaxscript\Module; |
7
|
|
|
use function sleep; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* integrate web authentication |
11
|
|
|
* |
12
|
|
|
* @since 4.5.0 |
13
|
|
|
* |
14
|
|
|
* @package Redaxscript |
15
|
|
|
* @category Modules |
16
|
|
|
* @author Henry Ruhs |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
class WebAuthentication extends Module\Module |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* array of the module |
23
|
|
|
* |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
protected static $_moduleArray = |
28
|
|
|
[ |
29
|
|
|
'name' => 'WebAuthentication', |
30
|
|
|
'alias' => 'WebAuthentication', |
31
|
|
|
'author' => 'Redaxmedia', |
32
|
|
|
'description' => 'Integrate web authentication', |
33
|
|
|
'version' => '4.5.0', |
34
|
|
|
'license' => 'Sponsorware' |
35
|
|
|
]; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* renderStart |
39
|
|
|
* |
40
|
|
|
* @since 4.5.0 |
41
|
|
|
*/ |
42
|
|
|
|
43
|
|
|
public function renderStart() : void |
44
|
|
|
{ |
45
|
|
|
$script = Head\Script::getInstance(); |
46
|
|
|
$script |
47
|
|
|
->init('foot') |
48
|
|
|
->appendFile( |
49
|
|
|
[ |
50
|
|
|
'modules/WebAuthentication/assets/scripts/init.js', |
51
|
|
|
'modules/WebAuthentication/dist/scripts/web-authentication.min.js' |
52
|
|
|
]); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* routeContent |
57
|
|
|
* |
58
|
|
|
* @since 4.5.0 |
59
|
|
|
*/ |
60
|
|
|
|
61
|
|
|
public function routeContent() : ?string |
62
|
|
|
{ |
63
|
|
|
if ($this->_request->getPost('Redaxscript\View\LoginForm')) |
64
|
|
|
{ |
65
|
|
|
// $this->_registry->set('routerBreak', true); |
66
|
|
|
|
67
|
|
|
// lookup if that user has login bouncer enabled inside modules_web_authentication |
68
|
|
|
// remember the post array and pass it to the webauthn/login endpoint via fetch() |
69
|
|
|
// do all the auth via key and if promise is fine then do the process login |
70
|
|
|
|
71
|
|
|
sleep(2); |
72
|
|
|
return $this->_processLogin(); |
73
|
|
|
} |
74
|
|
|
return null; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* process the login |
79
|
|
|
* |
80
|
|
|
* @since 3.3.0 |
81
|
|
|
* |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
|
85
|
|
|
protected function _processLogin() : string |
86
|
|
|
{ |
87
|
|
|
$loginController = new Controller\Login($this->_registry, $this->_request, $this->_language, $this->_config); |
88
|
|
|
return $loginController->process(); |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|