<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc subcompact="no"?>
<?rfc rfcedstyle="yes"?>
<?rfc-ext allow-markup-in-artwork="yes" ?>

<!DOCTYPE rfc [
  <!ENTITY MAY "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MAY</bcp14>">
  <!ENTITY MUST "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST</bcp14>">
  <!ENTITY MUST-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST NOT</bcp14>">
  <!ENTITY OPTIONAL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>OPTIONAL</bcp14>">
  <!ENTITY RECOMMENDED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>RECOMMENDED</bcp14>">
  <!ENTITY REQUIRED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>REQUIRED</bcp14>">
  <!ENTITY SHALL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL</bcp14>">
  <!ENTITY SHALL-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL NOT</bcp14>">
  <!ENTITY SHOULD "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD</bcp14>">
  <!ENTITY SHOULD-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD NOT</bcp14>">
]>

<rfc xmlns:x="http://purl.org/net/xml2rfc/ext" xmlns:ed="http://greenbytes.de/2002/rfcedit" ipr="trust200902" docName="draft-reschke-basicauth-enc-06" category="std" x:maturity-level="proposed" xml:lang="en" updates="2617">

  <x:feedback template="mailto:ietf-http-wg@w3.org?subject={docname},%20%22{section}%22&amp;body=&lt;{ref}&gt;:"/>

	<front>
  <title abbrev="Basic Auth Encoding Parameter">An Encoding Parameter for HTTP
  Basic Authentication</title>
  <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke">
    <organization abbrev="greenbytes">greenbytes GmbH</organization>
    <address>
      <postal>
        <street>Hafenweg 16</street>
        <city>Muenster</city><region>NW</region><code>48155</code>
        <country>Germany</country>
      </postal>
      <email>julian.reschke@greenbytes.de</email>	
      <uri>http://greenbytes.de/tech/webdav/</uri>	
    </address>
  </author>

  <date month="September" day="5"  year="2012"/>
  
  <abstract>
    <t>
      The "Basic" authentication scheme defined in RFC 2617 does not properly
      define how to treat non-ASCII characters. This has lead to a situation
      where user agent implementations disagree, and servers make different
      assumptions based on the locales they are running in. There is little
      interoperability for the non-ASCII characters in the ISO-8859-1 character set, and even less
      interoperability for any characters beyond that.
    </t>
    <t>
      This document defines a backwards-compatible extension to "Basic", 
      specifying the server's character encoding expectation,
      using a new authentication scheme parameter.
    </t>
  </abstract>
  
  <note title="Editorial Note (To be removed by RFC Editor before publication)">
    <t>
      Distribution of this document is unlimited. Although this is not a work
      item of the HTTPbis Working Group, comments should be sent to the 
      Hypertext Transfer Protocol (HTTP) mailing list at <eref target="mailto:ietf-http-wg@w3.org">ietf-http-wg@w3.org</eref>,
      which may be joined by sending a message with subject 
      "subscribe" to <eref target="mailto:ietf-http-wg-request@w3.org?subject=subscribe">ietf-http-wg-request@w3.org</eref>.
    </t>
    <t>
      Discussions of the HTTPbis Working Group are archived at
      <eref target="http://lists.w3.org/Archives/Public/ietf-http-wg/"/>.               
    </t> 
    <t>
      XML versions, latest edits and the issues list for this document
      are available from <eref target="http://greenbytes.de/tech/webdav/#draft-reschke-basicauth-enc"/>.
    </t>
  </note>
  </front>

  <middle>


<ed:issue name="edit" type="edit" status="open">
  <ed:item entered-by="julian.reschke@greenbytes.de" date="2010-08-11">
    Umbrella issue for editorial fixes/enhancements.
  </ed:item>
</ed:issue>

<ed:issue name="unorm" type="edit" status="open">
  <ed:item entered-by="julian.reschke@greenbytes.de" date="2012-02-02">
    We need a statement about unicode normalization forms.
  </ed:item>
</ed:issue>

