Yubico / php-u2flib-server

(OBSOLETE) U2F library in PHP
https://developers.yubico.com/php-u2flib-server/
BSD 2-Clause "Simplified" License
288 stars 68 forks source link

missing id in castObjectToRegistration function #72

Closed Nexulo closed 5 years ago

Nexulo commented 5 years ago

Hello together,

is it possible that it should have also a handler for the id property in the castObjectToRegistration function in the file "U2F.php" ? So it will also return the id of the matching key, which will be good for database storing. Or i'm handling that wrong?

Thank you and best regards, Maisen20

klali commented 5 years ago

The Registration class only has the properties keyHandle, publicKey, certificate & counter. No id property there to handle.

Not sure what you mean, anything additional you use for storing the registration will have to build on top of what php-u2flib-server does.

Nexulo commented 5 years ago

Okay i try to explain what i mean.

In the PDO example on line 186 there's following code:

$reg = $u2f->doAuthenticate(json_decode($_SESSION['authReq']), getRegs($user->id), json_decode($_POST['authenticate2']));

And on the next line there is the code: updateReg($reg);

And the update function: function updateReg($reg) { global $pdo; $upd = $pdo->prepare("update registrations set counter = ? where id = ?"); $upd->execute(array($reg->counter, $reg->id)); }

The function updateReg will update the entry in the database and set the counter to the same value like the yubikey has. But the $reg parameter, which will be used in the updateReg function, has/gets no id-property from the doAuthenticate function.

I hope you understand what i mean... So that's only a "issue" on the example, or isn't it?

klali commented 5 years ago

Ah, I see what you mean. The example code is a bit outdated and will have to use the keyHandle to find it's way in that table.