Properly update FIDO U2F counter on login
Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
c64e52c3c0
commit
e67ea08eae
@ -47,12 +47,13 @@ class Key extends SecondFactorPlugin
|
||||
public function getRegistrations()
|
||||
{
|
||||
$result = [];
|
||||
foreach ($this->_second->config['settings']['registrations'] as $data) {
|
||||
foreach ($this->_second->config['settings']['registrations'] as $index => $data) {
|
||||
$reg = new \StdClass;
|
||||
$reg->keyHandle = $data['keyHandle'];
|
||||
$reg->publicKey = $data['publicKey'];
|
||||
$reg->certificate = $data['certificate'];
|
||||
$reg->counter = $data['counter'];
|
||||
$reg->index = $index;
|
||||
$result[] = $reg;
|
||||
}
|
||||
return $result;
|
||||
@ -101,7 +102,8 @@ class Key extends SecondFactorPlugin
|
||||
$this->getRegistrations(),
|
||||
$response
|
||||
);
|
||||
// TODO: Store counter
|
||||
$this->_second->config['settings']['registrations'][$authentication->index]['counter'] = $authentication->counter;
|
||||
$this->_second->save();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
|
||||
@ -179,6 +179,16 @@ class SecondFactor
|
||||
return $this->_backend->getError() . $this->_backend->setup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves current configuration.
|
||||
*
|
||||
* @return true|PhpMyAdmin\Message
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
return UserPreferences::persistOption('2fa', $this->config, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes second factor settings
|
||||
*
|
||||
@ -209,7 +219,7 @@ class SecondFactor
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$result = UserPreferences::persistOption('2fa', $this->config, null);
|
||||
$result = $this->save();
|
||||
if ($result !== true) {
|
||||
$result->display();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user