<ed:issue xmlns="http://www.w3.org/1999/xhtml" name="terminology" type="edit" status="open">
  <ed:item entered-by="julian.reschke@greenbytes.de" date="2012-02-02">
    Try to be consistent with the terminology defined in RFC 6365.
  </ed:item>
</ed:issue>





<section title="Introduction" anchor="introduction">
<t>
  The "Basic" authentication scheme defined in <xref target="RFC2617" x:fmt="of" x:sec="2"/> does
  not properly define how to treat non-ASCII characters (<xref target="USASCII"/>): it uses the Base64
  (<xref target="RFC4648" x:fmt="," x:sec="4"/>)
  encoding of the concatenation of username, separator character, and password
  without stating which character encoding to use.
</t>
<t>  
  This has lead to a situation
  where user agent implementations disagree, and servers make different
  assumptions based on the locales they are running in. There is little
  interoperability for the non-ASCII characters in the ISO-8859-1 character set (<xref target="USASCII"/><ed:replace ed:resolves="edit"><ed:del> ,</ed:del><ed:ins>, </ed:ins></ed:replace><xref target="ISO-8859-1"/>),
  and even less interoperability for any characters beyond that.
</t>
<t>
  This document defines a backwards-compatible extension to "Basic", 
  specifying the server's character encoding expectation,
  using a new auth-param 
  for use in the Proxy-Authenticate and WWW-Authenticate header fields,
  as defined in <xref target="draft-ietf-httpbis-p7-auth"/>.
</t>
</section>  

<section title="Notational Conventions">
<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>
  This specification uses the ABNF (Augmented Backus-Naur Form) notation defined in
  <xref target="RFC5234"/>. The following core rules are included by
  reference, as defined in <xref target="RFC5234" x:fmt="," x:sec="B.1"/>:
  ALPHA (letters), DIGIT (decimal 0-9), HEXDIG (hexadecimal 0-9/A-F/a-f) and
  LWSP (linear white space).
</t>-->
</section>  

<section title="The 'accept-charset' auth-param" anchor="accept-charset">
<t>
  In challenges, servers &MAY; use the "accept-charset" authentication parameter (case-insensitive) to express the
  character encoding they expect the user agent to use.
</t>
<t>
  The only allowed value is "UTF-8", to be matched case-insensitively 
  (see <xref target="RFC2978" x:fmt="," x:sec="2.3"/>), indicating that
  the server expects the UTF-8 character encoding to be used
  (<xref target="RFC3629"/>).
</t>
<t>  
  Other values are reserved for future use.
</t>

<x:note>
  <t>
    <x:h>Note:</x:h> The 'accept-charset' parameter cannot be included when sending
   credentials (e.g. in the Authorization or Proxy-Authorization header fields),
   as the "Basic" scheme uses a single base64 token for credentials
   ('b64token' syntax), not a parameter list ('#auth-param' syntax); see
   <xref target="draft-ietf-httpbis-p7-auth" x:fmt="of" x:rel="#challenge.and.response"/>.
  </t>
</x:note>

</section>  

<section title="Examples" anchor="examples">
<figure>
  <preamble>In the example below, the server prompts for authentication in the "foo" realm,
  using Basic authentication, with a preference for the UTF-8 character encoding:</preamble>
  <artwork type="example">
WWW-Authenticate: Basic realm="foo", accept-charset="UTF-8"
</artwork>
  <postamble>Note that the parameter value can be either a token or a quoted
  string; in this case the server chose to use the quoted-string notation.</postamble>
</figure>
<t>
  The user's name is "test", and his password is the string "123" followed by
  the Unicode character U+00A3 (POUND SIGN). Following <xref target="RFC2617" x:fmt="of" x:sec="1.2"/>, but using the character encoding UTF-8, the user-pass, 
  converted to a sequence of octets, is:
</t>
<figure><artwork type="example">
 't' 'e' 's' 't' ':' '1' '2' '3' pound
 74  65  73  74  3A  31  32  33  C2  A3  
</artwork></figure>
<t>
  Encoding this octet sequence in Base64 (<xref target="RFC4648" x:fmt="," x:sec="4"/>) yields:
</t>
<figure><artwork type="example">
  dGVzdDoxMjPCow==
