Improved FIDO U2F error reporting
Signed-off-by: Michal Čihař <michal@cihar.com>
This commit is contained in:
parent
e67ea08eae
commit
2af38a3de8
@ -13,6 +13,7 @@ use PhpMyAdmin\SecondFactor;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Plugins\SecondFactorPlugin;
|
||||
use Samyoul\U2F\U2FServer\U2FServer;
|
||||
use Samyoul\U2F\U2FServer\U2FException;
|
||||
|
||||
/**
|
||||
* Hardware key based second factor
|
||||
@ -105,7 +106,8 @@ class Key extends SecondFactorPlugin
|
||||
$this->_second->config['settings']['registrations'][$authentication->index]['counter'] = $authentication->counter;
|
||||
$this->_second->save();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
} catch (U2FException $e) {
|
||||
$this->_message = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -188,7 +190,8 @@ class Key extends SecondFactorPlugin
|
||||
'counter' => $registration->getCounter(),
|
||||
];
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
} catch (U2FException $e) {
|
||||
$this->_message = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,6 +34,11 @@ class SecondFactorPlugin
|
||||
*/
|
||||
protected $_provided;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $_message;
|
||||
|
||||
/**
|
||||
* Creates object
|
||||
*
|
||||
@ -43,6 +48,7 @@ class SecondFactorPlugin
|
||||
{
|
||||
$this->_second = $second;
|
||||
$this->_provided = false;
|
||||
$this->_message = '';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,6 +59,11 @@ class SecondFactorPlugin
|
||||
public function getError()
|
||||
{
|
||||
if ($this->_provided) {
|
||||
if (!empty($this->_message)) {
|
||||
return Message::rawError(
|
||||
sprintf(__('Two-factor authentication failed: %s'), $this->_message)
|
||||
)->getDisplay();
|
||||
}
|
||||
return Message::rawError(
|
||||
__('Two-factor authentication failed.')
|
||||
)->getDisplay();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user