Open ID Authentication简介
OpenID 身份只是个指向一些 web 页面的 HTTP URL,在 URL 中带有适当的用户和特别标签的信息,在标签中描述使用哪个服务器和提交哪个身份到那里。关于 OpenID 请参考 » OpenID 官方网站 .
细节
作为
然而和其它
下面的例子展示
<?php
$status = "";
$auth = Zend_Auth::getInstance();
if ((isset($_POST['openid_action']) &&
$_POST['openid_action'] == "login" &&
!empty($_POST['openid_identifier'])) ||
isset($_GET['openid_mode']) ||
isset($_POST['openid_mode'])) {
$result = $auth->authenticate(
new Zend_Auth_Adapter_OpenId(@$_POST['openid_identifier']));
if ($result->isValid()) {
$status = "You are logged in as "
. $auth->getIdentity()
. "<br>\n";
} else {
$auth->clearIdentity();
foreach ($result->getMessages() as $message) {
$status .= "$message<br>\n";
}
}
} else if ($auth->hasIdentity()) {
if (isset($_POST['openid_action']) &&
$_POST['openid_action'] == "logout") {
$auth->clearIdentity();
} else {
$status = "You are logged in as "
. $auth->getIdentity()
. "<br>\n";
}
}
?>
<html><body>
<?php echo htmlspecialchars($status);?>
<form method="post"><fieldset>
<legend>OpenID Login</legend>
<input type="text" name="openid_identifier" value="">
<input type="submit" name="openid_action" value="login">
<input type="submit" name="openid_action" value="logout">
</fieldset></form></body></html>
*/
允许和下面这些方法一起来定制 OpenID 认证过程:从 OpenID 服务器上接收在分开的页面上的重定向;指定网站的 "root"。在这种情况下,使用
|