</artwork></figure>
<t>
  Thus the Authorization header field would be:
</t>
<figure><artwork type="example">
  Authorization: Basic dGVzdDoxMjPCow==
</artwork></figure>
<t>
  Or, for proxy authentication:
</t>
<figure><artwork type="example">
  Proxy-Authorization: Basic dGVzdDoxMjPCow==
</artwork></figure>

</section>  

<section title="Security Considerations" anchor="security.considerations">
<t>
  This document does not introduce any new security considerations beyond
  those defined for the "Basic" authentication scheme (<xref target="RFC2617" x:sec="4" x:fmt=","/>), and those
  applicable to the handling of UTF-8 (<xref target="RFC3629" x:fmt="," x:sec="10"/>).
</t>
</section>  

<section title="IANA Considerations" anchor="iana.considerations">
<t>
  There are no IANA Considerations related to this specification.
</t>
</section>  

<section title="Acknowledgements">
<t>
  The internationalisation problem has been reported as a Mozilla bug back
  in the year 2000 (see <eref target="https://bugzilla.mozilla.org/show_bug.cgi?id=41489"/>
  and also the more recent <eref target="https://bugzilla.mozilla.org/show_bug.cgi?id=656213"/>).
  It was Andrew Clover's idea to address it using a new auth-param.
</t>
<t>
  Thanks to Bjoern Hoehrmann, Amos Jeffries, James Manger, and Martin Thomson for providing feedback on this document.
</t>
</section>  
  </middle>
  <back>
  
<references title="Normative References">
  
  <reference anchor="RFC2119">
    <front>
      <title abbrev="RFC Key Words">Key words for use in RFCs to Indicate Requirement Levels</title>
      <author initials="S." surname="Bradner" fullname="Scott Bradner">
        <organization>Harvard University</organization>
        <address><email>sob@harvard.edu</email></address>
      </author>
      <date month="March" year="1997"/>
    </front>
    <seriesInfo name="BCP" value="14"/>
    <seriesInfo name="RFC" value="2119"/>
  </reference>

  <reference anchor="RFC2978">
    <front>
      <title>IANA Charset Registration Procedures</title>
      <author initials="N." surname="Freed" fullname="N. Freed"/>
      <author initials="J." surname="Postel" fullname="J. Postel"/>
      <date year="2000" month="October"/>
    </front>
    <seriesInfo name="BCP" value="19"/>
    <seriesInfo name="RFC" value="2978"/>
  </reference>

  <reference anchor="RFC3629">
    <front>
      <title>UTF-8, a transformation format of ISO 10646</title>
      <author initials="F." surname="Yergeau" fullname="F. Yergeau">
        <organization>Alis Technologies</organization>
        <address><email>fyergeau@alis.com</email></address>
      </author>
      <date month="November" year="2003"/>
    </front>
    <seriesInfo name="STD" value="63"/>
    <seriesInfo name="RFC" value="3629"/>
  </reference>

