1212use Magento \Framework \DataObject ;
1313use Magento \Framework \Data \Form \FormKey ;
1414use Magento \Framework \Encryption \EncryptorInterface ;
15- use Magento \Framework \Session \SessionManagerInterface ;
1615use Magento \Framework \UrlInterface ;
1716use Magento \User \Api \Data \UserInterface ;
1817use Magento \TwoFactorAuth \Api \EngineInterface ;
2120
2221/**
2322 * Duo Security engine
24- * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2523 */
2624class DuoSecurity implements EngineInterface
2725{
@@ -110,17 +108,11 @@ class DuoSecurity implements EngineInterface
110108 */
111109 private $ formKey ;
112110
113- /**
114- * @var SessionManagerInterface
115- */
116- private $ session ;
117-
118111 /**
119112 * @param ScopeConfigInterface $scopeConfig
120113 * @param EncryptorInterface $encryptor
121114 * @param UrlInterface $urlBuilder
122115 * @param FormKey $formKey
123- * @param SessionManagerInterface $session
124116 * @param Client|null $client
125117 * @param DuoAuth|null $duoAuth
126118 * @throws \Duo\DuoUniversal\DuoException
@@ -130,15 +122,13 @@ public function __construct(
130122 EncryptorInterface $ encryptor ,
131123 UrlInterface $ urlBuilder ,
132124 FormKey $ formKey ,
133- SessionManagerInterface $ session ,
134125 Client $ client = null ,
135126 DuoAuth $ duoAuth = null
136127 ) {
137128 $ this ->scopeConfig = $ scopeConfig ;
138129 $ this ->encryptor = $ encryptor ;
139130 $ this ->urlBuilder = $ urlBuilder ;
140131 $ this ->formKey = $ formKey ;
141- $ this ->session = $ session ;
142132 $ this ->client = $ client ?? new Client (
143133 $ this ->getClientId (),
144134 $ this ->getClientSecret (),
@@ -239,9 +229,8 @@ public function verify(UserInterface $user, DataObject $request): bool
239229 }
240230
241231 try {
232+ // Not saving token as this is just for verificaiton purpose
242233 $ decoded_token = $ this ->client ->exchangeAuthorizationCodeFor2FAResult ($ duoCode , $ username );
243- // Save the token in the session for later use
244- $ this ->session ->setData ('duo_token ' , $ decoded_token );
245234 } catch (LocalizedException $ e ) {
246235 return false ;
247236 }
0 commit comments