add logger, improve error messages
This commit is contained in:
@ -18,6 +18,7 @@ namespace D3\Webauthn\Application\Controller\Admin;
|
|||||||
use D3\Webauthn\Application\Model\Credential\PublicKeyCredential;
|
use D3\Webauthn\Application\Model\Credential\PublicKeyCredential;
|
||||||
use D3\Webauthn\Application\Model\Credential\PublicKeyCredentialList;
|
use D3\Webauthn\Application\Model\Credential\PublicKeyCredentialList;
|
||||||
use D3\Webauthn\Application\Model\Webauthn;
|
use D3\Webauthn\Application\Model\Webauthn;
|
||||||
|
use D3\Webauthn\Application\Model\WebauthnConf;
|
||||||
use D3\Webauthn\Application\Model\WebauthnErrors;
|
use D3\Webauthn\Application\Model\WebauthnErrors;
|
||||||
use D3\Webauthn\Application\Model\WebauthnException;
|
use D3\Webauthn\Application\Model\WebauthnException;
|
||||||
use D3\Webauthn\Modules\Application\Model\d3_User_Webauthn;
|
use D3\Webauthn\Modules\Application\Model\d3_User_Webauthn;
|
||||||
@ -74,7 +75,7 @@ class d3user_webauthn extends AdminDetailsController
|
|||||||
if (strlen(Registry::getRequest()->getRequestEscapedParameter('error'))) {
|
if (strlen(Registry::getRequest()->getRequestEscapedParameter('error'))) {
|
||||||
$errors = oxNew(WebauthnErrors::class);
|
$errors = oxNew(WebauthnErrors::class);
|
||||||
Registry::getUtilsView()->addErrorToDisplay(
|
Registry::getUtilsView()->addErrorToDisplay(
|
||||||
$errors->translateError(Registry::getRequest()->getRequestEscapedParameter('error'))
|
$errors->translateError(Registry::getRequest()->getRequestEscapedParameter('error'), WebauthnConf::TYPE_CREATE)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ class d3webauthnadminlogin extends AdminController
|
|||||||
$errors = oxNew(WebauthnErrors::class);
|
$errors = oxNew(WebauthnErrors::class);
|
||||||
throw oxNew(
|
throw oxNew(
|
||||||
StandardException::class,
|
StandardException::class,
|
||||||
$errors->translateError(Registry::getRequest()->getRequestEscapedParameter('error'))
|
$errors->translateError(Registry::getRequest()->getRequestEscapedParameter('error'), WebauthnConf::TYPE_GET)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ namespace D3\Webauthn\Application\Controller;
|
|||||||
use D3\Webauthn\Application\Model\Credential\PublicKeyCredential;
|
use D3\Webauthn\Application\Model\Credential\PublicKeyCredential;
|
||||||
use D3\Webauthn\Application\Model\Credential\PublicKeyCredentialList;
|
use D3\Webauthn\Application\Model\Credential\PublicKeyCredentialList;
|
||||||
use D3\Webauthn\Application\Model\Webauthn;
|
use D3\Webauthn\Application\Model\Webauthn;
|
||||||
|
use D3\Webauthn\Application\Model\WebauthnConf;
|
||||||
use D3\Webauthn\Application\Model\WebauthnErrors;
|
use D3\Webauthn\Application\Model\WebauthnErrors;
|
||||||
use D3\Webauthn\Application\Model\WebauthnException;
|
use D3\Webauthn\Application\Model\WebauthnException;
|
||||||
use OxidEsales\Eshop\Application\Controller\AccountController;
|
use OxidEsales\Eshop\Application\Controller\AccountController;
|
||||||
@ -91,7 +92,7 @@ class d3_account_webauthn extends AccountController
|
|||||||
if (strlen(Registry::getRequest()->getRequestEscapedParameter('error'))) {
|
if (strlen(Registry::getRequest()->getRequestEscapedParameter('error'))) {
|
||||||
$errors = oxNew(WebauthnErrors::class);
|
$errors = oxNew(WebauthnErrors::class);
|
||||||
Registry::getUtilsView()->addErrorToDisplay(
|
Registry::getUtilsView()->addErrorToDisplay(
|
||||||
$errors->translateError(Registry::getRequest()->getRequestEscapedParameter('error'))
|
$errors->translateError(Registry::getRequest()->getRequestEscapedParameter('error'), WebauthnConf::TYPE_CREATE)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +102,8 @@ class d3webauthnlogin extends FrontendController
|
|||||||
if (strlen(Registry::getRequest()->getRequestEscapedParameter('error'))) {
|
if (strlen(Registry::getRequest()->getRequestEscapedParameter('error'))) {
|
||||||
$errors = oxNew(WebauthnErrors::class);
|
$errors = oxNew(WebauthnErrors::class);
|
||||||
throw oxNew(
|
throw oxNew(
|
||||||
StandardException::class,
|
WebauthnException::class,
|
||||||
$errors->translateError(Registry::getRequest()->getRequestEscapedParameter('error'))
|
$errors->translateError(Registry::getRequest()->getRequestEscapedParameter('error'), WebauthnConf::TYPE_GET)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,9 @@ class Webauthn
|
|||||||
public function getServer(): Server
|
public function getServer(): Server
|
||||||
{
|
{
|
||||||
$rpEntity = oxNew(RelyingPartyEntity::class);
|
$rpEntity = oxNew(RelyingPartyEntity::class);
|
||||||
return oxNew(Server::class, $rpEntity, oxNew(PublicKeyCredentialList::class));
|
$server = oxNew(Server::class, $rpEntity, oxNew(PublicKeyCredentialList::class));
|
||||||
|
$server->setLogger(Registry::getLogger());
|
||||||
|
return $server;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveAuthn(string $credential, string $keyName = null)
|
public function saveAuthn(string $credential, string $keyName = null)
|
||||||
|
@ -25,4 +25,7 @@ class WebauthnConf
|
|||||||
public const WEBAUTHN_SESSION_NAVFORMPARAMS = 'd3webauthnNavFormParams'; // no usage
|
public const WEBAUTHN_SESSION_NAVFORMPARAMS = 'd3webauthnNavFormParams'; // no usage
|
||||||
|
|
||||||
public const GLOBAL_SWITCH = 'blDisableWebauthnGlobally';
|
public const GLOBAL_SWITCH = 'blDisableWebauthnGlobally';
|
||||||
|
|
||||||
|
public const TYPE_CREATE = 'TYPECREATE';
|
||||||
|
public const TYPE_GET = 'TYPEGET';
|
||||||
}
|
}
|
@ -12,20 +12,21 @@ class WebauthnErrors
|
|||||||
public const CONSTRAINT = 'constrainterror';
|
public const CONSTRAINT = 'constrainterror';
|
||||||
public const NOTSUPPORTED = 'notsupporederror';
|
public const NOTSUPPORTED = 'notsupporederror';
|
||||||
public const UNKNOWN = 'unknownerror';
|
public const UNKNOWN = 'unknownerror';
|
||||||
public const NOPUBKEYSUPPORT= 'd3nopublickeycredentialsupportederror';
|
public const NOPUBKEYSUPPORT = 'd3nopublickeycredentialsupportederror';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://webidl.spec.whatwg.org/
|
|
||||||
* @param $msg
|
* @param $msg
|
||||||
* @return mixed|string
|
* @param null $type
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function translateError($msg)
|
public function translateError($msg, $type = null): string
|
||||||
{
|
{
|
||||||
$lang = Registry::getLang();
|
$lang = Registry::getLang();
|
||||||
|
$type = $type ? '_'.$type : null;
|
||||||
|
|
||||||
switch ($this->getErrIdFromMessage($msg)) {
|
switch ($this->getErrIdFromMessage($msg)) {
|
||||||
case self::INVALIDSTATE:
|
case self::INVALIDSTATE:
|
||||||
return $lang->translateString('D3_WEBAUTHN_ERR_INVALIDSTATE', null, true);
|
return $lang->translateString('D3_WEBAUTHN_ERR_INVALIDSTATE'.$type, null, true);
|
||||||
case self::NOTALLWED:
|
case self::NOTALLWED:
|
||||||
return $lang->translateString('D3_WEBAUTHN_ERR_NOTALLOWED', null, true);
|
return $lang->translateString('D3_WEBAUTHN_ERR_NOTALLOWED', null, true);
|
||||||
case self::ABORT:
|
case self::ABORT:
|
||||||
@ -38,10 +39,9 @@ class WebauthnErrors
|
|||||||
return $lang->translateString('D3_WEBAUTHN_ERR_UNKNOWN', null, true);
|
return $lang->translateString('D3_WEBAUTHN_ERR_UNKNOWN', null, true);
|
||||||
case self::NOPUBKEYSUPPORT:
|
case self::NOPUBKEYSUPPORT:
|
||||||
return $lang->translateString('D3_WEBAUTHN_ERR_NOPUBKEYSUPPORT', null, true);
|
return $lang->translateString('D3_WEBAUTHN_ERR_NOPUBKEYSUPPORT', null, true);
|
||||||
// ToDo: translate messages from Webauthn package like "The credential ID is invalid."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $msg;
|
return $lang->translateString('D3_WEBAUTHN_ERR_TECHNICALERROR', null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,6 +8,7 @@ $sLangName = 'Deutsch';
|
|||||||
$aLang = array(
|
$aLang = array(
|
||||||
'charset' => 'UTF-8',
|
'charset' => 'UTF-8',
|
||||||
|
|
||||||
|
'PAGE_TITLE_D3WEBAUTHNLOGIN' => 'Passwortloses Anmelden',
|
||||||
'D3_WEBAUTHN_ACCOUNT' => 'Sicherheitsschlüssel',
|
'D3_WEBAUTHN_ACCOUNT' => 'Sicherheitsschlüssel',
|
||||||
'D3_WEBAUTHN_ACC_REGISTERNEW' => 'neue Registrierung erstellen',
|
'D3_WEBAUTHN_ACC_REGISTERNEW' => 'neue Registrierung erstellen',
|
||||||
'D3_WEBAUTHN_ACC_ADDKEY' => 'Sicherheitsschlüssel hinzufügen',
|
'D3_WEBAUTHN_ACC_ADDKEY' => 'Sicherheitsschlüssel hinzufügen',
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use D3\Webauthn\Application\Model\WebauthnConf;
|
||||||
|
|
||||||
$sLangName = "Deutsch";
|
$sLangName = "Deutsch";
|
||||||
|
|
||||||
$aLang = [
|
$aLang = [
|
||||||
@ -39,13 +41,15 @@ $aLang = [
|
|||||||
'D3_WEBAUTHN_REGISTEREDKEYS' => 'registrierte Schlüssel',
|
'D3_WEBAUTHN_REGISTEREDKEYS' => 'registrierte Schlüssel',
|
||||||
|
|
||||||
'D3_WEBAUTHN_ERR_UNSECURECONNECTION' => 'Die Verwendung von Sicherheitsschlüsseln ist nur bei gesicherten oder lokalen Verbindungen (https) möglich.',
|
'D3_WEBAUTHN_ERR_UNSECURECONNECTION' => 'Die Verwendung von Sicherheitsschlüsseln ist nur bei gesicherten oder lokalen Verbindungen (https) möglich.',
|
||||||
'D3_WEBAUTHN_ERR_INVALIDSTATE' => 'Der Schlüssel vom Token kann nicht oder nicht mehr verwendet werden. Möglicherweise wurde dieser in Ihrem Konto schon einmal gespeichert.',
|
'D3_WEBAUTHN_ERR_INVALIDSTATE_'.WebauthnConf::TYPE_CREATE => 'Der Schlüssel vom Token kann nicht oder nicht mehr verwendet werden. Möglicherweise wurde dieser in Ihrem Konto schon einmal gespeichert.',
|
||||||
|
'D3_WEBAUTHN_ERR_INVALIDSTATE_'.WebauthnConf::TYPE_GET => 'Der Schlüssel kann nicht validiert werden.',
|
||||||
'D3_WEBAUTHN_ERR_NOTALLOWED' => 'Die Anfrage wurde vom Browser oder der Plattform nicht zugelassen. Möglicherweise fehlen Berechtigungen oder die Zeit ist abgelaufen.',
|
'D3_WEBAUTHN_ERR_NOTALLOWED' => 'Die Anfrage wurde vom Browser oder der Plattform nicht zugelassen. Möglicherweise fehlen Berechtigungen oder die Zeit ist abgelaufen.',
|
||||||
'D3_WEBAUTHN_ERR_ABORT' => 'Die Aktion wurde vom Browser oder der Plattform abgebrochen.',
|
'D3_WEBAUTHN_ERR_ABORT' => 'Die Aktion wurde vom Browser oder der Plattform abgebrochen.',
|
||||||
'D3_WEBAUTHN_ERR_CONSTRAINT' => 'Die Aktion konnte vom authentisierenden Gerät nicht durchgeführt werden.',
|
'D3_WEBAUTHN_ERR_CONSTRAINT' => 'Die Aktion konnte vom authentisierenden Gerät nicht durchgeführt werden.',
|
||||||
'D3_WEBAUTHN_ERR_NOTSUPPORTED' => 'Die Aktion wird nicht unterstützt.',
|
'D3_WEBAUTHN_ERR_NOTSUPPORTED' => 'Die Aktion wird nicht unterstützt.',
|
||||||
'D3_WEBAUTHN_ERR_UNKNOWN' => 'Die Aktion wurde wegen eines unbekannten Fehlers abgebrochen.',
|
'D3_WEBAUTHN_ERR_UNKNOWN' => 'Die Aktion wurde wegen eines unbekannten Fehlers abgebrochen.',
|
||||||
'D3_WEBAUTHN_ERR_NOPUBKEYSUPPORT' => 'Ihr Browser unterstützt die Verwendung von Hardwareschlüsseln leider nicht.',
|
'D3_WEBAUTHN_ERR_NOPUBKEYSUPPORT' => 'Ihr Browser unterstützt die Verwendung von Hardwareschlüsseln leider nicht.',
|
||||||
|
'D3_WEBAUTHN_ERR_TECHNICALERROR' => 'Beim Prüfen der Zugangsdaten ist ein technischer Fehler aufgetreten.',
|
||||||
|
|
||||||
'D3_WEBAUTHN_ERR_LOGINPROHIBITED' => 'Die Anmeldung mit Sicherheitsschlüssel ist aus technischen Gründen derzeit leider nicht möglich. Bitte verwenden Sie statt dessen Ihr Passwort.',
|
'D3_WEBAUTHN_ERR_LOGINPROHIBITED' => 'Die Anmeldung mit Sicherheitsschlüssel ist aus technischen Gründen derzeit leider nicht möglich. Bitte verwenden Sie statt dessen Ihr Passwort.',
|
||||||
];
|
];
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
* @link http://www.oxidmodule.com
|
* @link http://www.oxidmodule.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use D3\Webauthn\Application\Model\WebauthnConf;
|
||||||
|
|
||||||
$sLangName = "English";
|
$sLangName = "English";
|
||||||
|
|
||||||
$aLang = [
|
$aLang = [
|
||||||
@ -39,13 +41,15 @@ $aLang = [
|
|||||||
'D3_WEBAUTHN_REGISTEREDKEYS' => 'registered keys',
|
'D3_WEBAUTHN_REGISTEREDKEYS' => 'registered keys',
|
||||||
|
|
||||||
'D3_WEBAUTHN_ERR_UNSECURECONNECTION' => 'The use of security keys is only possible with secured or local connections (https).',
|
'D3_WEBAUTHN_ERR_UNSECURECONNECTION' => 'The use of security keys is only possible with secured or local connections (https).',
|
||||||
'D3_WEBAUTHN_ERR_INVALIDSTATE' => 'The key from the token cannot be used or can no longer be used. It may have been stored in your account before.',
|
'D3_WEBAUTHN_ERR_INVALIDSTATE_'.WebauthnConf::TYPE_CREATE => 'The key from the token cannot be used or can no longer be used. It may have been stored in your account before.',
|
||||||
|
'D3_WEBAUTHN_ERR_INVALIDSTATE_'.WebauthnConf::TYPE_GET => 'The key cannot be validated.',
|
||||||
'D3_WEBAUTHN_ERR_NOTALLOWED' => 'The request was not allowed by the browser or the platform. Possibly permissions are missing or the time has expired.',
|
'D3_WEBAUTHN_ERR_NOTALLOWED' => 'The request was not allowed by the browser or the platform. Possibly permissions are missing or the time has expired.',
|
||||||
'D3_WEBAUTHN_ERR_ABORT' => 'The action was aborted by the browser or the platform.',
|
'D3_WEBAUTHN_ERR_ABORT' => 'The action was aborted by the browser or the platform.',
|
||||||
'D3_WEBAUTHN_ERR_CONSTRAINT' => 'The action could not be performed by the authenticating device.',
|
'D3_WEBAUTHN_ERR_CONSTRAINT' => 'The action could not be performed by the authenticating device.',
|
||||||
'D3_WEBAUTHN_ERR_NOTSUPPORTED' => 'The action is not supported.',
|
'D3_WEBAUTHN_ERR_NOTSUPPORTED' => 'The action is not supported.',
|
||||||
'D3_WEBAUTHN_ERR_UNKNOWN' => 'The action was cancelled due to an unknown error.',
|
'D3_WEBAUTHN_ERR_UNKNOWN' => 'The action was cancelled due to an unknown error.',
|
||||||
'D3_WEBAUTHN_ERR_NOPUBKEYSUPPORT' => 'Unfortunately, your browser does not support the use of hardware keys.',
|
'D3_WEBAUTHN_ERR_NOPUBKEYSUPPORT' => 'Unfortunately, your browser does not support the use of hardware keys.',
|
||||||
|
'D3_WEBAUTHN_ERR_TECHNICALERROR' => 'A technical error occurred while checking the access data.',
|
||||||
|
|
||||||
'D3_WEBAUTHN_ERR_LOGINPROHIBITED' => 'Unfortunately, logging in with a security key is currently not possible for technical reasons. Please use your password instead.',
|
'D3_WEBAUTHN_ERR_LOGINPROHIBITED' => 'Unfortunately, logging in with a security key is currently not possible for technical reasons. Please use your password instead.',
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user