<!--  <reference anchor="RFC5234">
    <front>
      <title abbrev="ABNF for Syntax Specifications">Augmented BNF for Syntax Specifications: ABNF</title>
      <author initials="D." surname="Crocker" fullname="Dave Crocker" role="editor">
        <organization>Brandenburg InternetWorking</organization>
        <address>
          <phone>+1.408.246.8253</phone>
          <email>dcrocker@bbiw.net</email>
        </address>  
      </author>
      <author initials="P." surname="Overell" fullname="Paul Overell">
        <organization>THUS plc.</organization>
        <address>
          <email>paul.overell@thus.net</email>
        </address>
      </author>
      <date month="January" year="2008"/>
    </front>
    <seriesInfo name="STD" value="68"/>
    <seriesInfo name="RFC" value="5234"/>
  </reference>-->

  <reference anchor="ISO-8859-1">
    <front>
      <title>Information technology -- 8-bit single-byte coded graphic character sets -- Part 1: Latin alphabet No. 1</title>
      <author>
        <organization>International Organization for Standardization</organization>
      </author>
      <date year="1998"/>
    </front>
    <seriesInfo name="ISO/IEC" value="8859-1:1998"/>
  </reference>

  <reference anchor="USASCII">
    <front>
      <title>Coded Character Set -- 7-bit American Standard Code for Information Interchange</title>
      <author>
        <organization>American National Standards Institute</organization>
      </author>
      <date year="1986"/>
    </front>
    <seriesInfo name="ANSI" value="X3.4"/>
  </reference>

  <reference anchor="RFC2617">
    <front>
      <title abbrev="HTTP Authentication">HTTP Authentication: Basic and Digest Access Authentication</title>
      <author initials="J." surname="Franks" fullname="John Franks">
        <organization>Northwestern University, Department of Mathematics</organization>
        <address><email>john@math.nwu.edu</email></address>
      </author>
      <author initials="P.M." surname="Hallam-Baker" fullname="Phillip M. Hallam-Baker">
        <organization>Verisign Inc.</organization>
        <address><email>pbaker@verisign.com</email></address>
      </author>
      <author initials="J.L." surname="Hostetler" fullname="Jeffery L. Hostetler">
        <organization>AbiSource, Inc.</organization>
        <address><email>jeff@AbiSource.com</email></address>
      </author>
      <author initials="S.D." surname="Lawrence" fullname="Scott D. Lawrence">
        <organization>Agranat Systems, Inc.</organization>
        <address><email>lawrence@agranat.com</email></address>
      </author>
      <author initials="P.J." surname="Leach" fullname="Paul J. Leach">
        <organization>Microsoft Corporation</organization>
        <address><email>paulle@microsoft.com</email></address>
      </author>
      <author initials="A." surname="Luotonen" fullname="Ari Luotonen">
        <organization>Netscape Communications Corporation</organization>
      </author>
      <author initials="L." surname="Stewart" fullname="Lawrence C. Stewart">
        <organization>Open Market, Inc.</organization>
        <address><email>stewart@OpenMarket.com</email></address>
      </author>
      <date month="June" year="1999"/>
    </front>
    <seriesInfo name="RFC" value="2617"/>
  </reference>


<reference anchor="draft-ietf-httpbis-p7-auth">
  <front>
    <title abbrev="HTTP/1.1">HTTP/1.1, part 7: Authentication</title>
    <author fullname="Roy T. Fielding" initials="R." role="editor" surname="Fielding">
      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
      <address><email>fielding@gbiv.com</email></address>
    </author>
    <author fullname="Yves Lafon" initials="Y." role="editor" surname="Lafon">
      <organization abbrev="W3C">World Wide Web Consortium</organization>
      <address><email>ylafon@w3.org</email></address>
    </author>
    <author fullname="Julian F. Reschke" initials="J. F." role="editor" surname="Reschke">
      <organization abbrev="greenbytes">greenbytes GmbH</organization>
      <address><email>julian.reschke@greenbytes.de</email></address>
    </author>
    <date month="July" year="2012"/>
  </front>
  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p7-auth-20"/>
  <x:source basename="draft-ietf-httpbis-p7-auth-19" href="draft-ietf-httpbis-p7-auth-20.xml"/>
</reference>

</references>
  
<references title="Informative References" x:nrm="false">

<reference anchor="RFC4648">
  <front>
    <title>The Base16, Base32, and Base64 Data Encodings</title>
    <author fullname="S. Josefsson" initials="S." surname="Josefsson"/>
    <date year="2006" month="October"/>
  </front>
  <seriesInfo value="4648" name="RFC"/>
</reference>


<reference anchor="XHR" target="http://www.w3.org/TR/2011/WD-XMLHttpRequest2-20110816/">
  <front>
    <title>XMLHttpRequest Level 2</title>
    <author fullname="Anne van Kesteren" surname="van Kesteren" initials="A."/>
    <date year="2011" month="August" day="16"/>
  </front>
  <seriesInfo name="W3C Working Draft" value="WD-XMLHttpRequest2-20110816"/>
  <annotation>
    Latest version available at
    <eref target="http://www.w3.org/TR/XMLHttpRequest2/"/>.
  </annotation>
</reference>
</references>


