Tại sao bạn làm một bài đăng HTML tự động thay vì chuyển hướng đơn giản?Tại sao chuyển hướng dạng HTML được sử dụng trong OpenID 2?
Đây có phải là nhà phát triển có thể tự động tạo biểu mẫu đăng nhập để đăng thư mục lên máy chủ từ xa khi OpenID được biết không?
ví dụ:
- Người dùng chưa đăng nhập và truy cập trang đăng nhập của bạn.
- Bạn phát hiện OpenID của người dùng từ cookie.
- Biểu mẫu được tạo trực tiếp gửi tới máy chủ OpenID từ xa.
- Máy chủ từ xa chuyển hướng người dùng trở lại trang web.
- Nhật ký trang web trong người dùng.
Nếu đây là trường hợp tôi có thể thấy lợi ích. Tuy nhiên điều này giả định rằng bạn giữ openID của người dùng trong một cookie khi họ đăng xuất.
Tôi có thể tìm thấy rất ít thông tin về cách triển khai thông số này tốt nhất.
Xem HTML MẪU Redirection trong thông số kỹ thuật chính thức:
http://openid.net/specs/openid-authentication-2_0.html#indirect_comm
Tôi thấy điều này ra từ nhìn vào PHP OpenID Library (phiên bản 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;
}
}
Xem http://trac.openidenabled.com/trac/ticket/376. – crb