Yubico Forum
https://forum.yubico.com/

Super simple Yubikey server access with PHP - is this wrong?
https://forum.yubico.com/viewtopic.php?f=3&t=700
Page 1 of 1

Author:  Rik [ Tue Aug 23, 2011 9:26 am ]
Post subject:  Super simple Yubikey server access with PHP - is this wrong?

Ive been reading a lot about the Yubikey the last week and found a PDF slideshow that listed a URL accessing the API in a simple manner so I produced this PHP code using it :

Code:

<?php

$otp      = "cccccccvfckdvfblijjfctibtlrbejjddjiligvbkevu";   // OTP from Yubikey
$yubikeyid   = substr($otp, 0, 12);               // Grab first 12 chars for unique userid

$apiserver1 = "https://api.yubico.com/wsapi/verify?id=1&otp=";      // Yubico API server

$serverresponse = file_get_contents($apiserver1 . $otp);      // Access server using concat string of URL plus OTP
$pos = strpos($serverresponse, "status=OK");            // Check the server response for "status=ok"

if ($pos === false) {                     // If the string is not returned there is an error
    echo "$yubikeyid - Invalid<BR><BR> - $serverresponse";
} else {                        // Else the string was found and the Yubikey is valid, now check the userid etc...
    echo "$yubikeyid -  OK<BR><BR> - $serverresponse";
}

?>



Is this too simplistic / a bad idea?

Thanks
R.

Author:  netagence [ Tue Dec 06, 2011 11:06 am ]
Post subject:  Re: Super simple Yubikey server access with PHP - is this wr

Did you manage to make that example work ?

Regards.

Author:  Fredrik-at-Yubico [ Wed Dec 07, 2011 2:51 pm ]
Post subject:  Re: Super simple Yubikey server access with PHP - is this wr

I'd recommend using the PHP validation client. See the ReadMe for a super-simple example.

http://code.google.com/p/php-yubico/

/Fredrik

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/