<p>Why would you do an automatic HTML post rather than a simple redirect?</p>

<p>Is this so developers can automatically generate a login form that posts directory to the remote server when the OpenID is known?</p>

<p>eg.</p>

<ol>
<li>User is not logged in and visits your login page.</li>
<li>You detect the user's openID from a cookie.</li>
<li>Form is generated that directly posts to remote OpenID server.</li>
<li>Remote server redirects user back to website.</li>
<li>Website logs in the user.</li>
</ol>

<p>If this is the case I can see the benefit. However this assumes that you keep the user's openID in a cookie when they log out.</p>

<p>I can find very little information on how this spec should be best implemented.</p>

<p>See HTML FORM Redirection in the official specs:</p>

<p><a href="http://openid.net/specs/openid-authentication-2_0.html#indirect_comm" rel="noreferrer">http://openid.net/specs/openid-authentication-2_0.html#indirect_comm</a></p>

<p>I found this out from looking at the <a href="http://openidenabled.com/php-openid/" rel="noreferrer">PHP OpenID Library</a> (version 2.1.1).</p>

<pre><code>// 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-&gt;shouldSendRedirect()) {
    $redirect_url = $auth_request-&gt;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-&gt;message);
    } else {
        // Send redirect.
        header("Location: ".$redirect_url);
    }
} else {
    // Generate form markup and render it.
    $form_id = 'openid_message';
    $form_html = $auth_request-&gt;htmlMarkup(getTrustRoot(), getReturnTo(),
                                           false, array('id' =&gt; $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-&gt;message);
    } else {
        print $form_html;
    }
}
</code></pre>

[{'answer_id': 35960, 'author': 'Mark Brackett', 'author_id': 2199, 'author_profile': 'https://Stackoverflow.com/users/2199', 'pm_score': 3, 'selected': False, 'text': "<p>I can think of a couple of reasons:</p>\n\n<ul>\n<li>A modicum of security by obscurity - it's slightly more work to tamper with POST submissions than GET</li>\n<li>Caching and resubmit rules are more restrictive for POST than GET. I'm not entirely sure this would matter for the OpenID use case, though.</li>\n<li>Bots wouldn't follow the POST form, but would follow the redirect. This could impact server load. </li>\n<li>Different browsers have different max lengths for GET requests - but none of them are as large as POST.</li>\n<li>Some browsers will warn on redirect to another domain. They'll also warn if you're submitting POST to a non-HTTPS url.</li>\n<li>By turning JavaScript off, I can have a relatively secure experience, and not be silently redirected to another domain.</li>\n</ul>\n\n<p>I don't know that any of these are a slam-dunk reason to choose POST - unless the amount of data being sent exceeds the querystring length for some major browser.</p>\n"}, {'answer_id': 85788, 'author': 'keturn', 'author_id': 9585, 'author_profile': 'https://Stackoverflow.com/users/9585', 'pm_score': 4, 'selected': True, 'text': "<p>The primary motivation was, as Mark Brackett says, the limits on payload size imposed by using redirects and GET.  Some implementations are smart enough to only use POST when the message goes over a certain size, as there are certainly disadvantages to the POST technique.  (Chief among them being the fact that your Back button doesn't work.)  Other implementations, like the example code you cited, go for simplicity and consistency and leave out that conditional.</p>\n"}, {'answer_id': 669298, 'author': 'Laurent Fournié', 'author_id': 80861, 'author_profile': 'https://Stackoverflow.com/users/80861', 'pm_score': 2, 'selected': False, 'text': '<p>The same approach is used for the SAML Web Browser SSO profile. The primary motivations of using HTML Post redirection are :</p>\n\n<ul>\n<li><p>Virtually unlimited length of the payload : in SAML the payload is a XML document signed with XMLDSig and base64 encoded. It is larger than the usual 1024 characters limitation of URL (a best practice to support not only any browsers but intermediary network devices like Firewall, Reverse Proxy, Load Balancer as well).</p></li>\n<li><p>W3C HTTP standard says that GET is idempotent (the same URL GET executed multiple times should always result in same response) and consequently can be cached along the way while POST is not and must reach the URL target. Response of an OpenID HTML Form POST or SAML HTML Form POST should not be cached. It must reach the target in order to initiate the authenticated session.</p></li>\n</ul>\n\n<p>You could argue that using a HTTP GET redirection would work as well since the URL query always change and you would be right is practice. However, this would be a workaround of the W3C standard, and therefore, should not be a standard but an alternate implementation whenever both end agree with it.</p>\n'}]
['https://Stackoverflow.com/questions/34623', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2108/']