<?xml version="1.0"?>
<?xml-stylesheet href="http://xml.resource.org/authoring/rfc2629.xslt"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<rfc ipr="trust200902" category="std" docName="draft-shanks-http-form-authentication-00">
	<front>
		<title abbrev="HTTP Form Authentication">Hypertext Transfer Protocol (HTTP) Form Authentication Scheme</title>
		<date day="27" month="November" year="2012"/>
		<author fullname="Nicholas Shanks" surname="Shanks" initials="N.">
			<address>
				<postal>
					<street>45 Oaklands Wood</street>
					<city>Hatfield</city>
					<region>Hertfordshire</region>
					<code>AL10 8LU</code>
					<country>United Kingdom</country>
				</postal>
				<phone>+44 (0)1707 258219</phone>
				<email>nickshanks@nickshanks.com</email>
				<uri>http://nickshanks.com/</uri>
			</address>
		</author>
		<abstract>
			<t>This document defines the "Form" HTTP authentication scheme. It allows web developers access to standard HTTP-based authentication mechanisms whilst retaining control over the look and feel of their log-in page, without requiring any client-side scripting. Comments are requested and should be addressed to the author.</t>
		</abstract>
	</front>
	<middle>
		<section anchor="intro" title="Introduction">
			<t>This document builds upon the Digest authentication scheme defined by <xref target="RFC2617"/> and amended by <xref target="draft-ietf-httpbis-p7-auth"/>, but changes the process for creating the A1 value (as is defined by Section 3.2.2.2 of <xref target="RFC2617"/>), and defines different user agent behaviour. It is intended to allow migration away from application/x-www-form-urlencoded requests over unencrypted HTTP which transmit the password in plaintext; and to do so in a way that, when widely supported by user agents and server software, will also allow simple migration from Digest authentication, should developers who are already using that want to take control of the credentials solicitation appearance. It is not intended for use in conjunction with TLS, as it offers little benefit there, but nothing prevents its use in that context if so desired.</t>
			<section anchor="rfc2199" title="Conformance">
				<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in <xref target="RFC2119"/>.</t>
			</section>
		</section>
		<section anchor="scheme" title="The &quot;Form&quot; Authentication Scheme">
			<t>Supporting user agents MUST present to the user (or to a software/hardware agent acting on behalf of the user) the body of a response which uses either a HTTP status code of 401 and a WWW-Authenticate header specifying the "Form" scheme; or a 407 status code and a Proxy-Authenticate header specifying the "Form" scheme. This response body MUST contain a form in a format that the user agent can understand, e.g. HTML &lt;form> element with &lt;input> children, XML incorperating XForms &lt;xf:input> elements, or other comparable markup which the user agent knows about.</t>
			<t>If the response does not meet these conditions, then the user agent MUST ignore this document and process the response as it would otherwise.</t>
			<t>When submitting the form, instead of obeying the action, method and encoding specified by the form, user agents MUST create an Authorization header by concatenating the values of each form input, in document order, each seperated from the next by a single colon character ":" not surrounded by whitespace, possibly followed by nonce and cnonce values also seperated by a colon character, then computing the hash of the resulting string using the MD5 algorithm, or otherwise per the algorithm parameter (e.g. those defined by <xref target="draft-ahrens-httpbis-digest-auth-update"/>).</t>
			<t>When no nonce value is provided by the server</t>
			<figure>
				<artwork>
    A1 = *(unq(form-field-value) ":") unq(form-field-value)
				</artwork>
			</figure>
			<t>If a nonce value is provided by the server</t>
			<figure>
				<artwork>
    A1 = H( *(unq(form-field-value) ":") unq(form-field-value) )
	        ":" unq(nonce-value)
			":" unq(cnonce-value)
				</artwork>
			</figure>
			<t>The result now forms the "A1" input to the standard Digest authentication computation <xref target="RFC2617">Section 3.2.2.1 of RFC2617</xref>. The user agent MUST then re-submit the original request with this header included, to the original Request-URI <xref target="RFC2617">Section 5.1.2 of RFC2617</xref>.</t>
			<t>This scheme introduces no new authentication parameters.</t>
			<section anchor="examples" title="Examples">
				<t>This section is non-normative.</t>
				<t>An example in HTML:</t>
				<figure>
					<artwork>
&lt;form action=/login.php method=POST>
    &lt;input name=user required>
    &lt;input name=realm type=hidden value=admin>
    &lt;input name=pass type=password required>
    &lt;input name=pin type=password size=4>
    &lt;button>Log In&lt;/button>
