<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rfc [
<!ENTITY nbsp "&#160;">
<!ENTITY zwsp "&#8203;">
<!ENTITY nbhy "&#8209;">
<!ENTITY wj "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-mailmaint-pacc-03" category="std" submissionType="IETF" xml:lang="en" version="3">
    <!-- xml2rfc v2v3 conversion 3.28.0 -->
    <front>
        <title abbrev="Auto-Config of Email Server Settings">Automatic Configuration of Email, Calendar, and Contact Server Settings</title>
        <seriesInfo name="Internet-Draft" value="draft-ietf-mailmaint-pacc-03"/>
        <author fullname="Daniel Eggert" initials="D." surname="Eggert">
            <organization>Apple Inc</organization>
            <address>
                <postal>
                    <street>One Apple Park Way</street>
                    <city>Cupertino</city>
                    <code>CA 95014</code>
                    <country>USA</country>
                </postal>
                <email>deggert@apple.com</email>
                <uri>https://www.apple.com</uri>
            </address>
        </author>
        <author fullname="Ben Bucksch">
          <organization>Beonex</organization>
          <address>
            <email>ben.bucksch@beonex.com</email>
          </address>
        </author>
        <author fullname="Matt Diephouse" initials="M." surname="Diephouse">
            <organization>Apple Inc</organization>
            <address>
                <postal>
                    <street>One Apple Park Way</street>
                    <city>Cupertino</city>
                    <code>CA 95014</code>
                    <country>USA</country>
                </postal>
                <email>diephouse@apple.com</email>
                <uri>https://www.apple.com</uri>
            </address>
        </author>
        <date year="2026" month="7" day="27"/>
        <area>ART</area>
        <workgroup>mailmaint</workgroup>
        <keyword>configuration</keyword>
        <keyword>autoconfig</keyword>
        <keyword>auto-configuration</keyword>
        <keyword>ua-auto-config</keyword>
        <keyword>autodiscover</keyword>
        <keyword>mail</keyword>
        <keyword>email</keyword>
        <keyword>calendar</keyword>
        <keyword>contacts</keyword>
        <keyword>IMAP</keyword>
        <keyword>CalDAV</keyword>
        <keyword>CardDAV</keyword>
        <keyword>SMTP</keyword>
        <keyword>submission</keyword>
        <keyword>JMAP</keyword>
        <keyword>OAuth</keyword>
        <abstract>
            <t>This document specifies an automatic configuration mechanism for email, calendar, and contact user agent applications. Service providers publish standardized configuration information that user agent applications retrieve and use to simplify server setup procedures.</t>
        </abstract>
    </front>
    <middle>
        <section anchor="introduction">
            <name>Introduction</name>
            <t>Manual configuration of email, calendar, and contact user agent applications requires users to correctly specify numerous technical parameters including server hostnames, port numbers, and authentication protocols. This manual process frequently results in configuration errors and setup failures, even among technically skilled users.</t>
            <t>This document defines a mechanism that significantly simplifies this configuration process. Service providers can publish standardized configuration data that user agents can automatically retrieve and use. In most cases, users need only provide their email address and account password to complete the setup.</t>
            <t>For service providers that support the OAuth Profile for Open Public Clients <xref target="I-D.ietf-mailmaint-oauth-public"/>, this mechanism also enables automatic OAuth configuration. The user agent automatically determines all necessary details to set up OAuth authentication for the associated account.</t>
        </section>
        <section>
          <name>Document Conventions</name>
          <t>In the examples of text-based protocols (IMAP, POP3, Submission, and ManageSieve), this document uses a prefix of "C: " to denote lines sent by the user agent to the server, and "S: " for lines sent by the server to the user agent.  These prefixes are not part of the protocol.  Lines without either prefix are continuations of the previous line, and no line break is present in the protocol unless specifically mentioned.  Examples of HTTP-based protocols do not use these prefixes; each example shows either a request or a response, as stated in the surrounding text.</t>
          <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>",
              "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT
              RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be
              interpreted as described in BCP 14 <xref target="RFC2119"/>
              <xref target="RFC8174"/> when, and only when, they appear in
              all capitals, as shown here.</t>
          <t>This document uses the term <em>public suffix</em> as defined in <xref target="RFC9499" sectionFormat="of" section="9"/>: a domain under which third parties can register names, such as <tt>com</tt> or <tt>co.uk</tt>. Note that a public suffix can consist of more than one label. Such a domain is also referred to as an "effective top-level domain" (eTLD).</t>
          <t>This document uses the term <em>registrable domain</em> as defined in <xref target="I-D.ietf-httpbis-rfc6265bis" sectionFormat="of" section="2.3"/>: a hostname's public suffix plus the label to its left. It is the portion of a hostname that a single organization registers, and it is also commonly called "eTLD+1". For example, the registrable domain of <tt>mail.example.com</tt> is <tt>example.com</tt>, and the registrable domain of <tt>mail.example.co.uk</tt> is <tt>example.co.uk</tt>.</t>
          <t>Note that nothing in a domain name itself indicates whether it is a public suffix; determining the registrable domain of a hostname requires an external list of public suffixes, such as the Public Suffix List <xref target="PSL"/>. This document does not mandate a particular source for that list.</t>
        </section>
        <section anchor="flow-overview">
            <name>Overview</name>
            <t>The automatic configuration process begins when a user wants to set up their user agent application. The user agent requests the user's email address and then uses the domain portion of that address to retrieve configuration data for the account.</t>
            <t>Configuration retrieval uses the Well-Known URIs mechanism defined in <xref target="RFC8615"/>. The specific suffix for this configuration is <tt>user-agent-configuration.json</tt>. <xref target="flow-configuration-source"/> provides detailed information about the retrieval process.</t>
            <t>The configuration is provided as a JSON document (detailed in <xref target="json-configuration"/>) that informs the user agent about:</t>
            <ul>
                <li>Human-readable information about the service provider</li>
                <li>Supported protocols for this domain</li>
                <li>Server endpoints for each protocol</li>
                <li>OAuth Profile for Open Public Clients support availability</li>
            </ul>
            <t>The user agent uses this configuration to determine whether the provider supports protocols that the user agent can also use, helping decide whether to continue with the setup process. For example, an email user agent might check for support of JMAP, IMAP, POP3, and Submission protocols.</t>
            <t>Next, the user agent typically connects to the relevant services to verify which authentication methods they support and whether the user agent can use those methods. For instance, if the user agent needs both IMAP and Submission, it will connect to both servers to check their capabilities and confirm compatibility with the user agent's supported authentication mechanisms.</t>
            <t>Based on the available options, the user agent then proceeds with one of two approaches:</t>
            <ol>
                <li>Continue configuration using OAuth Profile for Open Public Clients, or</li>
                <li>Request the user's password for traditional authentication</li>
            </ol>
            <t>Finally, the user agent uses the obtained credentials (OAuth tokens or password) to connect to the servers specified in the configuration document and validates that the credentials work correctly with the desired protocols.</t>
            <section anchor="overview-server">
                <name>Server Requirements Summary</name>
                <t>The following is a non-normative, high-level summary of what a server operator needs to implement.</t>
                <ul>
                    <li>Publish a JSON configuration document at a well-known HTTPS URI, listing the domain's supported protocols and their server endpoints.</li>
                    <li>Publish DNS TXT records containing a digest of that configuration document, so user agents can verify its integrity.</li>
                    <li>Accept the user's full email address as the username on all servers listed in the configuration.</li>
                    <li>Optionally, support the OAuth Profile for Open Public Clients to enable OAuth-based authentication.</li>
                </ul>
            </section>
            <section anchor="overview-client">
                <name>User Agent Requirements Summary</name>
                <t>The following is a non-normative, high-level summary of what a user agent needs to implement.</t>
                <ul>
                    <li>Ability to construct the well-known URI from a user's email address and retrieve the JSON configuration document over HTTPS.</li>
                    <li>Ability to validate the configuration document's integrity by comparing its digest against a DNS TXT record.</li>
                    <li>Ability to connect to each server listed in the configuration and retrieve its supported authentication mechanisms.</li>
                    <li>User interface to present the server hostnames for the user to confirm before any credentials are entered.</li>
                    <li>Support for OAuth Profile for Open Public Clients and/or password-based authentication, to complete account setup.</li>
                </ul>
            </section>
        </section>
        <section anchor="json-configuration">
            <name>JSON Configuration</name>
            <t>The configuration document describes which services are available and their corresponding endpoints for a specific domain.</t>
            <t>The configuration file <bcp14>MUST</bcp14> conform to the JSON schema specification provided in <xref target="configuration-schema"/>.</t>
            <t>The configuration uses the media type <tt>application/json</tt>. The HTTP server <bcp14>MUST</bcp14> set the corresponding <tt>Content-Type</tt> header as specified in <xref target="RFC9110"/>.</t>
            <section anchor="json-configuration-example">
                <name>Example</name>
                <t>The following example demonstrates a typical JSON configuration:</t>
<sourcecode type="json" name="example-configuration.json"><![CDATA[
========== NOTE: '\' line wrapping per RFC 8792 ===========

{
    "protocols": {
        "jmap": {
            "url": "https://jmap.example.com/session"
        },
        "imap": {
            "host": "imap.example.com"
        },
        "pop3": {
            "host": "pop3.example.com"
        },
        "submit": {
            "host": "smtp.example.com"
        },
        "caldav": {
            "url": "https://sync.example.com/.well-known/caldav"
        },
        "carddav": {
            "url": "https://sync.example.com/.well-known/carddav"
        }
    },
    "authentication": {
        "oauth-public": {
            "issuer": "https://auth.example.com"
        },
        "password": true
    },
    "info": {
        "provider": {
            "name": "Example Provider Name",
            "shortName": "Example",
            "logo": [
                {
                    "url": "https://www.example.com/logo.svg",
                    "content-type": "image/svg+xml"
                }
            ]
        },
        "help": {
            "documentation": "https://help.example.com/howto/\
                set-up-your-mail-app.html",
            "developer": "https://developer.example.com/\
                client-apps/",
            "contact": ["mailto:it@example.com"]
        }
    }
}
]]></sourcecode>
            </section>
            <section anchor="json-config-protocols">
                <name>Protocols</name>
                <t>The <tt>protocols</tt> object specifies all protocols that the domain supports and identifies the server endpoint for each protocol.</t>
                <t>For the following HTTP-based protocols:</t>
                <ul>
                    <li>JMAP defined in <xref target="RFC8620"/>,</li>
                    <li>CalDAV defined in <xref target="RFC4791"/>,</li>
                    <li>CardDAV defined in <xref target="RFC6352"/>, and</li>
                    <li>WebDAV defined in <xref target="RFC4918"/></li>
                </ul>
                <t>each protocol entry <bcp14>MUST</bcp14> include a <tt>url</tt> value containing a URL with the <tt>https</tt> scheme. A server <bcp14>MAY</bcp14> answer a request for this URL with a redirect (see <xref target="sec-redirects" />); the URL reached after all redirects have been followed <bcp14>MUST</bcp14> specify an endpoint that serves the corresponding protocol. The server <bcp14>MUST</bcp14> use the default port 443 for HTTPS, and the URL <bcp14>MUST NOT</bcp14> include an explicit port number.</t>
                <t>The <tt>webdav</tt> protocol entry describes a WebDAV service used for file sharing, as distinct from the calendar and contact services described by the <tt>caldav</tt> and <tt>carddav</tt> entries.</t>
                <t>For the WebDAV-based protocols CalDAV, CardDAV, and WebDAV, the <tt>url</tt> value serves two purposes: the user agent uses it to probe for supported authentication schemes (see <xref target="flow-probing-http-auth-mechanism" />), and, once authenticated, it uses it as the base URL for the protocol itself. It is therefore not sufficient for the <tt>url</tt> to be any resource that merely triggers authentication; it <bcp14>MUST</bcp14> be a URL that the user agent can use as the initial "context path" for the bootstrapping procedure in <xref target="RFC6764" sectionFormat="of" section="6"/>. Specifically, the <tt>url</tt> <bcp14>MUST</bcp14> be either:</t>
                <ol spacing="normal">
                    <li>the protocol-specific <tt>.well-known</tt> URI defined in <xref target="RFC6764" sectionFormat="of" section="5"/> (that is, <tt>https://example.com/.well-known/caldav</tt> for CalDAV and <tt>https://example.com/.well-known/carddav</tt> for CardDAV), which redirects to such a context path; or</li>
                    <li>the context path itself, that is, a WebDAV resource that responds to a <tt>PROPFIND</tt> request (<xref target="RFC4918" sectionFormat="of" section="9.1"/>).</li>
                </ol>
                <t>For CalDAV and CardDAV, providers <bcp14>SHOULD</bcp14> publish the protocol-specific <tt>.well-known</tt> URI (form 1). <xref target="RFC6764" sectionFormat="of" section="5"/> already requires servers to support these URIs and to redirect requests for them to the actual context path, and requires user agents to follow those redirects, so form 1 is the most broadly interoperable choice. It also lets a provider change the context path, including on a per-user basis, without republishing the configuration document and updating its DNS digest (<xref target="flow-dns-digest-validation" />).</t>
                <t><xref target="RFC6764"/> does not define a <tt>.well-known</tt> URI for WebDAV as defined in <xref target="RFC4918"/>, and no such URI is registered in the "Well-Known URIs" registry. The <tt>url</tt> of a <tt>webdav</tt> protocol entry <bcp14>MUST</bcp14> therefore be the context path (form 2).</t>
                <t>The <tt>url</tt> <bcp14>MUST NOT</bcp14> be a bare origin, nor any other URL that neither serves the protocol itself nor redirects to a resource that does, and that would require the user agent to derive the context path on its own. Note that a server <bcp14>MUST NOT</bcp14> locate the actual service endpoint at the <tt>.well-known</tt> URI (<xref target="RFC6764" sectionFormat="of" section="5"/>); form 1 therefore always involves at least one redirect.</t>
                <t>The user agent sends its <tt>PROPFIND</tt> probe to this <tt>url</tt> and follows any redirect subject to the constraints in <xref target="sec-redirects" />. The URL reached after all redirects have been followed is the context path that the user agent uses for subsequent protocol operations; the user agent is not required to derive <tt>.well-known</tt> URIs itself. A server <bcp14>MAY</bcp14> require authentication before it issues the redirect, as described in <xref target="RFC6764" sectionFormat="of" section="5"/>; such a response also carries the <tt>WWW-Authenticate</tt> header fields that the user agent is probing for (see <xref target="flow-probing-http-auth-mechanism" />). Where the OAuth profile in <xref target="I-D.ietf-mailmaint-oauth-public" /> calls for a protected-resource identifier, that identifier is the context path reached after all redirects have been followed, not the <tt>url</tt> as published in the configuration.</t>
                <t>Hostnames in URLs <bcp14>MUST</bcp14> support Internationalized Domain Names (IDNs) as defined in <xref target="RFC5890"/> and <xref target="RFC5891"/>. Service providers <bcp14>MAY</bcp14> use either Unicode labels (u-labels) or ASCII Compatible Encoding labels (a-labels) in their configuration. User agents <bcp14>MUST</bcp14> support both forms and handle the conversion between them as specified in <xref target="RFC5891"/>.</t>
                <t>Example:</t>
                <sourcecode><![CDATA[
"jmap": {
    "url": "https://jmap.example.com/session"
}
                ]]></sourcecode>
                <t>For the following text-based protocols:</t>
                <ul>
                    <li>IMAP defined in <xref target="RFC9051"/>,</li>
                    <li>POP3 defined in <xref target="RFC1939"/>,</li>
                    <li>Submission defined in <xref target="RFC6409"/>, and</li>
                    <li>ManageSieve defined in <xref target="RFC5804"/></li>
                </ul>
                <t>each protocol entry <bcp14>MUST</bcp14> include a <tt>host</tt> value specifying the hostname of the server that provides the corresponding protocol. The service <bcp14>MUST</bcp14> be available on the default port for that protocol, with the connection secured using TLS from the start of the connection, also known as "direct TLS" or "implicit TLS". <xref target="flow-probing-text-auth-mechanism" /> goes into details about TLS and which ports to use.</t>
                <t>Hostnames <bcp14>MUST</bcp14> support Internationalized Domain Names (IDNs) as defined in <xref target="RFC5890"/> and <xref target="RFC5891"/>. Service providers <bcp14>MAY</bcp14> use either Unicode labels (u-labels) or ASCII Compatible Encoding labels (a-labels) in their configuration. User agents <bcp14>MUST</bcp14> support both forms and handle the conversion between them as specified in <xref target="RFC5891"/>.</t>
                <t>Example:</t>
                <sourcecode><![CDATA[
"imap": {
    "host": "imap.mail.example.com"
}
                ]]></sourcecode>
            </section>
            <section anchor="json-config-authentication">
                <name>Authentication</name>
                <t>The <tt>authentication</tt> object specifies which authentication mechanisms the provider supports.</t>
                <t>The <tt>authentication</tt> object itself is optional, but providers <bcp14>SHOULD</bcp14> include it. If it is absent, the configuration makes no statement about the authentication mechanisms that the provider supports, and the user agent has to determine them solely by probing each server of interest as described in <xref target="flow-selecting-protocols"/>.</t>
                <t>If the <tt>authentication</tt> object is present, it <bcp14>MUST</bcp14> include the <tt>password</tt> value. This value indicates whether the provider supports username and password authentication. A provider that supports OAuth but not password-based authentication therefore publishes <tt>"password": false</tt>.</t>
                <t>The nested <tt>oauth-public</tt> object contains a single <tt>issuer</tt> value that specifies the authorization server's issuer identifier as defined in <xref target="RFC8414" />. This value is a URL that uses the <tt>https</tt> scheme and has no query or fragment components.  User agents can use this identifier for authentication via <xref target="I-D.ietf-mailmaint-oauth-public" />. The presence of the <tt>oauth-public</tt> object indicates that the provider supports OAuth; its absence indicates that it does not.</t>
                <t>The contents of the <tt>authentication</tt> object describe the provider as a whole. Individual servers can differ, so a user agent still needs to probe each server that it intends to use, as described in <xref target="flow-selecting-protocols"/>.</t>
            </section>
            <section anchor="json-config-info">
                <name>Informational</name>
                <t>The <tt>info</tt> object contains information that user agents can present to users. The only required field is <tt>info/provider/name</tt>, which <bcp14>SHOULD</bcp14> clearly identify the provider to the user. The optional <tt>info/provider/shortName</tt> provides a shorter version of <tt>name</tt>.</t>
                <t>The <tt>info/provider/logo</tt> array can contain one or more entries pointing to the provider's logo images. User agents can use these to display the provider's logo to users.</t>
                <t>The <tt>info/help/documentation</tt> field provides a URL that can be presented to users for additional information about the provider. The <tt>info/help/developer</tt> field contains a URL with information specifically for user agent developers. The <tt>info/help/contact</tt> array lists URLs, such as <tt>mailto</tt> URLs, that user agent developers can use to contact the provider. As described in <xref target="help"/>, these URLs are not intended for users, and user agents <bcp14>MUST NOT</bcp14> display them.</t>
                <t>A minimal <tt>info</tt> example:</t>
                <sourcecode><![CDATA[
"info": {
    "provider": {
        "name": "Example Provider Name"
    }
}
                ]]></sourcecode>

                <section anchor="provider">
                    <name>Provider Information</name>
                    <t>The <tt>provider</tt> object can have <tt>name</tt>, <tt>shortName</tt>, and <tt>logo</tt> properties.</t>
                    <t>The <tt>name</tt> and <tt>shortName</tt> values are intended for display to the user.</t>
                    <t>The <tt>name</tt> property specifies the provider's display name, such as
                        the name used in the provider's marketing materials. It <bcp14>SHOULD</bcp14> be no
                        longer than 30 characters, but <bcp14>MUST</bcp14> be no longer than 60 characters.</t>
                    <t>The <tt>shortName</tt> property is optional. It specifies a brief version of the provider's name, as
                        commonly recognized by users. It <bcp14>SHOULD</bcp14> be no longer than 12
                        characters, and it <bcp14>MUST NOT</bcp14> be longer than 20 characters.</t>
                    <t>Both <tt>name</tt> and <tt>shortName</tt> <bcp14>MUST NOT</bcp14> include any control characters and <bcp14>SHOULD NOT</bcp14> include any excessive white space.</t>
                    <t>The <tt>logo</tt> property contains an array of provider logo variants.
                        User agents select the variant that best matches their UI requirements and technical constraints.</t>
                    <t>Each object in the array contains the following properties:</t>
                    <ul>
                        <li><tt>url</tt> - Location where the logo can be retrieved. User agents <bcp14>MAY</bcp14> download
                            the logo file during configuration and store it locally.</li>
                        <li><tt>content-type</tt> - Media type of the logo image. This follows <xref target="RFC2045"/> media type format, specifying the main type and subtype without parameters. The main media type <bcp14>MUST</bcp14> be <tt>image</tt>.</li>
                        <li><tt>width</tt> - Image width in pixels. Optional. Omitted for SVG files.</li>
                        <li><tt>height</tt> - Image height in pixels. Optional. Omitted for SVG files.</li>
                    </ul>
                    <t>The logos <bcp14>SHOULD</bcp14> include at least one of each of the following:</t>
                    <ul>
                        <li><tt>image/svg+xml</tt></li>
                        <li><tt>image/png</tt> with size 128 by 128</li>
                        <li><tt>image/png</tt> with size 512 by 512</li>
                    </ul>
                    <t>If the server provides images in the SVG format, these images <bcp14>MUST</bcp14> use the SVG Tiny PS Profile specified in <xref target="I-D.svg-tiny-ps-abrotman" />.</t>
                </section>
                <section anchor="help">
                    <name>Help</name>
                    <t>These fields are intended to allow a service provider to provide additional information about configuring user agents.</t>
                    <t>The <tt>documentation</tt> property should link to a document intended for users. It can provide additional information to users about how to configure their user agent. A user agent <bcp14>MAY</bcp14> choose to display a link to this URL. User agents <bcp14>SHOULD NOT</bcp14> display links with a URL scheme other than <tt>https</tt>.</t>
                    <t>The <tt>developer</tt> property should link to a document intended for user agent developers. The document this URL links to can provide additional information to the developer.</t>
                    <t>The <tt>contact</tt> property should provide a way for user agent developers to contact the service providers. It is <em>not</em> intended as a way for users to contact the service provider. User agents <bcp14>MUST NOT</bcp14> display this link in their user interface. This URL would typically be a <tt>mailto</tt> URL or a URL linking to a contact form for developers to use.</t>
                </section>
            </section>
        </section>
        <section anchor="flow">
            <name>Flow</name>
            <t><xref target="flow-overview"/> provides a high-level overview of the automatic configuration process. This section details the individual steps involved in this process.</t>
            <section anchor="flow-user-enters-email-address">
                <name>Email Address</name>
                <t>During the initial configuration process, the user agent requests the user's email address. User agents <bcp14>SHOULD</bcp14> accept any valid <tt>mailbox</tt> format as specified in <xref target="RFC5322" sectionFormat="of" section="3.4"/>.</t>
            </section>
            <section anchor="flow-configuration-source">
                <name>Configuration Source</name>
                <t>After the user provides their email address, the user agent extracts the <tt>domain</tt> part of the user's email address according to <xref target="RFC5322" sectionFormat="of" section="3.4.1"/>. For example:</t>
                <table>
                    <name>Domain from email address</name>
                    <thead>
                        <tr>
                            <th align="left">Text Entered by User</th>
                            <th align="left">domain</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td align="left">jdoe@foo.example.com</td>
                            <td align="left">foo.example.com</td>
                        </tr>
                        <tr>
                            <td align="left">"J Doe" &lt;jdoe@foo.example.com&gt;</td>
                            <td align="left">foo.example.com</td>
                        </tr>
                        <tr>
                            <td align="left">&lt;jdoe@foo.example.com&gt;</td>
                            <td align="left">foo.example.com</td>
                        </tr>
                    </tbody>
                </table>
                <t>This <tt>domain</tt> is then used to retrieve the JSON configuration resource using well-known URIs with DNS-based digest validation.</t>
                <section anchor="well-known-uri">
                    <name>Well-Known Uniform Resource Identifier</name>
                    <t>The user agent retrieves configuration data over HTTP using the format described in <xref target="json-configuration"/>.</t>
                    <t>Configuration retrieval uses <xref target="RFC8615"/> Well-Known URIs. The user agent constructs the URI using the <em>domain</em> from the user's email address and the <em>URI suffix</em> <tt>user-agent-configuration.json</tt>. The detailed URI construction process is specified in <xref target="RFC8615"/>.</t>
                    <t>The domain name <bcp14>MUST</bcp14> support Internationalized Domain Names (IDNs) as defined in <xref target="RFC5890"/> and <xref target="RFC5891"/>. User agents <bcp14>MUST</bcp14> handle both Unicode labels (u-labels) and ASCII Compatible Encoding labels (a-labels) when processing domain names from email addresses, and convert them appropriately for URI construction as specified in <xref target="RFC5891"/>.</t>
                    <t>The URI follows this template:</t>
                    <sourcecode><![CDATA[
========== NOTE: '\' line wrapping per RFC 8792 ===========

https://ua-auto-config.{domain}/\
  .well-known/user-agent-configuration.json
]]></sourcecode>
                    <t>If the user's email address' domain is <tt>foo.example.com</tt>, the user agent constructs the following URI:</t>
                    <sourcecode><![CDATA[
========== NOTE: '\' line wrapping per RFC 8792 ===========

https://ua-auto-config.foo.example.com/\
  .well-known/user-agent-configuration.json
]]></sourcecode>
                    <t>This URI always uses the <tt>https</tt> scheme. User agents <bcp14>MUST</bcp14> retrieve the configuration file only via <tt>https</tt> (HTTP over TLS).</t>
                    <t>The user agent <bcp14>MUST</bcp14> validate that the connection is secured by TLS, and this connection <bcp14>MUST</bcp14> use TLS 1.3 (<xref target="RFC8446" />) or higher. If the user agent follows any HTTP redirect while retrieving the configuration, every hop <bcp14>MUST</bcp14> likewise use the <tt>https</tt> scheme over TLS 1.3 or higher. See <xref target="tls-validation" /> and <xref target="tls-min-version" /> for details about transport security with respect to retrieving the configuration.</t>
                    <t>As described in <xref target="json-configuration"/>, the configuration uses the media type <tt>application/json</tt>. The user agent <bcp14>MUST</bcp14> validate that the <tt>Content-Type</tt> of the returned resource is <tt>application/json</tt>.</t>
                    <t>The HTTP server that serves the JSON configuration <bcp14>MUST NOT</bcp14> require any form of HTTP authentication to return the configuration.</t>
                    <t>For example, the user agent sends the following request:</t>
                    <sourcecode><![CDATA[
GET /.well-known/user-agent-configuration.json HTTP/1.1
host: ua-auto-config.foo.example.com
user-agent: curl/8.4.0
accept: application/json
]]></sourcecode>
                    <t>and the server responds:</t>
                    <sourcecode><![CDATA[
HTTP/1.1 200 OK
server: nginx/1.25.3
date: Thu, 23 Oct 2025 10:30:00 GMT
content-type: application/json
content-length: 1184

{
    "protocols": {
        "jmap": {
...
]]></sourcecode>
                </section>
                <section anchor="flow-dns-digest-validation">
                    <name>DNS-Based Digest Validation</name>
                    <t>After retrieving the auto-configuration resource from the well-known URI as described in <xref target="well-known-uri" />, the user agent <bcp14>SHOULD</bcp14> validate its integrity before use. This validation is performed by comparing a locally computed digest of the resource against a digest published in a DNS TXT resource record (RR).</t>
                    <t>This validation depends on the integrity of the DNS answer, and it therefore only adds to the protection that TLS already provides (<xref target="tls-validation" />) if the user agent can obtain that answer over a trusted channel. A user agent that cannot do so, or that has no way to perform DNS queries at all, <bcp14>MAY</bcp14> omit this validation. <xref target="sec-dns" /> discusses this trade-off.</t>
                    <t>A user agent that performs this validation <bcp14>MUST</bcp14> perform it as described in <xref target="validation-procedure" />. If the validation fails, the user agent <bcp14>MUST</bcp14> ignore the auto-configuration resource.</t>
                    <t>Providers <bcp14>MUST</bcp14> publish the DNS TXT RR described in <xref target="dns-record-specification" />, using the SHA-256 digest algorithm, regardless of whether a particular user agent validates it. <xref target="dns-record-rollover" /> describes how to publish this record when the configuration changes.</t>
                    <section anchor="validation-procedure">
                        <name>Validation Procedure</name>
                        <t>
                            A user agent that validates the auto-configuration
                            resource <bcp14>MUST</bcp14> perform the following steps:
                        </t>
                        <ol spacing="normal">
                            <li>
                                Let the "decoded message content" be the payload body of the HTTP
                                response after all <tt>Transfer-Encoding</tt> (e.g., "chunked") and
                                <tt>Content-Encoding</tt> (e.g., "gzip", "br") transformations have been
                                reversed. This is the final, decompressed representation of the resource.
                                See <xref target="RFC9112" sectionFormat="of" section="6.1"/> and
                                <xref target="RFC9110" sectionFormat="of" section="8.4"/> for details on these encodings.
                            </li>
                            <li>
                                Construct a DNS query <tt>QNAME</tt> using the template
                                <tt>_ua-auto-config.{domain}</tt>, where <tt>{domain}</tt> is
                                the domain part of the user's email address (e.g., "foo.example.com"
                                for "jdoe@foo.example.com").
                            </li>
                            <li>
                                Perform a DNS query for the <tt>TXT</tt> RR type at the constructed
                                <tt>QNAME</tt>. The response may contain multiple <tt>TXT</tt> RRs.
                            </li>
                            <li>
                                <t>For each <tt>TXT</tt> RR returned in the DNS response:</t>
                                <ol type="a">
                                    <li>
                                        Parse the record according to the syntax in
                                        <xref target="dns-record-specification" />. If the record is
                                        malformed or is missing any of the mandatory tags (<tt>v</tt>,
                                        <tt>a</tt>, <tt>d</tt>), discard this RR and proceed to the next one.
                                    </li>
                                    <li>
                                        Let the "remote algorithm" be the value of the <tt>a</tt> tag.
                                        If the user agent does not support this algorithm, discard this
                                        RR and proceed to the next one.
                                    </li>
                                    <li>
                                        Let the "remote digest" be the Base64-decoded value of the
                                        <tt>d</tt> tag. If decoding fails, discard this RR and proceed
                                        to the next one.
                                    </li>
                                    <li>
                                        Using the "remote algorithm", compute a "local digest" of the
                                        "decoded message content" obtained in step 1.
                                    </li>
                                    <li>
                                        Perform a byte-for-byte comparison of the "local digest" and
                                        the "remote digest". If they are identical, the validation is
                                        successful. The user agent <bcp14>MUST</bcp14> immediately stop
                                        processing further <tt>TXT</tt> RRs and <bcp14>MAY</bcp14> use
                                        the auto-configuration resource.
                                    </li>
                                </ol>
                            </li>
                            <li>
                                If, after checking all valid and supported <tt>TXT</tt> RRs, no
                                match is found, the validation has failed. The user agent
                                <bcp14>MUST</bcp14> discard the "decoded message content" and behave as if
                                no auto-configuration resource was found.
                            </li>
                        </ol>

                        <t>
                            Note: A compliant HTTP client library will typically handle the decoding
                            of <tt>Transfer-Encoding</tt> and <tt>Content-Encoding</tt>
                            transparently. The requirement in this document is to ensure that the
                            digest is computed on the final data, not on an intermediate, encoded
                            representation.
                        </t>
                    </section>
                    <section anchor="dns-record-specification">
                        <name>DNS Resource Record for Auto-Configuration</name>
                        <t>
                            Configuration information for a given domain is published as a DNS TXT
                            resource record (RR) at a special name, <tt>_ua-auto-config</tt>,
                            prepended to the domain name. For example, for the domain
                            <tt>example.com</tt>, the lookup would be for a TXT record at
                            <tt>_ua-auto-config.example.com</tt>.
                        </t>

                        <section anchor="dns-record-syntax">
                            <name>Record Syntax</name>
                            <t>The content of the TXT RR is a string of <tt>tag=value</tt> pairs separated by semicolons (<tt>;</tt>). Tags are short ASCII strings that identify a particular parameter. Values are ASCII strings whose format depends on the tag.</t>
                            <t>As described in <xref target="RFC1035" sectionFormat="of" section="3.3.14"/>, the RDATA of a TXT RR consists of one or more character-strings, each of which can hold at most 255 octets. If the RDATA of a single TXT RR contains more than one character-string, a user agent <bcp14>MUST</bcp14> concatenate those character-strings, in the order in which they appear in the RDATA and without adding any separator, and treat the result as the content of the record. A user agent <bcp14>MUST NOT</bcp14> concatenate the contents of separate TXT RRs; each RR is parsed and evaluated on its own, as described in <xref target="validation-procedure"/>. The records defined by this document fit within a single character-string, and providers <bcp14>SHOULD</bcp14> publish them as one.</t>
                            <t>The formal syntax of the record is described using ABNF <xref target="RFC5234"/> as follows. The core rules <tt>ALPHA</tt>, <tt>DIGIT</tt>, <tt>HTAB</tt>, and <tt>WSP</tt> are defined in <xref target="RFC5234" sectionFormat="of" section="B.1"/>, and the Base64 alphabet is the one defined in <xref target="RFC4648" sectionFormat="of" section="4"/>.</t>
                            <artwork name="ABNF for the TXT Record" type="abnf"><![CDATA[
config-record    = tag-spec *( *WSP ";" *WSP tag-spec ) *WSP [";"]

tag-spec         = version-tag / alg-tag / digest-tag / future-tag

version-tag      = "v" *WSP "=" *WSP "UAAC1"
alg-tag          = "a" *WSP "=" *WSP digest-algorithm
digest-algorithm = "sha256"
digest-tag       = "d" *WSP "=" *WSP 1*base64-char

future-tag       = 1*tag-name-char *WSP "=" *WSP 1*tag-value-char

tag-name-char    = ALPHA / DIGIT
tag-value-char   = %x21-3A / %x3C-7E ; Any visible ASCII char
                                     ; except semicolon

base64-char      = ALPHA / DIGIT / "+" / "/" / "="
]]></artwork>
                            <t>ABNF string literals are case-insensitive (<xref target="RFC5234" sectionFormat="of" section="2.3"/>), but the tag names and tag values defined by this document are not; see <xref target="dns-record-tags"/>.</t>
                        </section>

                        <section anchor="dns-record-tags">
                            <name>Tags</name>
                            <t>
                                The following tags are defined. Tag names and tag values are
                                case-sensitive. The tag names <tt>v</tt>, <tt>a</tt>, and <tt>d</tt>
                                and the tag value <tt>sha256</tt> <bcp14>MUST</bcp14> be lowercase,
                                and the tag value <tt>UAAC1</tt> <bcp14>MUST</bcp14> be uppercase, as
                                shown in this document. A record that uses different case for any of
                                these <bcp14>MUST</bcp14> be treated as invalid and ignored, as
                                described in <xref target="dns-record-parsing-rules"/>.
                            </t>
                            <table>
                                <name>Defined Tags</name>
                                <thead>
                                    <tr><th align="left">Tag</th><th align="left">Description</th><th align="left">Status</th></tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td><tt>v</tt></td>
                                        <td>Version. The value <bcp14>MUST</bcp14> be "UAAC1" for records
                                            compliant with this specification.</td>
                                        <td>Mandatory</td>
                                    </tr>
                                    <tr>
                                        <td><tt>a</tt></td>
                                        <td>Digest Algorithm. The value <bcp14>MUST</bcp14> be "sha256". This identifies the algorithm used to create the digest in the 'd' tag.</td>
                                        <td>Mandatory</td>
                                    </tr>
                                    <tr>
                                        <td><tt>d</tt></td>
                                        <td>Digest. The Base64-encoded digest of the JSON resource described in <xref target="well-known-uri" />. The encoding <bcp14>MUST</bcp14> follow <xref target="RFC4648" sectionFormat="of" section="4"/>.</td>
                                        <td>Mandatory</td>
                                    </tr>
                                </tbody>
                            </table>
                        </section>
                        <section anchor="dns-record-digest-algorithm">
                            <name>Digest Algorithm</name>
                            <t>
                                SHA-256 ("sha256") as defined in <xref target="RFC6234" /> is the
                                supported digest algorithm.
                            </t>
                            <t>
                                The digest is computed over the raw bytes of the JSON resource retrieved
                                from the well-known URI, after any HTTP transfer or content encoding
                                has been decoded.
                            </t>
                        </section>
                        <section anchor="dns-record-parsing-rules">
                            <name>Parsing Rules</name>
                            <t>A user agent parsing the record <bcp14>MUST</bcp14> adhere to the following rules:</t>
                            <ul spacing="normal">
                                <li>
                                    The record <bcp14>MUST</bcp14> contain the <tt>v</tt>, <tt>a</tt>,
                                    and <tt>d</tt> tags. If any of these tags are missing, the record
                                    is invalid and <bcp14>MUST</bcp14> be ignored.
                                </li>
                                <li>
                                    The order of the tags is not significant.
                                </li>
                                <li>
                                    Whitespace (<tt>WSP</tt>) is permitted on either side of the
                                    <tt>=</tt> and <tt>;</tt> separators and <bcp14>MUST</bcp14> be ignored.
                                </li>
                                <li>
                                    If a tag is encountered that is not defined in this document
                                    (e.g., a tag from a future version), the parser
                                    <bcp14>MUST</bcp14> ignore that entire <tt>tag=value</tt> pair.
                                    This allows for future extensions.
                                </li>
                                <li>
                                    If any of the mandatory tags (<tt>v</tt>, <tt>a</tt>) have values
                                    other than those specified in this document, including a value
                                    that differs only in case, the record is invalid
                                    and <bcp14>MUST</bcp14> be ignored.
                                </li>
                            </ul>
                        </section>
                    </section>
                    <section anchor="dns-record-rollover">
                        <name>Changing the Configuration</name>
                        <t>The digest in the TXT RR has to match the configuration document that the user agent retrieves. Because DNS answers are cached for the duration of the record's TTL, and because HTTP caches and content delivery networks can serve a previous version of the configuration document for some time, a provider that changes its configuration document has a window during which a user agent can retrieve one version of the document and the digest of another. During that window, validation as described in <xref target="validation-procedure"/> fails, and user agents behave as if no configuration were published.</t>
                        <t>To avoid this, a provider that changes its configuration document <bcp14>SHOULD</bcp14> publish, for the duration of the change, one TXT RR for the previous version of the document and one TXT RR for the new version. The validation procedure in <xref target="validation-procedure"/> accepts a configuration document that matches any of the records returned for the <tt>QNAME</tt>, so a user agent succeeds regardless of which version of the document it retrieves. Once the provider is confident that no cached copy of the previous version is being served anymore, it removes the record for the previous version.</t>
                        <t>Providers <bcp14>SHOULD</bcp14> keep the TTL of the TXT RR short enough that this window stays short, and <bcp14>SHOULD</bcp14> take the caching directives that they set on the configuration document (<xref target="RFC9111"/>) into account when deciding how long to publish both records.</t>
                    </section>
                    <section anchor="flow-primary-source-example">
                        <name>Example</name>
                        <t>This example demonstrates the configuration retrieval process for a user with email address <tt>user@example.com</tt>.</t>
                        <t>The user agent performs the following steps:</t>
                        <ol spacing="normal">
                            <li>
                                <t>Constructs the well-known URI from the email domain:</t>
                                <sourcecode><![CDATA[
========== NOTE: '\' line wrapping per RFC 8792 ===========

https://ua-auto-config.example.com/\
  .well-known/user-agent-configuration.json
]]></sourcecode>
                            </li>
                            <li>
                                <t>Retrieves the JSON configuration over HTTPS and receives:</t>
                                <sourcecode><![CDATA[
{
    "protocols": {
        "jmap": {
            "url": "https://jmap.example.com/session"
        },
        "imap": {
            "host": "imap.example.com"
        },
        "submit": {
            "host": "smtp.example.com"
        }
    },
    "authentication": {
        "oauth-public": {
            "issuer": "https://auth.example.com"
        },
        "password": true
    },
    "info": {
        "provider": {
            "name": "Example Provider"
        }
    }
}
                                ]]></sourcecode>
                            </li>
                            <li>
                                <t>Queries DNS for TXT record at <tt>_ua-auto-config.example.com</tt> and receives:</t>
                                <sourcecode><![CDATA[
========== NOTE: '\' line wrapping per RFC 8792 ===========

_ua-auto-config.example.com.    TXT    "v=UAAC1; a=sha256; \
  d=K7gNU3sdo+OL0wNhqoVWhr3g6s1xYv72ol/pe/Unols="
                                ]]></sourcecode>
                            </li>
                            <li>
                                <t>Computes the SHA-256 digest of the retrieved JSON configuration and verifies it matches the digest in the DNS TXT record.</t>
                            </li>
                            <li>
                                <t>Since validation succeeds, the user agent may proceed to use this configuration for account setup.</t>
                            </li>
                        </ol>
                    </section>
                </section>
            </section>
            <section anchor="flow-config-json-validation">
                <name>Configuration JSON Validation</name>
                <t>After successfully retrieving a configuration resource, user agents <bcp14>MUST</bcp14> validate that the configuration contains valid JSON syntax according to <xref target="RFC8259"/>. Additionally, user agents <bcp14>MUST</bcp14> validate the retrieved configuration against the JSON schema provided in <xref target="configuration-schema"/>. If the JSON syntax is invalid, or if the configuration does not validate against that schema, user agents <bcp14>MUST</bcp14> ignore the configuration entirely and not use any portion of it.</t>
                <t>User agents <bcp14>MUST</bcp14> process only the properties that they support and <bcp14>MUST</bcp14> ignore properties not specified in the schema. This requirement enables future extensions of the format without breaking existing user agent implementations.</t>
            </section>
            <section anchor="flow-selecting-protocols">
                <name>Selecting Protocols and Authentication</name>
                <t>After successfully retrieving and validating the configuration JSON, the user agent needs to determine:</t>
                <ul>
                    <li>Which protocols to use</li>
                    <li>Which authentication mechanism to employ</li>
                </ul>
                <t>Both user agents and servers support multiple protocols. The user agent needs to decide which protocols to use and determine whether the protocols specified in the configuration are sufficient to proceed. This document does not provide recommendations regarding protocol preferences or minimum protocol requirements, as these decisions depend on the specific needs and implementation details of individual user agents.</t>
                <t>The automatic configuration flow supports two distinct authentication types:</t>
                <ul>
                    <li>Username and password-based authentication</li>
                    <li>OAuth-based authentication</li>
                </ul>
                <t>User agents can support one or both authentication methods. Similarly, servers for each protocol can support one or both methods. Additionally, the specific implementation details of authentication can vary between protocols.</t>
                <t>User agents <bcp14>SHOULD</bcp14> probe each protocol and server of interest to determine compatible authentication methods. This probing process can influence the user agent's protocol selection and allows the user agent to verify server availability.</t>
                <t>This document does not provide recommendations regarding protocol preferences. The user agent <bcp14>MUST</bcp14> make these decisions based on its needs.</t>
                <t>If the user agent determines that it can use either password-based authentication or OAuth authentication, the user agent <bcp14>SHOULD</bcp14> prefer OAuth-based authentication.</t>
                <section anchor="flow-probing-oauth">
                    <name>OAuth</name>
                    <t>The JSON configuration includes an <tt>oauth-public</tt> entry when the provider supports OAuth. The <tt>issuer</tt> value specifies the authorization server's issuer identifier. According to <xref target="I-D.ietf-mailmaint-oauth-public" sectionFormat="of" section="2.2"/>, the OAuth Authorization Server Metadata is served at a URL constructed using this <tt>issuer</tt> value with the template</t>
                    <sourcecode><![CDATA[
{issuer}/.well-known/oauth-authorization-server
                    ]]></sourcecode>
                    <t>For example, if the JSON configuration contains this entry:</t>
                    <sourcecode><![CDATA[
"oauth-public" : {
    "issuer" : "https://auth.example.com"
},
                    ]]></sourcecode>
                    <t>the OAuth Authorization Server Metadata would be at the URL <tt>https://auth.example.com/.well-known/oauth-authorization-server</tt>.</t>
                    <t>Note that as defined in <xref target="RFC8414" />, the authorization server's issuer identifier <bcp14>MUST</bcp14> be a URL that uses the <tt>https</tt> scheme without any query or fragment components. User agents <bcp14>MUST</bcp14> verify that the <tt>issuer</tt> value is valid according to <xref target="RFC8414" />. Providers <bcp14>SHOULD NOT</bcp14> publish an <tt>issuer</tt> value with a trailing slash, and user agents <bcp14>MUST</bcp14> construct the metadata URL as described in <xref target="RFC8414" sectionFormat="of" section="3.1"/>, which inserts the well-known URI path between the host and any path component of the issuer identifier.</t>
                    <t>Before the user agent chooses to use OAuth for any protocols, it <bcp14>SHOULD</bcp14> make sure that it can retrieve the OAuth Authorization Server Metadata from the corresponding URI. This retrieval, and any HTTP redirect the user agent follows while performing it, <bcp14>MUST</bcp14> use the <tt>https</tt> scheme over TLS 1.3 (<xref target="RFC8446" />) or higher, as required by <xref target="tls-min-version" />.</t>
                    <t>The presence of the <tt>oauth-public</tt> object describes the provider, not any individual server. The user agent <bcp14>SHOULD</bcp14> therefore still probe each server that it is interested in, as described in <xref target="flow-probing-http-auth-mechanism" /> and <xref target="flow-probing-text-auth-mechanism" />, to check that the server itself supports OAuth. The user agent <bcp14>MUST NOT</bcp14> perform any authentication while probing, but it <bcp14>SHOULD</bcp14> record which mechanism(s) each server supports.</t>
                </section>
                <section anchor="flow-probing-http-auth-mechanism">
                    <name>HTTP Authentication Mechanisms</name>
                    <t>To check which HTTP authentication schemes a particular HTTP server supports, the user agent <bcp14>SHOULD</bcp14> send a request to the server's endpoint without any <tt>Authorization</tt> header. The user agent <bcp14>SHOULD</bcp14> choose an HTTP method that requires access privileges on the target resource, so that a server that supports authentication responds with a 401 <tt>Unauthorized</tt> status code and a <tt>www-authenticate</tt> response header. The appropriate method depends on the protocol.</t>
                    <t>For the WebDAV-based protocols CalDAV (<xref target="RFC4791"/>), CardDAV (<xref target="RFC6352"/>), and WebDAV (<xref target="RFC4918"/>), the user agent <bcp14>SHOULD</bcp14> use a <tt>PROPFIND</tt> request as defined in <xref target="RFC4918" sectionFormat="of" section="9.1"/>. <tt>PROPFIND</tt> is the canonical request used to bootstrap a WebDAV connection: it requires access privileges on the collection and therefore reliably triggers authentication. A plain <tt>GET</tt> request against a WebDAV collection is not a reliable probe, because how servers handle it varies widely. The bootstrapping procedure in <xref target="RFC6764" sectionFormat="of" section="6"/> uses the same request, a <tt>PROPFIND</tt> for the <tt>DAV:current-user-principal</tt> property (<xref target="RFC5397"/>). A minimal probe might look like this:</t>
                    <sourcecode><![CDATA[
PROPFIND /dav/ HTTP/1.1
host: dav.example.com
depth: 0
content-type: application/xml; charset=utf-8

<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:">
  <prop>
    <current-user-principal/>
  </prop>
</propfind>
                    ]]></sourcecode>
                    <t>For all other HTTP-based protocols, notably JMAP (<xref target="RFC8620"/>), the user agent <bcp14>SHOULD</bcp14> use a <tt>GET</tt> request. For example:</t>
                    <sourcecode><![CDATA[
GET /jmap/session HTTP/1.1
host: api.example.com
accept: application/json
                    ]]></sourcecode>
                    <t>As detailed in <xref target="RFC9110"/> the server <bcp14>SHOULD</bcp14> respond to either request with a 401 <tt>Unauthorized</tt> status code and a <tt>www-authenticate</tt> response header indicating which authentication scheme(s) are supported.</t>
                    <t>The user agent <bcp14>SHOULD</bcp14> include an <tt>accept</tt> header with the content type it would expect for the given protocol. For JMAP, for example, the user agent <bcp14>SHOULD</bcp14> include <tt>accept: application/json</tt> as a header in this request.</t>
                    <t>If the server supports OAuth, the <tt>www-authenticate</tt> response header would include the <tt>Bearer</tt> scheme, which <xref target="RFC6750"/> defines; <xref target="RFC6749"/> describes the OAuth framework itself in more detail. <xref target="RFC7617"/> and <xref target="RFC7616"/> describe username + password authentication using the so-called 'Basic' HTTP authentication scheme and the HTTP digest access authentication respectively. Other password based authentication mechanisms exist for HTTP, but their discussion is outside the scope of this document.</t>
                    <t>For example, a response header</t>
                    <sourcecode><![CDATA[
HTTP/1.1 401 Unauthorized
www-authenticate: Bearer realm="api.example.com"
                    ]]></sourcecode>
                    <t>would indicate that the server supports OAuth.</t>
                    <t>Alternatively, a response such as</t>
                    <sourcecode><![CDATA[
========== NOTE: '\' line wrapping per RFC 8792 ===========

HTTP/1.1 401 Unauthorized
www-authenticate: Digest realm="api.example.com", qop="auth", \
algorithm=SHA-256, nonce="dcd98b7102dd2f0e8b11d0f600bfb0c093", \
opaque="5ccc069c403ebaf9f0171e9517f40e41"
                    ]]></sourcecode>
                    <t>would indicate that the server supports digest access authentication.</t>
                    <t>Details of HTTP authentication are described in <xref target="RFC9110"/> but it is worth noting that a server supporting multiple authentication methods can return either multiple <tt>www-authenticate</tt> header fields in its response or a single <tt>www-authenticate</tt> header field with multiple authentication methods.</t>
                    <t>These probing requests are sent to the HTTP-based protocol endpoints from the configuration, which use the <tt>https</tt> scheme, and they are subject to the transport security requirements in <xref target="tls-min-version" />. A server <bcp14>MAY</bcp14> respond to a probe with a redirect, which lets a provider use the configured URL as a stable "front door" that redirects to the server that actually handles the protocol. The user agent <bcp14>MUST</bcp14> follow such redirects subject to the constraints in <xref target="sec-redirects" />. For the WebDAV-based protocols, the URL reached after these redirects is the context path the user agent uses for the protocol itself, as described in <xref target="json-config-protocols" />.</t>
                </section>
                <section anchor="flow-probing-text-auth-mechanism">
                    <name>Authentication Mechanisms of Text-Based Protocols</name>
                    <t>For the text-based protocols (IMAP, POP3, Submission, and ManageSieve) the user agent <bcp14>SHOULD</bcp14> connect to the server to check that:</t>
                    <ul>
                    <li>the user agent can reach the server,</li>
                    <li>the server implements the expected protocol, and</li>
                    <li>which authentication mechanisms the server supports.</li>
                    </ul>
                    <t>The user agent <bcp14>MUST</bcp14> attempt to connect to the server on the default ports:</t>
                    <ul>
                    <li>port 993 for IMAP</li>
                    <li>port 995 for POP3</li>
                    <li>port 465 for Submission</li>
                    </ul>
                    <t>using TLS from the start of the connection ("direct TLS", also known as "implicit TLS"), as specified in <xref target="RFC8314"/>. These connections <bcp14>MUST</bcp14> use TLS 1.3 (<xref target="RFC8446" />) or higher, as required by <xref target="tls-min-version" />.</t>
                    <t><cref anchor="todo-managesieve" source="editor">TODO: ManageSieve needs a port in the list above. This document requires direct TLS for all text-based protocols, but <xref target="RFC5804"/> defines only port 4190 with STARTTLS, and no port for ManageSieve over direct TLS is registered. Resolve this before publication, for example by requesting a port assignment for ManageSieve over direct TLS, or by scoping ManageSieve out of this document.</cref></t>
                    <t>The user agent <bcp14>SHOULD NOT</bcp14> attempt to connect to a text-based protocol server on its cleartext port.</t>
                    <t>The user agent <bcp14>MUST NOT</bcp14> allow for configuration with a cleartext protocol that is not protected by TLS.</t>
                    <t>The user agent <bcp14>MUST</bcp14> validate that the connection is secured by TLS, and that the server certificate is valid and matches the expected domain name. See <xref target="tls-validation" /> for details on transport security validation.</t>
                    <t>If the server announces the <tt>OAUTHBEARER</tt> SASL authentication method (<xref target="RFC7628"/>), the user agent can assume that this server supports using <xref target="I-D.ietf-mailmaint-oauth-public" />. For IMAP for example, if the server's <tt>CAPABILITY</tt> contains <tt>AUTH=OAUTHBEARER</tt> this would indicate this support.</t>
                    <t>Servers <bcp14>SHOULD NOT</bcp14> announce support for the <tt>OAUTHBEARER</tt> SASL mechanism if they do not support <xref target="I-D.ietf-mailmaint-oauth-public" />. Servers <bcp14>MUST</bcp14> announce support for the <tt>OAUTHBEARER</tt> SASL mechanism if they support OAuth Profile for Open Public Clients. Servers <bcp14>SHOULD NOT</bcp14> use the <tt>XOAUTH2</tt> SASL mechanism.</t>
                    <t>There are various SASL authentication mechanisms for password-based authentication, and additionally IMAP and POP3 also support password-based authentication through <tt>LOGIN</tt> and <tt>APOP</tt> respectively. The user agent needs to probe each server to determine which authentication methods are supported by both the user agent and the server.</t>
                    <section anchor="probing-text-auth-mechanism-imap">
                        <name>IMAP</name>
                        <t>The IMAP protocol provides various other authentication mechanisms. There are various SASL mechanisms for username + password authentication. <xref target="RFC4959"/> describes how to use SASL with IMAP.</t>
                        <t>Unless the server sends the <tt>LOGINDISABLED</tt> capability, user agents know that they can use the <tt>LOGIN</tt> command for username + password authentication.</t>
                        <t>For IMAP, a sample session might look like this:</t>
                        <sourcecode><![CDATA[
========== NOTE: '\' line wrapping per RFC 8792 ===========

S: * OK [CAPABILITY IMAP4rev2 IMAP4rev1 SASL-IR AUTH=PLAIN \
AUTH=OAUTHBEARER] IMAP Server
C: A1 LOGOUT
S: * BYE IMAP Server logging out
S: A1 OK LOGOUT completed
                        ]]></sourcecode>
                        <t>In this case the server returned its IMAP capabilities as part of the so-called greeting messages. The support for the <tt>OAUTHBEARER</tt> SASL authentication mechanism indicates to the user agent that the server supports OAuth. Similarly the <tt>PLAIN</tt> SASL authentication mechanism indicates that the server supports username + password authentication. The absence of the <tt>LOGINDISABLED</tt> also indicates support for username and password authentication.</t>
                        <t>If the server doesn't include its capabilities in the server greeting, the user agent <bcp14>SHOULD</bcp14> send a <tt>CAPABILITY</tt> command as outlined in <xref target="RFC9051" sectionFormat="of" section="6.1.1" />. The user agent <bcp14>SHOULD</bcp14> send a <tt>LOGOUT</tt> command as outlined in <xref target="RFC9051" sectionFormat="of" section="6.1.3" /> and check that the server sends an untagged <tt>BYE</tt> response.</t>
                    </section>
                    <section anchor="probing-text-auth-mechanism-submit">
                        <name>Submission</name>
                        <t>Message submission uses the SMTP protocol <xref target="RFC5321"/> and similarly announces which authentication mechanisms it supports. <xref target="RFC4954"/> describes how to use SASL with SMTP.</t>
                        <t>The user agent would use the <tt>EHLO</tt> command to retrieve the submission server's supported authentication mechanisms. For example:</t>
                        <sourcecode><![CDATA[
S: 220 smtp.example.com ESMTP service ready
C: EHLO client.example.com
S: 250-smtp.example.com
S: 250-PIPELINING
S: 250-SIZE 10240000
S: 250-AUTH PLAIN LOGIN OAUTHBEARER
S: 250-ENHANCEDSTATUSCODES
S: 250 8BITMIME
C: QUIT
S: 221 Bye
                        ]]></sourcecode>
                        <t><xref target="RFC5321" sectionFormat="of" section="3.2" /> describes this client initiation of the SMTP protocol. <xref target="RFC4954" /> describes SMTP authentication in detail. In the above example <tt>PLAIN</tt> and <tt>LOGIN</tt> indicate that the server supports username + password based authentication, and <tt>OAUTHBEARER</tt> indicates that the server supports OAuth.</t>
                        <t>The user agent <bcp14>SHOULD</bcp14> send a <tt>QUIT</tt> command and check for the server's <tt>221 Bye</tt> response.</t>
                    </section>
                    <section anchor="probing-text-auth-mechanism-pop3">
                        <name>POP3</name>
                        <t>For POP3 <xref target="RFC5034"/> describes how to use SASL. POP3 additionally supports password based authentication using its <tt>USER</tt> and <tt>PASS</tt> commands, or through the optional <tt>APOP</tt> command. The user agent can check which SASL authentication methods the server supports using the <tt>CAPA</tt> command.</t>
                        <t>For example:</t>
                        <sourcecode><![CDATA[
S: +OK pop.example.com POP3 server ready
C: CAPA
S: +OK List of capabilities follows
S: SASL PLAIN OAUTHBEARER
S: IMPLEMENTATION BlurdyBlurp POP3 server
S: .
C: QUIT
S: +OK POP3 server signing off (maildrop empty)
                        ]]></sourcecode>
                        <t>The user agent <bcp14>SHOULD</bcp14> send a <tt>QUIT</tt> command and check for the server's <tt>+OK</tt> response.</t>
                    </section>
                </section>
            </section>
            <section anchor="flow-confirming-hostnames">
                <name>Confirming Server Names</name>
                <t>Before any credentials are entered, the user agent <bcp14>SHOULD</bcp14> display to the user the hostnames of all servers that it intends to authenticate with, and request explicit confirmation. This list of server hostnames gives the user a chance to validate if they want to move ahead.</t>
                <t>The user agent <bcp14>MAY</bcp14> choose to limit the hostnames to their registrable domains when displaying this list. Instead of displaying <tt>mail.example.com</tt> the user agent would display <tt>example.com</tt>, and instead of <tt>mail.example.co.uk</tt> it would display <tt>example.co.uk</tt>. Limiting the hostnames to their registrable domains helps users identify if this is the domain they intend to connect to or not.</t>
                <t>At least the registrable domains of all involved hostnames <bcp14>MUST</bcp14> be displayed clearly and prominently. The user agent <bcp14>MUST NOT</bcp14> cut off parts of long registrable domains, to avoid spoofing. At least 63 characters of the registrable domain <bcp14>MUST</bcp14> be displayed.</t>
                <t>If the user mistyped their email address in <xref target="flow-user-enters-email-address" />, letting the user confirm the server hostnames gives the user a chance to notice this.</t>
                <t>When the user agent has followed an HTTP redirect while probing a server (see <xref target="flow-probing-http-auth-mechanism" /> and <xref target="sec-redirects" />), the hostname it displays for that server <bcp14>MUST</bcp14> be the hostname reached after all redirects have been followed, not the hostname taken from the configuration. Otherwise the user could confirm a hostname that differs from the one the user agent ultimately authenticates with.</t>
                <t>User agents can enhance the user experience by using the <tt>info</tt> section of the configuration (described in <xref target="json-config-info" />) to display the provider's name and logo during this configuration step.</t>
                <t><xref target="sec-domain-names" /> lists security considerations related to the user confirming these hostnames.</t>
            </section>
            <section anchor="flow-username">
                <name>Username</name>
                <t>For password-based authentication, the full <tt>addr-spec</tt> part of the email address <bcp14>MUST</bcp14> be used as the username. For example:</t>
                <table>
                    <name>Username from email address</name>
                    <thead>
                        <tr>
                            <th align="left">Text Entered by User</th>
                            <th align="left">username</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td align="left">jdoe@example.com</td>
                            <td align="left">jdoe@example.com</td>
                        </tr>
                        <tr>
                            <td align="left">"J Doe" &lt;jdoe@example.com&gt;</td>
                            <td align="left">jdoe@example.com</td>
                        </tr>
                        <tr>
                            <td align="left">&lt;jdoe@example.com&gt;</td>
                            <td align="left">jdoe@example.com</td>
                        </tr>
                    </tbody>
                </table>
                <t>For OAuth Profile for Open Public Clients, the user agent <bcp14>MUST</bcp14> send this username as the <tt>login_hint</tt> in the authorization request URL.</t>
                <t>The provider <bcp14>MUST</bcp14> ensure that any valid email address that the user might enter
                    during setup is a valid username for all servers given in this configuration.
                    This will require a mapping on the server level from email address to internal
                    username. This mapping happens internally in the server and the user agent
                    is not involved in this mapping.</t>
            </section>
            <section anchor="flow-config-oauth">
                <name>Configuring OAuth</name>
                <t>If the user agent and the provider both support OAuth Profile for Open Public Clients, and if the servers that the user agent wants to use support OAuth, the user agent can configure OAuth.</t>
                <t>The <tt>authentication</tt> section in the JSON configuration described in <xref target="json-config-authentication" /> will let the user agent create a URL to retrieve the OAuth Authorization Server Metadata as described in <xref target="flow-probing-oauth" />. With this metadata, the user agent can then use <xref target="I-D.ietf-mailmaint-oauth-public" /> to configure OAuth.</t>
                <t>Part of this will require opening the authorization request URL in an external browser, which is typically the user's default browser. The user agent <bcp14>SHOULD</bcp14> make it very apparent to the user which hostname is being used for the authorization request URL. The user agent <bcp14>SHOULD</bcp14> make the user confirm at least the registrable domain of the hostname of this URL. This is to minimize the risk of the user exposing their credentials to a third party.</t>
                <t>As described in <xref target="flow-confirming-hostnames" />, the user agent <bcp14>SHOULD</bcp14> also confirm the server hostnames with the user. For OAuth authentication, the user agent <bcp14>SHOULD</bcp14> include the hostname of the authorization request URL in this list of hostnames.</t>
            </section>
            <section anchor="flow-config-password">
                <name>Configuring Password-Based Authentication</name>
                <t>If the user agent and provider both support password-based authentication, and if the servers that the user agent wants to use support password-based authentication, the user agent can configure itself to use these servers.</t>
                <t>The user agent <bcp14>SHOULD</bcp14> at this point ask the user for the password for their account with the provider.</t>
                <t>Once the user has entered their password, the user agent <bcp14>SHOULD</bcp14> validate that it is able to authenticate using the entered password with all servers that it is interested in. Only then would it save the new configuration.</t>
            </section>
        </section>
        <section anchor="oauth-requirements">
            <name>OAuth Requirements</name>
            <t>If OAuth is used, the OAuth authorization server <bcp14>MUST</bcp14> adhere to <xref target="I-D.ietf-mailmaint-oauth-public" />.</t>
            <t>Notably, Dynamic Client Registration <bcp14>MUST</bcp14> be implemented and <bcp14>MUST</bcp14> return a working Client ID in response to the HTTP calls defined by that specification.</t>
            <t>The OAuth scopes defined in <xref target="I-D.ietf-mailmaint-oauth-public" /> <bcp14>MUST</bcp14> be included and <bcp14>MUST</bcp14> give access to the servers returned in the JSON configuration described in <xref target="json-configuration" />.</t>
            <t>A single token <bcp14>MUST</bcp14> work for all servers in the JSON configuration, such that a single user login is sufficient for all services. For that purpose, the user agent will include all relevant scopes in the authorization requests.</t>
        </section>
        <section anchor="security-considerations">
            <name>Security Considerations</name>
            <t>While the mechanism described in this document makes it easier for users to correctly configure their user agent, there's an associated risk with making it easier for users to expose their credentials to a third party.</t>
            <t>User agents using the mechanism described in this document need to design their user interface and user experience such that this risk is minimized. Actual affordances depend on implementation details of the user interface and are outside the scope of this document.</t>
            <section anchor="sec-domain-names">
                <name>Mistyped Domain Names</name>
                <t>As part of the first step of the mechanism described in this document, the user enters their email address. If the user mistyped the domain part of their email address, and if the mistyped domain exists and supports the mechanism described in this document, the user could expose their credentials to the owner of that domain. An attacker could use this in an attempt to gain knowledge of the user's credentials.</t>
                <t>As a result, user agents need to carefully design their user interface and user experience as to let the user know which domain is being used. It would make sense to display this very clearly to the user, before they enter any credentials.</t>
                <t>The user agent would want to display a list of the registrable domains of all the servers that it intends to use. The user can then confirm these.</t>
                <t>When the mechanism described in this document uses OAuth, it would make sense to ask the user to confirm the domains of the servers that will be used and additionally confirm the domains of</t>
                <ul>
                    <li>the URL to retrieve the OAuth Authorization Server Metadata and/or</li>
                    <li>the authorization request URL.</li>
                </ul>
                <t>When asking the user to confirm these domains, it would make sense to only display the registrable domain of those domains. This would make it more difficult for an attacker to do URL obfuscation and use subdomain phishing.</t>
                <t>When using a browser for OAuth, the user agent would want to display the registrable domain that the browser is currently displaying, and update this when redirects happen or new pages are loaded.</t>
            </section>
            <section anchor="sec-attacker-controlled-conf">
                <name>Attacker Controlled JSON Configuration</name>
                <t>If an attacker can direct the user agent to use an attacker-controlled JSON configuration, the attacker would be able to direct the user to servers of the attacker's choosing.</t>
                <t>The transport security requirements in <xref target="tls-validation" /> and the digest validation in <xref target="flow-dns-digest-validation" /> limit an attacker's ability to substitute a configuration in the first place. Presenting the server names for the user to confirm (<xref target="flow-confirming-hostnames" />), following the display guidance in <xref target="sec-domain-names" />, gives the user a chance to notice servers that do not belong to their provider.</t>
                <t>An attacker-controlled configuration could also point a protocol's URL at a host that redirects the user agent elsewhere. <xref target="sec-redirects" /> describes the constraints that user agents apply when following such redirects, including that the user confirms the host reached after all redirects rather than the host named in the configuration.</t>
                <t>None of this is sufficient on its own. The user agent also needs to combine these mechanisms with a conservative trust policy for its TLS when retrieving the JSON configuration.</t>
            </section>
            <section anchor="sec-dns">
                <name>DNS</name>
                <t>The value of the digest validation described in <xref target="flow-dns-digest-validation" /> is that it ties the configuration to the operator of the domain's DNS zone, rather than to whoever operates the host that serves the well-known URI. An attacker who can serve content for <tt>ua-auto-config.{domain}</tt> (for example by compromising a hosting provider or a content delivery network configuration), but who cannot publish records in the domain's zone, cannot make a substituted configuration validate.</t>
                <t>That property only holds if the DNS answer itself is trustworthy, so a user agent that performs this validation needs to take care that an attacker has not altered the DNS response. Using DNSSEC is one method of improving the security aspects of this approach, as is querying a trusted resolver over a channel that provides integrity protection, such as DNS over TLS or DNS over HTTPS. An attacker who can alter DNS responses but cannot defeat the requirements in <xref target="tls-validation" /> can cause the validation to fail for a legitimate configuration, and thereby prevent automatic configuration.</t>
                <t>For this reason, <xref target="flow-dns-digest-validation" /> states this validation as a <bcp14>SHOULD</bcp14> rather than a <bcp14>MUST</bcp14>: a user agent that has no way to obtain DNS answers that it can rely on <bcp14>MAY</bcp14> omit it. Such a user agent relies solely on the transport security requirements in <xref target="tls-validation" /> and <xref target="tls-min-version" />, under which the configuration is retrieved over TLS from a host under the domain of the user's email address with the server certificate validated, together with the user confirming the resulting server names (<xref target="flow-confirming-hostnames" />).</t>
            </section>
            <section anchor="tls-validation">
                <name>Transport Security Validation</name>
                <t>Whenever secure transport is used (including TLS for HTTPS connections and QUIC's TLS-based security layer for HTTP/3), user agents <bcp14>MUST</bcp14> check the certificates presented by the server. This certificate <bcp14>MUST</bcp14> be within its validity period (prior to its expiration date) and <bcp14>MUST</bcp14> chain to a root CA that is trusted by the user agent. The certificate <bcp14>MUST</bcp14> have a subject alternative name (SAN) (<xref target="RFC5280" />) with a DNS-ID (<xref target="RFC9525" />) matching the hostname, per the rules given in <xref target="RFC9525" />. The certificate <bcp14>MAY</bcp14> also be checked for revocation via OCSP (<xref target="RFC6960" />), CRLs (<xref target="RFC5280" />, updated by <xref target="RFC6818" />), or some other mechanism. The general recommendations for the secure use of TLS in <xref target="RFC9325" /> <bcp14>SHOULD</bcp14> be followed.</t>
                <t>If these checks fail or the server certificate is otherwise invalid, the user agent <bcp14>MUST</bcp14> disconnect and <bcp14>MUST NOT</bcp14> use any configuration retrieved from that URI.</t>
                <t>Certificate validation failures represent significant security risks, as they may indicate attempts to redirect users' credentials to an attacker. User agents <bcp14>SHOULD NOT</bcp14> allow users to override certificate validation checks.</t>
                <t>Beyond the minimum TLS version required in <xref target="tls-min-version" />, user agents <bcp14>MAY</bcp14> implement even more restrictive transport security policies for the connections described in this document than those typically required for web browsing, in order to provide stronger security guarantees. For TLS connections, user agents <bcp14>MAY</bcp14> want to further restrict the allowed cipher suites. For QUIC connections, user agents <bcp14>MAY</bcp14> apply similar restrictions to the underlying TLS handshake parameters.</t>
                <section anchor="tls-min-version">
                    <name>Minimum TLS Version</name>
                    <t>Every connection that a user agent establishes as part of the mechanism described in this document <bcp14>MUST</bcp14> be secured using TLS 1.3 (<xref target="RFC8446" />) or higher. This requirement is not limited to retrieval of the JSON configuration; it applies to <em>all</em> services, whether HTTP-based or text-based. This includes, but is not limited to:</t>
                    <ul spacing="normal">
                        <li>retrieval of the JSON configuration from the Well-Known URI (<xref target="well-known-uri" />);</li>
                        <li>connections to HTTP-based protocol servers, such as JMAP, CalDAV, CardDAV, and WebDAV;</li>
                        <li>connections that the user agent itself makes to OAuth endpoints, such as retrieval of the OAuth Authorization Server Metadata (<xref target="flow-probing-oauth" />), dynamic client registration, and token requests; and</li>
                        <li>connections to text-based protocol servers, such as IMAP, POP3, Submission, and ManageSieve.</li>
                    </ul>
                    <t>This requirement applies equally to the TLS layer used by HTTP/1.1 and HTTP/2, and to the TLS-based security layer of QUIC used by HTTP/3.</t>
                    <t>Servers that provide any of these services <bcp14>MUST</bcp14> support TLS 1.3 or higher. If a server does not offer TLS 1.3 or higher, or if a connection using TLS 1.3 or higher cannot be established for any other reason, the user agent <bcp14>MUST NOT</bcp14> proceed with that connection and <bcp14>MUST NOT</bcp14> use the corresponding service. The user agent <bcp14>MUST NOT</bcp14> fall back to an earlier version of TLS, and <bcp14>SHOULD NOT</bcp14> allow users to override this requirement.</t>
                    <t>If the user agent follows an HTTP redirect (for example, any of the 3xx status codes described in <xref target="RFC9110" sectionFormat="of" section="15.4"/>) while retrieving the JSON configuration or while connecting to any HTTP-based protocol server or OAuth endpoint, then <em>every</em> hop in the resulting redirect chain <bcp14>MUST</bcp14> also use the <tt>https</tt> scheme and <bcp14>MUST</bcp14> be secured using TLS 1.3 or higher. The certificate validation requirements described earlier in this section, and the minimum TLS version requirement above, <bcp14>MUST</bcp14> be enforced independently for each hop. If any target in the redirect chain uses a scheme other than <tt>https</tt>, or a connection to it cannot be established using TLS 1.3 or higher, the user agent <bcp14>MUST NOT</bcp14> follow the redirect and <bcp14>MUST</bcp14> abort the operation, discarding any data obtained from that redirect chain. Additional constraints on following redirects are described in <xref target="sec-redirects" />.</t>
                </section>
            </section>
            <section anchor="sec-redirects">
                <name>Following HTTP Redirects</name>
                <t>Several steps of the mechanism described in this document involve HTTP requests that a server can answer with a redirect (any of the 3xx status codes described in <xref target="RFC9110" sectionFormat="of" section="15.4"/>). This includes retrieval of the JSON configuration (<xref target="well-known-uri" />), the HTTP authentication probes (<xref target="flow-probing-http-auth-mechanism" />), and connections that the user agent makes to OAuth endpoints (<xref target="flow-probing-oauth" />). Allowing redirects lets a provider publish a stable URL in the configuration that acts as a "front door" and redirects the user agent to the server that actually handles a protocol.</t>
                <t>Redirects are, however, a security-sensitive feature. The configuration is treated as potentially attacker-influenced (<xref target="sec-attacker-controlled-conf" />), and a redirect can send a probe, and subsequently the user's credentials, to a host that never appeared in the configuration and that the user was never shown. User agents therefore <bcp14>MUST</bcp14> apply the following constraints whenever they follow a redirect for any request described in this document.</t>
                <ol spacing="normal">
                    <li>Every hop in the redirect chain <bcp14>MUST</bcp14> use the <tt>https</tt> scheme and <bcp14>MUST</bcp14> be secured using TLS 1.3 (<xref target="RFC8446" />) or higher, with certificate validation enforced independently for each hop, as required by <xref target="tls-min-version" />.</li>
                    <li>The user agent <bcp14>MUST</bcp14> limit the number of redirects it follows for a single request. This limit <bcp14>MUST NOT</bcp14> exceed 5. If a request would exceed this limit, the user agent <bcp14>MUST NOT</bcp14> follow the additional redirect and <bcp14>MUST</bcp14> abort the operation, discarding any data obtained from that redirect chain.</li>
                    <li>The hostnames that the user agent presents to the user for confirmation (<xref target="flow-confirming-hostnames" />), and that it will authenticate with, <bcp14>MUST</bcp14> be the hostnames of the servers reached after all redirects have been followed, not the hostnames taken from the configuration. If following a redirect changes the host that the user agent will authenticate with, the user agent <bcp14>MUST</bcp14> present that final host for confirmation before any credentials are sent to it.</li>
                </ol>
                <t>Because the user agent probes each server of interest (<xref target="flow-probing-http-auth-mechanism" />) before it asks the user to confirm the server hostnames (<xref target="flow-confirming-hostnames" />), the final host reached after any redirect is known at the time of confirmation.</t>
            </section>
            <section anchor="config-updates">
                <name>Updating the Configuration</name>
                <t>The mechanism described in this document can be used to upgrade a user's configuration. The user agent could check for configurations even when it has a working configuration for an account. If the user agent finds a configuration that is better (in some way) than the already existing configuration, it could then upgrade the existing configuration.</t>
                <t>But in doing so, the user agent would increase the attack window that a potential attacker has. Instead of only giving an attacker the opportunity when the user configures their user agent for the first time, the attacker would now have an opportunity each time the user agent checks for a better configuration. That could be undesirable.</t>
            </section>
            <section anchor="security-provider">
                <name>Provider Information</name>
                <t>Image parsers are a common attack vector, and user agents <bcp14>MUST NOT</bcp14> display the <tt>logo</tt> images described in <xref target="provider" /> unless they can do so in a way that doesn't expose the user agent to such attacks.</t>
                <t>Retrieving a logo also discloses information to whoever operates the host that the <tt>url</tt> of that logo names. That host learns the user agent's IP address, and the fact that this user agent is being set up for this provider, at the time of setup. The host can be operated by a third party, such as a content delivery network, and the configuration is treated as potentially attacker-influenced (<xref target="sec-attacker-controlled-conf" />), so the <tt>url</tt> can name a host that the user has no relationship with and has not been shown. User agents therefore <bcp14>SHOULD NOT</bcp14> retrieve logo images before the user has confirmed the configuration as described in <xref target="flow-confirming-hostnames" />, and <bcp14>MAY</bcp14> choose not to retrieve them at all. Providers <bcp14>SHOULD</bcp14> serve logo images from a host under the same registrable domain as the configuration document itself.</t>
            </section>
        </section>
        <section anchor="iana-considerations">
            <name>IANA Considerations</name>
            <section anchor="iana-proto-registry">
                <name>The User-Agent Auto-Configuration Protocol Registry</name>
                <t>This document establishes the user-agent auto-configuration protocol registry.</t>
                <t>User-agent auto-configuration protocols are registered on the advice of one or more Designated Experts (appointed by the IESG or their delegate), with Specification Required (using terminology from <xref target="RFC8126" />).  However, to allow for the allocation of values prior to publication, the Designated Expert(s) may approve registration once they are satisfied that such a specification will be published.</t>
                <t>Registration requests are sent to the art@ietf.org mailing list for review and comment, with an appropriate subject (e.g., "Request for user-agent auto-configuration protocol: example").</t>
                <t><cref anchor="todo-review-list" source="editor">TODO: confirm the review mailing list for this registry. This document currently names art@ietf.org; the working group may instead want to request a dedicated review list.</cref></t>
                <t>Before a period of 14 days has passed, the Designated Expert(s) will either approve or deny the registration request, communicating this decision both to the review list and to IANA.  Denials should include an explanation and, if applicable, suggestions as to how to make the request successful.  Registration requests that are undetermined for a period longer than 21 days can be brought to the IESG's attention (using the iesg@ietf.org mailing list) for resolution.</t>
                <dl newline="true">
                    <dt>Registry Name:</dt>
                    <dd>User-Agent Auto-Configuration Protocols</dd>
                    <dt>Registration Procedure:</dt>
                    <dd>Specification Required (per <xref target="RFC8126" />)</dd>
                </dl>

                <section anchor="iana-proto-registration-template">
                    <name>Registration Template</name>
                     <dl newline="true">
                         <dt>Name:</dt>
                         <dd>The commonly used name of the protocol</dd>
                         <dt>Protocol Key:</dt>
                         <dd>The JSON key used in the <tt>protocols</tt> object in the JSON configuration described in <xref target="json-configuration"/></dd>
                         <dt>URL Scheme:</dt>
                         <dd>(Optional) The URL scheme to be used for this protocol. HTTP based protocols specify <tt>https</tt>. If left empty, the <tt>protocols</tt> entry in the JSON configuration will only specify a hostname using <tt>host</tt>. If a URL scheme is specified, the JSON configuration entry will instead use <tt>url</tt> with a URL using this URL scheme.</dd>
                         <dt>Specification:</dt>
                         <dd>Which RFC(s) or document(s) specify the protocol</dd>
                         <dt>Additional Properties:</dt>
                         <dd>Which additional property values are present in the protocol's JSON object.</dd>
                     </dl>
                </section>
                <section anchor="initial-registration">
                    <name>Initial Registrations</name>
                    <table>
                        <name>Initial registrations to the User-Agent Auto-Configuration Protocol Registry</name>
                        <thead>
                            <tr>
                                <th align="left">Name</th>
                                <th align="left">Protocol Key</th>
                                <th align="left">URL scheme</th>
                                <th align="left">Specification</th>
                                <th align="left">Additional Properties</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="left">JMAP</td>
                                <td align="left"><tt>jmap</tt></td>
                                <td align="left">https</td>
                                <td align="left"><xref target="RFC8620"/>, <xref target="RFC8621"/>, <xref target="RFC8887"/>, <xref target="RFC9610"/></td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="left">IMAP</td>
                                <td align="left"><tt>imap</tt></td>
                                <td align="left"></td>
                                <td align="left"><xref target="RFC9051"/></td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="left">POP3</td>
                                <td align="left"><tt>pop3</tt></td>
                                <td align="left"></td>
                                <td align="left"><xref target="RFC1939"/>, <xref target="RFC5034"/></td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="left">Submission</td>
                                <td align="left"><tt>submit</tt></td>
                                <td align="left"></td>
                                <td align="left"><xref target="RFC6409"/>, <xref target="RFC5321"/></td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="left">CalDAV</td>
                                <td align="left"><tt>caldav</tt></td>
                                <td align="left">https</td>
                                <td align="left"><xref target="RFC4791"/></td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="left">CardDAV</td>
                                <td align="left"><tt>carddav</tt></td>
                                <td align="left">https</td>
                                <td align="left"><xref target="RFC6352"/></td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="left">WebDAV</td>
                                <td align="left"><tt>webdav</tt></td>
                                <td align="left">https</td>
                                <td align="left"><xref target="RFC4918"/></td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="left">ManageSieve</td>
                                <td align="left"><tt>managesieve</tt></td>
                                <td align="left"></td>
                                <td align="left"><xref target="RFC5804"/>, <xref target="RFC5228"/></td>
                                <td align="left"></td>
                            </tr>
                        </tbody>
                    </table>
                    <t>The <em>Additional Properties</em> field is empty in all of the initial values.</t>
                </section>
            </section>
            <section anchor="registration">
                <name>Registration</name>
                <section anchor="registration-of-well-known-uri">
                    <name>Registration of Well-Known URI <tt>user-agent-configuration.json</tt></name>
                    <t>This registers the <tt>user-agent-configuration.json</tt> URI suffix from <xref target="well-known-uri" /> in the "Well-Known URIs" registry as specified in <xref target="RFC8615"/>.</t>
                    <table>
                        <name>Registration in Well-Known URIs Registry</name>
                        <thead>
                            <tr>
                                <th align="left">URI suffix</th>
                                <th align="left">Change controller</th>
                                <th align="left">Specification document(s)</th>
                                <th align="left">Status</th>
                                <th align="left">Related information</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="left"><tt>user-agent-configuration.json</tt></td>
                                <td align="left">IETF</td>
                                <td align="left">This document</td>
                                <td align="left">permanent</td>
                                <td align="left">None</td>
                            </tr>
                        </tbody>
                    </table>
                </section>
                <section anchor="registration-of-dns-underscore-label">
                    <name>Registration of DNS Underscore Label <tt>_ua-auto-config</tt></name>
                    <t>This registers the DNS underscore label <tt>_ua-auto-config</tt> used in <xref target="flow-dns-digest-validation" /> in the "Underscored and Globally Scoped DNS Node Names" registry as specified in <xref target="RFC8552"/>.</t>
                    <table>
                        <name>Registration in Underscored and Globally Scoped DNS Node Names Registry</name>
                        <thead>
                            <tr>
                                <th align="left">RR Type</th>
                                <th align="left">_NODE NAME</th>
                                <th align="left">Reference</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="left">TXT</td>
                                <td align="left"><tt>_ua-auto-config</tt></td>
                                <td align="left">This document</td>
                            </tr>
                        </tbody>
                    </table>
                </section>
            </section>
        </section>
    </middle>
    <back>
        <displayreference target="I-D.ietf-mailmaint-oauth-public" to="OAuthPublic"/>
        <displayreference target="I-D.ietf-httpbis-rfc6265bis" to="COOKIES"/>
        <references anchor="sec-normative-references">
            <name>Normative References</name>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.1035.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.1939.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2045.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4648.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4791.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4918.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4954.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.4959.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5034.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5228.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5234.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5280.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5321.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5322.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5397.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5804.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5890.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.5891.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6234.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6352.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6409.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6749.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6750.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6764.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6818.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6960.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7616.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7617.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.7628.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8126.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8259.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8314.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8414.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8446.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8552.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8615.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8620.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8621.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8887.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9051.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9110.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9111.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9112.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9325.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9525.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9610.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.svg-tiny-ps-abrotman.xml"/>
            <reference anchor="I-D.ietf-mailmaint-oauth-public" target="https://datatracker.ietf.org/doc/html/draft-ietf-mailmaint-oauth-public">
                <front>
                    <title>OAuth Profile for Open Public Clients</title>
                    <author initials="N." surname="Jenkins" fullname="Neil Jenkins">
                        <organization>Fastmail</organization>
                    </author>
                    <author initials="B." surname="Bucksch" fullname="Ben Bucksch">
                        <organization>Beonex</organization>
                    </author>
                    <abstract>
                        <t>This document specifies a profile of the OAuth authorization protocol to allow for interoperability between native clients and servers using open protocols, such as JMAP, IMAP, SMTP, POP, CalDAV, and CardDAV.</t>
                    </abstract>
                </front>
                <seriesInfo name="Internet-Draft" value="draft-ietf-mailmaint-oauth-public"/>
            </reference>
        </references>
        <references anchor="sec-informative-references">
            <name>Informative References</name>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9499.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-httpbis-rfc6265bis.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.bhutton-json-schema.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.bhutton-json-schema-validation.xml"/>
            <reference anchor="PSL" target="https://publicsuffix.org/list/">
                <front>
                    <title>Public Suffix List</title>
                    <author>
                        <organization>Mozilla Foundation</organization>
                    </author>
                </front>
            </reference>
        </references>
        <section anchor="configuration-schema">
            <name>Configuration JSON Schema</name>
            <t>The following schema defines the format of the JSON configuration in <xref target="json-configuration"/>. It is expressed in the 2020-12 dialect of JSON Schema, described in <xref target="I-D.bhutton-json-schema"/> and <xref target="I-D.bhutton-json-schema-validation"/>.</t>
            <t><cref anchor="todo-schema-id" source="editor">TODO: confirm the <tt>$id</tt> of the schema below. JSON Schema requires <tt>$id</tt> to be an absolute URI, and that URI needs to be stable, so it cannot be a draft-specific URL. This document currently uses a URL derived from the RFC number, to be substituted by the RFC Editor.</cref></t>
            <t>[RFC Editor: please replace "rfcXXXX" in the <tt>$id</tt> value below with the RFC number assigned to this document.]</t>
            <sourcecode><![CDATA[
========== NOTE: '\' line wrapping per RFC 8792 ===========

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://www.rfc-editor.org/rfc/rfcXXXX/\
        ua-auto-config.json",
    "title": "User-Agent Automatic Configuration",
    "description": "Automatic Configuration of Email, Calendar, \
        and Contact Server Settings",
    "type": "object",
    "properties": {
        "protocols": {
            "type": "object",
            "properties": {
                "caldav": { "$ref": "#/$defs/http-server" },
                "carddav": { "$ref": "#/$defs/http-server" },
                "imap": { "$ref": "#/$defs/text-server" },
                "jmap": { "$ref": "#/$defs/http-server" },
                "managesieve": { "$ref": "#/$defs/text-server" },
                "pop3": { "$ref": "#/$defs/text-server" },
                "submit": { "$ref": "#/$defs/text-server" },
                "webdav": { "$ref": "#/$defs/http-server" }
            }
        },
        "authentication": {
            "properties": {
                "oauth-public": {
                    "properties": {
                        "issuer": {
                            "format": "uri",
                            "type": "string"
                        }
                    },
                    "required": [
                        "issuer"
                    ],
                    "type": "object"
                },
                "password": {
                    "type": "boolean"
                }
            },
            "required": [ "password" ]
        },
        "info": {
            "type": "object",
            "properties": {
                "provider": {
                    "type": "object",
                    "properties": {
                        "name": { "type": "string", "minLength": 1 },
                        "shortName": { "type": "string", \
                            "minLength": 1 },
                        "logo": {
                            "type": "array",
                            "items": {
                                "type": "object",
                                "properties": {
                                    "url": { "type": "string", \
                                        "format": "uri" },
                                    "content-type": { \
                                        "type": "string", \
                                        "minLength": 1 },
                                    "width": { "type": "integer", \
                                        "minimum": 1 },
                                    "height": { "type": "integer", \
                                        "minimum": 1 }
                                },
                                "required": [ "url", "content-type" ]
                            }
                        }
                    },
                    "required": [ "name" ]
                },
                "help": {
                    "type": "object",
                    "properties": {
                        "documentation": { "type": "string", \
                            "format": "uri" },
                        "developer": { "type": "string", \
                            "format": "uri" },
                        "contact": {
                            "type": "array",
                            "items": { "type": "string", \
                                "minLength": 1 }
                        }
                    }
                }
            },
            "required": [ "provider" ]
        }
    },
    "required": [ "protocols", "info" ],
    "$defs": {
        "http-server": {
            "type": "object",
            "properties": {
                "url": { "type": "string", "format": "uri" }
            },
            "required": ["url"]
        },
        "text-server": {
            "type": "object",
            "properties": {
                "host": { "type": "string", "format": "hostname" }
            },
            "required": ["host"]
        }
    }
}
            ]]></sourcecode>
        </section>
        <section anchor="Acknowledgements" numbered="false">
            <name>Acknowledgements</name>
            <t>This document is based on the work of Ben Bucksch.</t>
        </section>
    </back>
</rfc>
