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;
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);
140 foreach (
$rows as $val) {
142 $val = preg_replace(
'/=/',
'#', $val, 1);
143 $row = explode(
"#", $val);
148 $checksignature = base64_encode(hash_hmac(
'sha1', $check, $this->_key,
true));
151 throw new Exception(
'Checked Signature failed');
155 if ($status !=
'OK') {
156 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.
static fetch($url, $context=array(), $getHeaders=false)
Helper function to retrieve a file or URL with proxy support, also supporting proxy basic authorizati...
__construct($id, $key='')
Constructor.