File tree Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,9 @@ public function getJsLayout()
8181 throw new LocalizedException (__ ('User session not found. ' ));
8282 }
8383 $ username = $ user ->getUserName ();
84- $ prompt_uri = $ this ->duoSecurity ->initiateAuth ($ username , $ this ->getFormKey ().DuoSecurity::AUTH_SUFFIX );
84+ $ state = $ this ->duoSecurity ->generateDuoState ();
85+ $ this ->session ->setDuoState ($ state );
86+ $ prompt_uri = $ this ->duoSecurity ->initiateAuth ($ username , $ state );
8587 $ this ->jsLayout ['components ' ]['tfa-auth ' ]['authUrl ' ] = $ prompt_uri ;
8688 return parent ::getJsLayout ();
8789 }
Original file line number Diff line number Diff line change 66
77namespace Magento \TwoFactorAuth \Helper ;
88
9- use Magento \Framework \ Data \ Form \ FormKey ;
9+ use Magento \Backend \ Model \ Auth \ Session ;
1010
1111class Data
1212{
1313 /**
14- * @var FormKey
14+ * @var Session
1515 */
16- private $ formKey ;
16+ private $ session ;
1717
1818 /**
19- * @param FormKey $formKey
19+ * @param Session $session
2020 */
21- public function __construct (FormKey $ formKey )
21+ public function __construct (Session $ session )
2222 {
23- $ this ->formKey = $ formKey ;
23+ $ this ->session = $ session ;
2424 }
2525
2626 /**
2727 * Get form key
2828 *
2929 * @return string
3030 */
31- public function getFormKey (): string
31+ public function getSavedDuoState (): string
3232 {
33- return $ this ->formKey -> getFormKey ();
33+ return $ this ->session -> getDuoState ();
3434 }
3535}
Original file line number Diff line number Diff line change @@ -221,15 +221,17 @@ private function getSkey(): string
221221 */
222222 public function verify (UserInterface $ user , DataObject $ request ): bool
223223 {
224- $ savedState = $ request ->getData ('state ' );
224+ $ state = $ request ->getData ('state ' );
225225 $ duoCode = $ request ->getData ('duo_code ' );
226226 $ username = $ user ->getUserName ();
227227
228+ $ savedState = $ this ->helper ->getSavedDuoState ();
229+
228230 if (empty ($ savedState ) || empty ($ username )) {
229231 return false ;
230232 }
231233
232- if ($ this -> helper -> getFormKey () . self :: AUTH_SUFFIX != $ savedState ) {
234+ if ($ state != $ savedState ) {
233235 return false ;
234236 }
235237
@@ -292,6 +294,14 @@ public function healthCheck(): void
292294 $ this ->client ->healthCheck ();
293295 }
294296
297+ /**
298+ * @return string
299+ */
300+ public function generateDuoState () : string
301+ {
302+ return $ this ->client ->generateState ();
303+ }
304+
295305 /**
296306 * Enroll a new user for Duo Auth API.
297307 *
You can’t perform that action at this time.
0 commit comments