そこで、このbrowserid.orgを見つけ、次に [browserid.org/developers] を見つけて、この新しい認証方法である browserID を試してみることにしました。私が見つけることができた唯一の半公式の例 ( browserid_favbeer_example ) を掘り下げて、3 つの簡単な手順のページを行ったり来たりした後、私はまだ困惑しています。私は少し調べて、1つを見つけました。JavaScriptの実装は(今のところ)簡単に悪用できます.2つは、非常に素晴らしい仲間からのものです。以下の例です。それが欠けていることに最初に気づいたのはログアウトでした。誰かが私がログアウトを完了するのを手伝ってくれるほど親切であることができれば、それは大歓迎です.
<?php
/*
* Simple implementation of Mozilla BrowserID (see https://browserid.org/)
* Author : Guillaume <guillaume@atto.be>
*/
/*
* Usage :
*
$browserid = new BrowserID('mywebserver.com', $_POST['assertion']);
if($browserid->verify_assertion())
{
echo('Welcome, your email is '.$browserid->get_email());
}
*/
class BrowserID
{
private $audience;
private $assertion;
private $email;
private $validity;
private $issuer;
private function post_request($url, $data)
{
$params = array('http' => array('method' => 'POST', 'content' => $data));
return stream_get_contents($fp);
}
else
{
return FALSE;
}
}
public function BrowserID($audience, $assertion)
{
$this->audience = $audience;
$this->assertion = $assertion;
}
/*
* Send the assertion to the browserid.org server (this must be over HTTPS)
* The response is read to determine is the assertion is authentic
*/
public function verify_assertion()
{
if(isset($result['status']) && $result['status'] == 'okay')
{
$this->email = $result['email'];
$this->validity = $result['valid-until'];
$this->issuer = $result['issuer'];
return true;
}
else
{
return false;
}
}
public function get_email()
{
return $this->email;
}
public function get_validity()
return $this->email;
}
public function get_validity()
* Usage :
*
$browserid = new BrowserID('mywebserver.com', $_POST['assertion']);
if($browserid->verify_assertion())
{
echo('Welcome, your email is '.$browserid->get_email());
}
*/
class BrowserID
{
private $audience;
private $assertion;
private $email;
private $validity;
private $issuer;
private function post_request($url, $data)
{
$params = array('http' => array('method' => 'POST', 'content' => $data));
return stream_get_contents($fp);
}
else
{
return FALSE;
}
}
public function BrowserID($audience, $assertion)
{
$this->audience = $audience;
$this->assertion = $assertion;
}
/*
* Send the assertion to the browserid.org server (this must be over HTTPS)
* The response is read to determine is the assertion is authentic
*/
public function verify_assertion()
{
if(isset($result['status']) && $result['status'] == 'okay')
{
$this->email = $result['email'];
$this->validity = $result['valid-until'];
$this->issuer = $result['issuer'];
return true;
}
else
{
return false;
}
}
public function get_email()
{
return $this->email;
}
public function get_validity()
{
return $this->validity;
}
public function get_issuer()
{
return $this->issuer;
}
}// end class BrowserID
$browserid = new BrowserID($_SERVER['HTTP_HOST'], $_POST['assertion']);
if($browserid->verify_assertion())
{
echo('Welcome '.$browserid->get_email());
}
else
{
echo('Identification failure');
}
?>