save binary credential data as compact base64 string

Cette révision appartient à :
Daniel Seifert 2022-11-02 08:23:41 +01:00
Parent 521d8e9e6a
révision f62c542d10
Signé par: DanielS
ID de la clé GPG: 8A7C4C6ED1915C6F
3 fichiers modifiés avec 9 ajouts et 9 suppressions

Voir le fichier

@ -54,13 +54,13 @@ class PublicKeyCredential extends BaseModel
public function setCredentialId($credentialId)
{
$this->assign([
'credentialid' => bin2hex($credentialId)
'credentialid' => base64_encode($credentialId)
]);
}
public function getCredentialId()
{
return hex2bin($this->__get($this->_getFieldLongName('credentialid'))->rawValue);
return base64_decode($this->__get($this->_getFieldLongName('credentialid'))->rawValue);
}
public function setUserId($userId)
@ -78,13 +78,13 @@ class PublicKeyCredential extends BaseModel
public function setCredential($credential)
{
$this->assign([
'credential' => bin2hex(serialize($credential))
'credential' => base64_encode(serialize($credential))
]);
}
public function getCredential()
{
return unserialize(hex2bin($this->__get($this->_getFieldLongName('credential'))->rawValue));
return unserialize(base64_decode($this->__get($this->_getFieldLongName('credential'))->rawValue));
}
/**
@ -134,7 +134,7 @@ class PublicKeyCredential extends BaseModel
$qb->expr()->and(
$qb->expr()->eq(
'credentialid',
$qb->createNamedParameter(bin2hex($publicKeyCredentialId))
$qb->createNamedParameter(base64_encode($publicKeyCredentialId))
),
$qb->expr()->eq(
'oxshopid',

Voir le fichier

@ -58,7 +58,7 @@ class PublicKeyCredentialList extends ListModel implements PublicKeyCredentialSo
$qb->expr()->and(
$qb->expr()->eq(
'credentialid',
$qb->createNamedParameter(bin2hex($publicKeyCredentialId))
$qb->createNamedParameter(base64_encode($publicKeyCredentialId))
),
$qb->expr()->eq(
'oxshopid',
@ -72,7 +72,7 @@ class PublicKeyCredentialList extends ListModel implements PublicKeyCredentialSo
return null;
}
$credential = unserialize(hex2bin($credential));
$credential = unserialize(base64_decode($credential));
return $credential instanceof PublicKeyCredentialSource ? $credential : null;
}
@ -106,7 +106,7 @@ class PublicKeyCredentialList extends ListModel implements PublicKeyCredentialSo
// generate decoded credentials list
return array_map(function (array $fields) {
return unserialize(hex2bin($fields['credential']));
return unserialize(base64_decode($fields['credential']));
}, $qb->execute()->fetchAllAssociative());
}

Voir le fichier

@ -45,7 +45,7 @@ class Events
`OXUSERID` char(32) NOT NULL,
`OXSHOPID` int(11) NOT NULL,
`NAME` varchar(100) NOT NULL,
`CREDENTIALID` char(200) NOT NULL,
`CREDENTIALID` char(100) NOT NULL,
`CREDENTIAL` varchar(2000) NOT NULL,
`OXTIMESTAMP` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`OXID`),