<section title="Deployment Considerations">

<section title="User Agents">
<t>
  User agents not implementing this specifications should continue to work as
  before, ignoring the new parameter.
</t>
<t>
  User agents which already default to the UTF-8 encoding implement
  this specification by definition. 
  Note that some user agents also have different defaults depending
  on whether the request originates from page navigation as opposed to a
  script-driven request using XMLHttpRequest <xref target="XHR"/>.
</t>
<t>
  Other user agents can keep their default behavior, and switch to UTF-8
  when seeing the new parameter.
</t>

<section title="Alternative approach">
<t>
  On the other hand, the strategy below may already improve the user-visible
  behavior today:
  <list style="symbols">
    <t>
      In the first authentication request, choose the character encoding based
      on the user's credentials: if they do not need any characters outside
      the ISO-8859-1 character set, default to ISO-8859-1, otherwise use
      UTF-8.
    </t>
    <t>
      If the first attempt failed and the encoding used was ISO-8859-1, retry
      once with UTF-8 encoding instead.
    </t>
  </list>
</t>
<t>
  Note that there's a risk if the site blocks an account after multiple login
  failures (for instance, when it doesn't reset the counter after a successful
  login).
</t>

</section>

</section>

<section title="Origin Servers">
<t>
  Origin servers that do not support non-ASCII characters in credentials do not
  require any changes.
</t>
<t>
  Origin servers that need to support non-ASCII characters, but can't use
  the UTF-8 encoding will not be affected; they will continue to function
  as well as before.
</t>
<t>
  Finally, origin servers that need to support non-ASCII characters and can
  use the UTF-8 encoding can opt in as described above. In the worst case,
  they'll continue to see either broken credentials or no credentials at
  all (depending on how legacy clients handle characters they can not
  encode). 
</t>
</section>

</section>

<section title="FAQ (to be removed by RFC Editor before publication)" anchor="faq">

<section title="Why not simply switch the default encoding to UTF-8?">
<t>
  There are sites in use today that default to a locale encoding, such as
  ISO-8859-1, and expect user agents to use that encoding. These sites
  will break if the user agent uses a different encoding, such as UTF-8.
</t>
</section>

<section title="What about Digest?">
<t>
  Although the solution proposed in this document may be applicable to
  "Digest" as well, any attempt to update this scheme may be an uphill
  battle hard to win. 
</t>
</section>


<section title="Will existing UAs ignore the parameter?">
<t>
  It appears they will. See <eref target="http://greenbytes.de/tech/tc/httpauth/#simplebasicnewparam1"/>
  and <eref target="http://greenbytes.de/tech/tc/httpauth/#simplebasicnewparam2"/>.
</t>
</section>


</section>


<section title="Change Log (to be removed by RFC Editor before publication)" anchor="change.log">
<section title="Since draft-reschke-basicauth-enc-00">
<t>
  Add and close issues "credparam" and "paramcase".
  Rewrite the deployment considerations.
</t>
</section>


<section title="Since draft-reschke-basicauth-enc-01">
<t>
  Note more recent Mozilla bugzilla entry; add behavior of existing UAs
  to FAQ (with pointer to test cases).
</t>
</section>


<section title="Since draft-reschke-basicauth-enc-02">
<t>
  Add and resolve issue "xhrutf8".
</t>
</section>


<section title="Since draft-reschke-basicauth-enc-03">
<t>
  Add and resolve issue "proxy".
</t>
</section>

<section title="Since draft-reschke-basicauth-enc-04">
<t>
  Add and resolve issues "<ed:issueref>paramname</ed:issueref>" and "<ed:issueref>sentparam</ed:issueref>".
  Add issues 
  "<ed:issueref>terminology</ed:issueref>" and
  "<ed:issueref>unorm</ed:issueref>".
  Update HTTPbis reference.
</t>
</section>

<ed:replace ed:resolves="edit" datetime="2012-07-17"><ed:ins>
<section title="Since draft-reschke-basicauth-enc-05">
<t>
  Update HTTPbis reference.
</t>
</section>
</ed:ins></ed:replace>


</section>



  </back>

</rfc>