<?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-01">
	<front>
		<title abbrev="HTTP Form Authentication">Hypertext Transfer Protocol (HTTP) Form Authentication Scheme</title>
		<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>
		<date day="30" month="November" year="2012"/>
		<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 scheme builds upon the Digest authentication scheme defined by <xref target="RFC2617"/> and updated by <xref target="draft-ietf-httpbis-p7-auth"/>, but changes the process for creating the A1 value (<eref target="http://tools.ietf.org/html/rfc2617#section-3.2.2.2">section 3.2.2.2 of RFC 2617</eref>), and specifies 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 clear-text, a common occurance on the web (for example see <eref target="http://it.toolbox.com/blogs/securitymonkey/look-at-all-of-these-passwords-11240">Look At All Of These Passwords!</eref>); 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 scheme wish to take control of their credentials solicitation appearance. It is intended to function independent of Transport Layer Security (TLS) <xref target="RFC5246"/>, serving only to obscure passwords from eavesdroppers, however nothing prevents its use over an encrypted connection if so desired.</t>
			<section anchor="terms" title="Terminology">
				<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>
				<t>The terms "form field", "form input" and "form output" are used somewhat interchangably and refer to elements generated by markup which may be submitted with the form by the user agent.</t>
				<t>The phrase "submittable field" means any form field which would generate a key&ndash;value pair on form submission. In HTML 4 that would mean every input type except an unchecked checkbox and a radio group with no selected element.</t>
				<t>A form field's "name" refers to the property of the field which is used to create the key in each key&ndash;value pair submitted by the form. In HTML this would be the value of the name attribute of e.g. an input element.</t>
				<t>The phrase "reserved name pattern" indicates a form field name which begins and ends with an underscore character "_", ASCII value decimal 95. As a regular expression, this would be represented by the pattern /_.*_/</t>
				<t>The "effective checksum algorithm" is determined as described by <eref target="http://tools.ietf.org/html/rfc2617#section-3.2.1">section 3.2.1 of RFC 2617</eref>, under "algorithm".</t>
				<t>The string obtained by applying the checksum algorithm to the data "data" will be denoted H(data). The notation unq(X) means the value of the quoted-string X without the surrounding quotes.</t>
			</section>
		</section>
		<section anchor="scheme" title="The &quot;Form&quot; Authentication Scheme">
			<t>Supporting user agents MUST present to the user (or to another software/hardware agent acting on behalf of the user) the parsed 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> descendants, 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 MAY 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 as may be specified by the form, user agents MUST create an Authorization header then re-submit the original request with this additional header to the original request URI. This header MUST be created per <xref target="RFC2617"/> with the exception of the the scheme name token, which must be "Form", and the "A1" string value. To generate the A1 value, the user agent MUST concatenate the values of all submittable fields of the form, in document order, excepting those with names that match the reserved name pattern. Each value is to be seperated from the next by a single colon character ":" not surrounded by whitespace. If a "nonce" parameter is supplied by the server in the WWW-Authenticate header, the result of the previous step is then to be hashed using the effective checksum algorithm, and followed by nonce and cnonce values also seperated from the hash and each other by single colon characters. Processing then continues as described by <eref target="http://tools.ietf.org/html/rfc2617#section-3.2.2.1">section 3.2.2.1 of RFC 2617</eref>.</t>
			<t>When no nonce value is provided by the server</t>
			<figure>
				<artwork>
    A1               = form-field-value *[ ":" form-field-value ]
    form-field-value = *TEXT
				</artwork>
			</figure>
			<t>If a nonce value is provided by the server</t>
			<figure>
				<artwork>
    A1           = H( form-field-value *[ ":" form-field-value ] )
                       ":" unq(nonce-value)
                       ":" unq(cnonce-value)
    nonce-value  = &lt;defined in RFC 2617>
    cnonce-value = &lt;defined in RFC 2617>
				</artwork>
			</figure>
			<section anchor="fields" title="Field Names">
				<t>This scheme defines specific meanings for the following form field names and gives user agents processing directives for each.</t>
				<list style="hanging">
					<t hangText="username">If a form field exists with this name, then its value is used for the "username" parameter of the Authorization request header. If there is no field with this name, then the value of the first non-hidden, clear-text input is used as the value of the "username" parameter.</t>
					<t hangText="_auth_expire_">An integer value in seconds which, when not empty, generates an Authentication-Control header (<xref target="draft-oiwa-httpbis-auth-extension"/>) with the logout-timeout parameter set to the value of this field. If multiple fields exist with this name, only the last submittable field is considered. Valid values are the empty string and any non-negative integer. Invalid values are mapped to the empty string. The value zero ("0") is not considered to be empty (i.e. it doesn't prevent parameter generation), and represents immediate expiry of the credentials after the client receives a response.</t>
				</list>
			</section>
			<section anchor="auth-params" title="Authorization Parameters">
				<t>This scheme introduces no new parameters for the Authorization header additional to those already defined by <xref target="RFC2617"/>.</t>
			</section>
			<section anchor="auth-control-params" title="Authentication-Control Parameters">
				<t>When using the Form authentication scheme, the default value for the auth-style parameter of the Authentication-Control header is the token "non-modal". <xref target="draft-oiwa-httpbis-auth-extension"/></t>
			</section>
			<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=_auth_expire_ type=hidden value=900>
    &lt;input name=_auth_expire_ type=checkbox> Do not
        log out after 15 minutes of inactivity.
    &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 and pass=p455w0rd, 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), then combining that with qop, nonce and other parameters as per <xref target="RFC2617"/>. In the above example, the presence of the hidden field "realm" will produce the same checksum result as would be generated by Digest authentication (assuming the field value "admin" matches that of the WWW-Authenticate header's realm parameter [see <xref target="issues"/>]). This trick may be of use to those migrating from existing Digest deployments.</t>
				<t>An empty field results in an empty string being concatenated, with no special treatment, i.e. an empty value between two others would result in a double colon appearing in the string to be hashed, "::", and an empty field at the start or end would result in the unhashed string beginning or ending with a colon. The field names, if provided, are not included in the checksum in any way. They serve only as fallback for UAs that do not support the Form authentication method, and for identifying which field values should be excluded from string to be hashed. In the above case, user agents which do not support this scheme 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 scheme and users upgrade.</t>
			</section>
			<section anchor="log-out" title="De-authentication Mechanisms">
				<t>This section is non-normative.</t>
				<t>Readers are directed to <xref target="draft-oiwa-httpbis-auth-extension"/> and the Authentication-Control header, which defines such mechanisms as a means by which clients may log out, and servers may direct clients to cease sending certain authentication credentials.</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 the Digest authentication method apply to the Form method too.</t>
			<t>Futher vulnerabilities to Digest authentication are discussed in <xref target="RFC4169"/> and also apply to Form authentication.</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 client.</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/rfc/rfc2617"/>
			</reference>
			<reference anchor="draft-oiwa-httpbis-auth-extension">
				<front>
					<title>HTTP Authentication Extensions for Interactive Clients</title>
					<author initials="Y." surname="Oiwa"/>
					<date day="4" month="June" year="2012"/>
				</front>
				<format type="text" target="http://www.ietf.org/id/draft-oiwa-httpbis-auth-extension-00.txt"/>
				<format type="pdf" target="http://www.ietf.org/id/draft-oiwa-httpbis-auth-extension-00.pdf"/>
				<format type="postscript" target="http://www.ietf.org/id/draft-oiwa-httpbis-auth-extension-00.ps"/>
				<format type="html" target="http://tools.ietf.org/html/draft-oiwa-httpbis-auth-extension"/>
			</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="text" target="http://www.ietf.org/id/draft-ietf-httpbis-p7-auth-21.txt"/>
				<format type="xml" target="http://www.ietf.org/id/draft-ietf-httpbis-p7-auth-21.xml"/>
				<format type="html" target="http://tools.ietf.org/html/draft-ietf-httpbis-p7-auth-21"/>
				<format type="pdf" target="http://tools.ietf.org/pdf/draft-ietf-httpbis-p7-auth-21.pdf"/>
			</reference>
		</references>
		<references anchor="irefs" title="Informational References">
			<reference anchor="RFC4169">
				<front>
					<title>Hypertext Transfer Protocol (HTTP) Digest Authentication Using Authentication and Key Agreement (AKA) Version-2</title>
					<author initials="V." surname="Torvinen"/>
					<date month="November" year="2005"/>
				</front>
				<seriesInfo name="RFC" value="4169"/>
				<format type="html" target="http://tools.ietf.org/html/rfc4169"/>
				<format type="pdf" target="http://tools.ietf.org/pdf/rfc4169"/>
				<format type="text" target="http://tools.ietf.org/txt/rfc4169"/>
			</reference>
			<reference anchor="RFC5246">
				<front>
					<title>The Transport Layer Security (TLS) Protocol Version 1.2</title>
					<author initials="T." surname="Dierks"/>
					<author initials="E." surname="Rescorla"/>
					<date month="August" year="2008"/>
				</front>
				<seriesInfo name="RFC" value="5246"/>
				<format type="html" target="http://tools.ietf.org/html/rfc5246"/>
				<format type="pdf" target="http://tools.ietf.org/pdf/rfc5246"/>
				<format type="text" target="http://tools.ietf.org/txt/rfc5246"/>
			</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="text" target="http://www.ietf.org/id/draft-ahrens-httpbis-digest-auth-update-00.txt"/>
				<format type="html" target="http://tools.ietf.org/html/draft-ahrens-httpbis-digest-auth-update-00"/>
				<format type="pdf" target="http://tools.ietf.org/pdf/draft-ahrens-httpbis-digest-auth-update-00.pdf"/>
			</reference>
			<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="text" target="http://www.ietf.org/id/draft-ietf-httpbis-authscheme-registrations-05.txt"/>
				<format type="xml" target="http://www.ietf.org/id/draft-ietf-httpbis-authscheme-registrations-05.xml"/>
				<format type="html" target="http://tools.ietf.org/html/draft-ietf-httpbis-authscheme-registrations-00"/>
				<format type="pdf" target="http://tools.ietf.org/pdf/draft-ietf-httpbis-authscheme-registrations-00.pdf"/>
			</reference>
		</references>
		<appendix anchor="thanks" title="Acknowledgments">
			<t>The author thanks to the memebers of the http-auth mailing list for their assistance.</t>
		</appendix>
		<appendix anchor="history" title="Change History">
			<section title="Since draft-shanks-http-form-authentication-00">
				<list>
					<t>Clarify role with respect to TLS.</t>
					<t>Added <xref target="fields"/>, <xref target="auth-control-params"/> and <xref target="log-out"/>, and split out <xref target="auth-params"/> into its own sub-section.</t>
					<t>Altered token order, added definitions and corrected indentation issue with ABNF in <xref target="scheme"/>.</t>
					<t>Added normative reference to <xref target="draft-oiwa-httpbis-auth-extension"/>, and an informational references to <xref target="RFC4169"/> and <xref target="RFC5246"/>.</t>
					<t>Amended various references used in the text, and some external links in the references sections.</t>
					<t>Sorted reference sections chronologically.</t>
					<t>Changed the title and anchor of <xref target="terms"/>, and added six terms.</t>
					<t>Added <xref target="thanks"/>, <xref target="history"/>, and expanded <xref target="issues"/>.</t>
				</list>
			</section>
		</appendix>
		<appendix anchor="issues" title="Known Issues">
			<list>
				<t>Server requirements and User Agent requirements are inter-mixed in <xref target="scheme"/>, and both are poorly defined IMO.</t>
				<t>Should fields with a name matching a WWW-Authenticate header parameter mirror the value of that parameter and ignore any value provided by the markup? i.e. Should form fields with the same name as a parameter adopt the value of the parameter? The original value of such fields will be submitted to the action URI by old UAs. Perhaps only for "realm"?</t>
				<t>I don't feel comfortable including a link to a blog article (see the <xref target="intro">Introduction</xref>), but I wanted to provide examples of just how common sending unencrypted auth data was in practice. Can anyone suggest a better external reference, or something I can inline?</t>
				<t>How do I add an "et al." to the list of authors where there is more than two for a given reference?</t>
				<t>I haven't yet read the ABNF documentation so I don't know if I'm using it correctly. I am also not sure how to reference it.</t>
				<t>Must the browser's response echo back "Form" as the authentication scheme, or could we get away with returning "Digest" if certain conditions are met, similar to my example? I want to make as few changes as is possible to the current Digest scheme so that as much as possible continues to function when people switch from either forms+cookies or existing Digest deployments.</t>
				<t>Perhaps change the reserved name pattern from /_.*_/ to /_.+_/ ?</t>
				<t>The rather verbose text about handling of empty fields and colons seems rather obvious and perhaps unnecessary.</t>
			</list>
		</appendix>
	</back>
</rfc>