44
55namespace PhpMyAdmin \Plugins \TwoFactor ;
66
7- use PhpMyAdmin \Application ;
87use PhpMyAdmin \Http \ServerRequest ;
98use PhpMyAdmin \Plugins \TwoFactorPlugin ;
109use PhpMyAdmin \ResponseRenderer ;
@@ -39,8 +38,6 @@ class WebAuthn extends TwoFactorPlugin
3938
4039 private Server $ server ;
4140
42- public ServerRequest |null $ serverRequest = null ;
43-
4441 public function __construct (TwoFactor $ twofactor )
4542 {
4643 parent ::__construct ($ twofactor );
@@ -72,18 +69,8 @@ public function setServer(Server $server): void
7269 $ this ->server = $ server ;
7370 }
7471
75- private function getRequest (): ServerRequest
76- {
77- if ($ this ->serverRequest === null ) {
78- $ this ->serverRequest = Application::getRequest ();
79- }
80-
81- return $ this ->serverRequest ;
82- }
83-
84- public function render (): string
72+ public function render (ServerRequest $ request ): string
8573 {
86- $ request = $ this ->getRequest ();
8774 $ userHandle = sodium_base642bin ($ this ->getUserHandleFromSettings (), SODIUM_BASE64_VARIANT_URLSAFE_NO_PADDING );
8875 $ requestOptions = $ this ->server ->getCredentialRequestOptions (
8976 $ this ->twofactor ->user ,
@@ -101,10 +88,9 @@ public function render(): string
10188 );
10289 }
10390
104- public function check (): bool
91+ public function check (ServerRequest $ request ): bool
10592 {
10693 $ this ->provided = false ;
107- $ request = $ this ->getRequest ();
10894 $ authenticatorResponse = $ request ->getParsedBodyParam ('webauthn_request_response ' , '' );
10995 if ($ authenticatorResponse === '' || ! isset ($ _SESSION ['WebAuthnCredentialRequestOptions ' ])) {
11096 return false ;
@@ -138,9 +124,8 @@ public function check(): bool
138124 return true ;
139125 }
140126
141- public function setup (): string
127+ public function setup (ServerRequest $ request ): string
142128 {
143- $ request = $ this ->getRequest ();
144129 $ userId = sodium_bin2base64 (random_bytes (32 ), SODIUM_BASE64_VARIANT_ORIGINAL );
145130 $ host = $ request ->getUri ()->getHost ();
146131 $ creationOptions = $ this ->server ->getCredentialCreationOptions ($ this ->twofactor ->user , $ userId , $ host );
@@ -154,10 +139,9 @@ public function setup(): string
154139 );
155140 }
156141
157- public function configure (): bool
142+ public function configure (ServerRequest $ request ): bool
158143 {
159144 $ this ->provided = false ;
160- $ request = $ this ->getRequest ();
161145 $ authenticatorResponse = $ request ->getParsedBodyParam ('webauthn_creation_response ' , '' );
162146 if ($ authenticatorResponse === '' || ! isset ($ _SESSION ['WebAuthnCredentialCreationOptions ' ])) {
163147 return false ;
0 commit comments