and*_*yuk 10 openid redirect openid2
为什么要进行自动HTML帖子而不是简单的重定向?
这是否所以开发人员可以自动生成一个登录表单,当OpenID已知时,该表单将目录发布到远程服务器?
例如.
如果是这种情况,我可以看到好处.但是,这假设您在注销时将用户的openID保留在cookie中.
我可以找到关于如何最好地实现此规范的信息.
请参阅官方规范中的HTML FORM Redirection:
http://openid.net/specs/openid-authentication-2_0.html#indirect_comm
我从查看PHP OpenID库(版本2.1.1)中发现了这一点.
// Redirect the user to the OpenID server for authentication.
// Store the token for this authentication so we can verify the
// response.
// For OpenID 1, send a redirect. For OpenID 2, use a Javascript
// form to send a POST request to the server.
if ($auth_request->shouldSendRedirect()) {
$redirect_url = $auth_request->redirectURL(getTrustRoot(),
getReturnTo());
// If the redirect URL can't be built, display an error
// message.
if (Auth_OpenID::isFailure($redirect_url)) {
displayError("Could not redirect to server: " . $redirect_url->message);
} else {
// Send redirect.
header("Location: ".$redirect_url);
}
} else {
// Generate form markup and render it.
$form_id = 'openid_message';
$form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(),
false, array('id' => $form_id));
// Display an error if the form markup couldn't be generated;
// otherwise, render the HTML.
if (Auth_OpenID::isFailure($form_html)) {
displayError("Could not redirect to server: " . $form_html->message);
} else {
print $form_html;
}
}
Run Code Online (Sandbox Code Playgroud)
我可以想到几个原因:
我不知道其中任何一个都是选择POST的扣篮理由 - 除非发送的数据量超过某些主要浏览器的查询字符串长度.
正如Mark Brackett所说,主要动机是使用重定向和GET对有效载荷大小的限制.一些实现足够聪明,只有当消息超过一定大小时才使用POST,因为POST技术肯定存在缺点.(其中最主要的是你的后退按钮不起作用.)其他实现,比如你引用的示例代码,是为了简单和一致,并省略了条件.
归档时间: |
|
查看次数: |
2058 次 |
最近记录: |