&lt;/form>
					</artwork>
				</figure>
				<t>When filled out by the user (or acting agent) with values of user=dave, pass=p455w0rd and pin=9876, and assuming the default MD5 algorithm is to be used, this form will result in an Authorization header being generated by conforming user agents by means of computing the function H(A1) = md5(dave:admin:p455w0rd:9876), then combining that with qop, nonce and other parameters as per <xref target="RFC2617"/>.</t>
				<t>An empty field results in an empty string being concatenated, with no special treatment, i.e. if no value for the PIN were provided in the above example, the MD5 hash would be computed as md5(dave:admin:p455w0rd:). An empty value between two others would result in a double colon appearing in the string to be hashed, "::". The input names, if provided, are not used in any way. They serve only as fallback for UAs that do not support this document. In the above case, user agents which do not support this document are expected to send a POST request to the path /login.php with the form fields URL-encoded in the request body. This allows for incremental support to be introduced as user agents are released which support this document and users upgrade.</t>
			</section>
		</section>
		<section anchor="security" title="Security Considerations">
			<t>Yet to be written (mostly).</t>
			<t>All security considerations in <xref target="RFC2617"/> pertaining to Digest authentication method apply to the Form method too.</t>
			<t>Until such time as standard server software (such as Apache, Lighttpd, Nginx, etc.) nativly supports this authentication scheme, web developers will have to implement support using server-side processing langauges (such as Ruby, Node.js or PHP). All incoming requests to URIs beyond the authentication point will need to be caught and processed for authentication credentials, to avoid exposing valid URIs from invalid ones. It is expected that third-party libraries will be developed to ease this.</t>
		</section>
		<section anchor="iana" title="IANA Considerations">
			<t>IANA is to register the "Form" authentication scheme, citing <xref target="reg"/> of this document as the reference, within the http-authschemes registry at &lt;http://www.iana.org/assignments/http-authschemes> as established by Section 2.3 of <xref target="draft-ietf-httpbis-p7-auth"/>.</t>
			<section anchor="reg" title="Authentication Scheme Registration">
				<t>Authentication scheme name: Form</t>
				<t>Specification text: This document</t>
				<t>Notes: A variant of the Digest authentication scheme, with new processing requirements for the server and the user agent.</t>
			</section>
		</section>
	</middle>
	<back>
		<references anchor="nrefs" title="Normative References">
			<reference anchor="RFC2119">
				<front>
					<title>Key words for use in RFCs to Indicate Requirement Levels</title>
					<author initials="S." surname="Bradner"/>
					<date month="March" year="1997"/>
				</front>
				<seriesInfo name="RFC" value="2119"/>
				<seriesInfo name="BCP" value="14"/>
				<format type="html" target="http://tools.ietf.org/html/rfc2119"/>
				<format type="pdf" target="http://tools.ietf.org/pdf/rfc2119"/>
				<format type="text" target="http://tools.ietf.org/rfc/rfc2119"/>
			</reference>
			<reference anchor="RFC2617">
				<front>
					<title>HTTP Authentication: Basic and Digest Access Authentication</title>
					<author initials="J." surname="Franks"/>
					<date month="June" year="1999"/>
				</front>
				<seriesInfo name="RFC" value="2617"/>
				<format type="html" target="http://tools.ietf.org/html/rfc2617"/>
				<format type="pdf" target="http://tools.ietf.org/pdf/rfc2617"/>
				<format type="text" target="http://tools.ietf.org/txt/rfc2617"/>
			</reference>
			<reference anchor="draft-ietf-httpbis-p7-auth">
				<front>
					<title>Hypertext Transfer Protocol (HTTP/1.1): Authentication</title>
					<author initials="R." surname="Fielding"/>
					<author initials="J." surname="Reschke"/>
					<date day="4" month="October" year="2012"/>
				</front>
				<format type="xml" target="http://www.ietf.org/id/draft-ietf-httpbis-p7-auth-21.xml"/>
				<format type="html" target="http://www.ietf.org/id/draft-ietf-httpbis-p7-auth-21.html"/>
				<format type="pdf" target="http://www.ietf.org/id/draft-ietf-httpbis-p7-auth-21.pdf"/>
				<format type="text" target="http://www.ietf.org/id/draft-ietf-httpbis-p7-auth-21.txt"/>
			</reference>
		</references>
		<references anchor="irefs" title="Informational References">
			<reference anchor="draft-ietf-httpbis-authscheme-registrations">
				<front>
					<title>Initial Hypertext Transfer Protocol (HTTP) Authentication Scheme Registrations</title>
					<author initials="J." surname="Reschke"/>
					<date day="13" month="October" year="2012"/>
				</front>
				<format type="xml" target="http://www.ietf.org/id/draft-ietf-httpbis-authscheme-registrations-05.xml"/>
				<format type="html" target="http://www.ietf.org/id/draft-ietf-httpbis-authscheme-registrations-05.html"/>
				<format type="pdf" target="http://www.ietf.org/id/draft-ietf-httpbis-authscheme-registrations-05.pdf"/>
				<format type="text" target="http://www.ietf.org/id/draft-ietf-httpbis-authscheme-registrations-05.txt"/>
			</reference>
			<reference anchor="draft-ahrens-httpbis-digest-auth-update">
				<front>
					<title>HTTP Digest Access Authentication Algorithm Update</title>
					<author initials="D." surname="Ahrens"/>
					<author initials="R." surname="Shekh Yusef"/>
					<date day="30" month="July" year="2012"/>
				</front>
				<format type="xml" target="http://www.ietf.org/id/draft-ahrens-httpbis-digest-auth-update-00.xml"/>
				<format type="html" target="http://www.ietf.org/id/draft-ahrens-httpbis-digest-auth-update-00.html"/>
				<format type="pdf" target="http://www.ietf.org/id/draft-ahrens-httpbis-digest-auth-update-00.pdf"/>
				<format type="text" target="http://www.ietf.org/id/draft-ahrens-httpbis-digest-auth-update-00.txt"/>
			</reference>
		</references>
		<appendix anchor="issues" title="Known Issues">
			<list style="symbols">
				<t>Server requirements and User Agent requirements are inter-mixed in <xref target="scheme"/>, and both are poorly defined.</t>
				<t>How should the realm, and other authentication header parameters, be reflected in the form. Should form fields with the same name as a parameter adopt the value of the parameter in supporting UAs? The value of the form field will be submitted to the action URI by old UAs. Should this be true only for "realm"?</t>
			</list>
		</appendix>
	</back>
</rfc>