94 $this->_key = base64_decode(
$key);
119 $parameters =
"id=" . $this->_id .
"&otp=" . $token;
121 if($this->_key <>
"") {
122 $signature = base64_encode(hash_hmac(
'sha1', $parameters, $this->_key,
true));
123 $parameters .=
'&h=' . $signature;
126 $url =
"https://api.yubico.com/wsapi/verify?" . $parameters;
128 $responseMsg = file_get_contents(
$url);
130 if(!preg_match(
"/status=([a-zA-Z0-9_]+)/", $responseMsg,
$out)) {
131 throw new Exception(
'Could not parse response');
137 if($this->_key <>
"") {
138 $rows = explode(
"\r\n", $responseMsg);
141 $val = preg_replace(
'/=/',
'#', $val, 1);
142 $row = explode(
"#", $val);
147 $checksignature = base64_encode(hash_hmac(
'sha1', $check, $this->_key,
true));
150 throw new Exception(
'Checked Signature failed');
154 if ($status !=
'OK') {
155 throw new Exception(
'Status was not OK: ' . $status);
verify($token)
Verify Yubico OTP.
if(!array_key_exists('StateId', $_REQUEST)) $id
getLastResponse()
Return the last data received from the server, if any.
__construct($id, $key='')
Constructor.