<?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-02" 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-02"/>
        <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="2" 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>JMAP</keyword>
        <keyword>OAuth2</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 protocol examples, 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.  Lines prefixed with "// " are comments explaining the previous protocol line.  These prefixes and comments are not part of the protocol.  Lines without any of these prefixes are continuations of the previous line, and no line break is present in the protocol unless specifically mentioned.</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>
        </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</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 SMTP 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 SMTP, 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 clients 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>Client Requirements Summary</name>
                <t>The following is a non-normative, high-level summary of what a client 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"
        },
        "smtp": {
            "host": "smtp.example.com"
        },
        "caldav": {
            "url": "https://sync.example.com/calendar/"
        },
        "carddav": {
            "url": "https://sync.example.com/contacts/"
        }
    },
    "authentication": {
        "oauth-public": {
            "issuer": "https://auth.example.com/"
        },
        "password": true
    },
    "info": {
        "provider": {
            "name": "Example Provider Name",
            "shortName": "Example",
            "logo": [
                {
                    "url": "https://www.example.net/logo.svg",
                    "content-type": "image/svg+xml"
                }
            ]
        },
        "help": {
            "documentation": "https://help.example.net/howto/\
                set-up-your-mail-app.html",
            "developer": "https://developer.example.net/\
                client-apps/",
            "contact": ["mailto:it@team.example.net"]
        }
    }
}
]]></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"/>, and</li>
                    <li>CardDAV defined in <xref target="RFC6352"/></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. This URL <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>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>SMTP defined in <xref target="RFC5321"/>, and</li>
                    <li>POP3 defined in <xref target="RFC1939"/></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 server <bcp14>MUST</bcp14> use the default port number for that protocol, with connections secured using 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 nested <tt>password</tt> value indicates whether the provider supports username and password authentication.</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.</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 that users can use to contact the provider, such as <tt>mailto</tt> URLs.</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><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> at least include one of each</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 agent <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>configuration name</em> <tt>user-agent-configuration</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. See <xref target="tls-validation" /> for details about TLS with respect to retrieving the configuration.</t>
                    <t>The media type of the configuration is <tt>application/json</tt>, and the HTTP server <bcp14>MUST</bcp14> set a corresponding <tt>Content-Type</tt> type header. See <xref target="RFC9110"/>. The user agent <bcp14>MUST</bcp14> validate that the content-type 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:</t>
                    <sourcecode><![CDATA[
C: GET /.well-known/user-agent-configuration.json HTTP/2
C: Host: foo.example.com
C: user-agent: curl/8.4.0
C: accept: application/json
C:

S: HTTP/2 200
S: server: nginx/1.25.3
S: date: Mon, 23 Oct 2025 10:30:00 GMT
S: content-type: application/json
S: content-length: 1184
S:
S: {
S:     "protocols": {
S:         "jmap": {
S: ...
                    ]]></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>MUST</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>If the validation fails, the user agent <bcp14>MUST</bcp14> ignore the auto-configuration resource.</t>
                    <section anchor="validation-procedure">
                        <name>Validation Procedure</name>
                        <t>
                            The user agent <bcp14>MUST</bcp14> perform the following steps to
                            validate the auto-configuration resource:
                        </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 Section 6.1 of <xref target="RFC9112"/> and Section 8.4 of
                                <xref target="RFC9110"/> 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 identifier (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>The formal syntax of the record is described using ABNF <xref target="RFC5234"/> as follows: </t>
                            <artwork name="ABNF for the TXT Record" type="abnf"><![CDATA[
config-record   = tag-value *( *WSP ";" *WSP tag-value ) *WSP [";"]

tag-value       = 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 *WSP "=" *WSP 1*tag-value-char

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

base64-char     = ALPHA / DIGIT / "+" / "/" / "="
; As defined in Section 4 of RFC 4648

WSP             = " " / HTAB
; As defined in Appendix B.1 of RFC 5234
                            ]]></artwork>
                        </section>

                        <section anchor="dns-record-tags">
                            <name>Tags</name>
                            <t>
                                The following tags are defined. Tag names are case-sensitive and
                                <bcp14>MUST</bcp14> be processed as lowercase.
                            </t>
                            <table>
                                <name>Defined Tags</name>
                                <thead>
                                    <tr><td>Tag</td><td>Description</td><td>Status</td></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 Section 4 of <xref target="RFC4648" />.</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>
                            <t>Servers <bcp14>MUST</bcp14> publish a DNS record using the SHA-256 algorithm.</t>
                        </section>
                        <section anchor="dns-record-parsing-rules">
                            <name>Parsing Rules</name>
                            <t>A client 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, the record is invalid
                                    and <bcp14>MUST</bcp14> be ignored.
                                </li>
                            </ul>
                        </section>
                    </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"
        },
        "smtp": {
            "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 RFC 8259. Additionally, user agents <bcp14>MUST</bcp14> validate the retrieved configuration against the JSON schema specification provided in <xref target="configuration-schema"/>. If the JSON syntax is invalid, 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. Clients <bcp14>MUST</bcp14> verify that the <tt>issuer</tt> value is valid according to <xref target="RFC8414" />.</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.</t>
                    <t>The user agent <bcp14>SHOULD</bcp14> connect to each protocol that it might be interested in to detect which authentication mechanism it supports. The user agent <bcp14>MUST NOT</bcp14> perform any authentication at this point, but it <bcp14>SHOULD</bcp14> record which mechanism(s) the server for each protocol of interest supports.</t>
                    <t>The user agent <bcp14>SHOULD</bcp14> still probe each server as described in the next sections <xref target="flow-probing-http-auth-mechanism" format="counter" /> and <xref target="flow-probing-text-auth-mechanism" format="counter" /> to check that the servers it is interested in have OAuth support.</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. 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 this 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 <tt>Bearer</tt>. <xref target="RFC6749"/> describes this in more detail. <xref target="RFC6750"/> 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>
                </section>
                <section anchor="flow-probing-text-auth-mechanism">
                    <name>Other Protocols Authentication Mechanisms</name>
                    <t>For text-based protocols (IMAP, POP3, and SMTP) 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 SMTP</li>
                    </ul>
                    <t>using TLS. See <xref target="RFC2595"/> and <xref target="RFC3207"/> for details about using TLS with these protocols.</t>
                    <t>The user agent <bcp14>SHOULD NOT</bcp14> attempt to connect to an IMAP, POP3, or SMTP server on their cleartext ports.</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, 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, clients 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 IMAP4 IMAP4rev1 SASL-IR AUTH=PLAIN \
AUTH=OAUTHBEARER] IMAP Server
C: A1 LOGOUT
S: * BYE
S: A1 OK
                        ]]></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 client 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 client <bcp14>SHOULD</bcp14> send a <tt>CAPABILITY</tt> command as outlined in <xref target="RFC9051" sectionFormat="of" section="6.1.1" />. The client <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-smtp">
                        <name>SMTP</name>
                        <t>SMTP similarly announces which authentication mechanisms is supports. <xref target="RFC4954"/> describes how to use SASL with SMTP.</t>
                        <t>For SMTP, the client would use the <tt>EHLO</tt> command to retrieve the SMTP 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" /> describe 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 client <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 client 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 client <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>The client <bcp14>SHOULD</bcp14> display to the user the hostnames of all servers that it intends to authenticate with. This list of server hostnames gives the user a chance to validate if they want to move ahead.</t>
                <t>The client <bcp14>MAY</bcp14> choose to limit the hostnames to their second-level domain names when displaying this list. Instead of displaying <tt>mail.example.com</tt> the client would display <tt>example.com</tt> if it chooses to do so. Limiting the hostnames to their second-level domain names helps users identify if this is the domain they intend to connect to or not.</t>
                <t>The client <bcp14>MUST NOT</bcp14> cut off parts of long second-level domains, to avoid spoofing. At least 63 characters of the second-level domain names <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>Clients 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" /> list 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 client <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 client
                    is not involved in this mapping.</t>
            </section>
            <section anchor="flow-config-oauth">
                <name>Configuring OAuth</name>
                <t>If the client and the provider both support OAuth Profile for Open Public Clients, and if the servers that the client wants to use support OAuth, the client can configure OAuth.</t>
                <t>The <tt>authentication</tt> section in the JSON configuration described in <xref target="json-config-authentication" /> will let the client create a URL to retrieve the OAuth Authorization Server Metadata as described in section <xref target="flow-probing-oauth" />. With this metadata, the client 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 user-agent, which is typically the default browser. The client <bcp14>SHOULD</bcp14> make it very apparent to the user which hostname is being used for the authorization request URL. The client <bcp14>SHOULD</bcp14> make the user confirm least the second-level domain name(s) 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 client <bcp14>SHOULD</bcp14> also confirm the server hostnames with the user. For OAuth authentication, the client <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 client and provider both support password-based authentication, and if the servers that the client wants to use support password-based authentication, the client can configure itself to use these servers.</t>
                <t>The client <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 client <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="config-validation">
            <name>Configuration Validation</name>
            <section anchor="user-approval">
                <name>User Approval</name>
                <t>Regardless of the mechanism used to obtain the configuration, clients <bcp14>SHOULD</bcp14> display the configuration details to users and request explicit confirmation before use. During this confirmation process:</t>
                <ul spacing="normal">
                    <li>
                        <t>At least the second-level domain names of all involved hostnames <bcp14>MUST</bcp14> be displayed clearly and prominently.</t>
                    </li>
                    <li>
                        <t>Clients <bcp14>MUST NOT</bcp14> truncate long second-level domain names to prevent spoofing attacks. At least 63 characters <bcp14>MUST</bcp14> be displayed.</t>
                    </li>
                </ul>
            </section>
            <section anchor="oauth2-requirements">
                <name>OAuth2 requirements</name>
                <t>If OAuth2 is used, the OAuth2 server <bcp14>MUST</bcp14> adhere to <xref target="I-D.ietf-mailmaint-oauth-public" />.</t>
                <t>Notably, the Dynamic Client Registration <bcp14>MUST</bcp14> be implemented and return a working Client ID in response HTTP calls defined by the specification.</t>
                <t>The OAuth2 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 client will include all relevant scopes in the authentication requests.</t>
            </section>
        </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 all second-level domains (SLDs) for 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 second-level domain (SLD) 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 second-level domain (SLD) 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>In <xref target="sec-domain-names" /> some mechanisms to limit this attack vector are described.</t>
                <t>However, the user agent needs to combine this with a conservative trust policy for its TLS when retrieving the JSON configuration.</t>
            </section>
            <section anchor="sec-dns">
                <name>DNS</name>
                <t>If the user agent uses the DNS mechanisms described in <xref target="flow-dns-digest-validation" />, care needs to be taken to make sure that an attacker hasn't altered the DNS response. Using DNSSEC is one method of improving the security aspects of this approach. Alternatively, user agents <bcp14>MAY</bcp14> choose not use the DNS based mechanisms described in <xref target="flow-dns-digest-validation" /> at all.</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="RFC6818" />), or some other mechanism. The general TLS usage guidance in <xref target="RFC9525" /> <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>User agents <bcp14>MAY</bcp14> implement more restrictive transport security policies for configuration retrieval than those typically required for web browsing, in order to provide stronger security guarantees. For TLS connections, user agents <bcp14>MAY</bcp14> want to limit the allowed protocol version(s) to recent versions, and <bcp14>MAY</bcp14> similarly want to restrict the allowed cipher suites. For QUIC connections, user agents <bcp14>MAY</bcp14> apply similar restrictions to the underlying TLS handshake parameters.</t>
                <t>The HTTP server serving the Well-Known resource described in <xref target="well-known-uri" /> <bcp14>MUST</bcp14> have support for TLS 1.3 (<xref target="RFC8446" />) or higher.</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 clients <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 client to such attacks.</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 a 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 ____@ietf.org mailing list for review and comment, with an appropriate subject (e.g., "Request for well-known URI: example").</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@iesg.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 using 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">RFC 8620, RFC 8621, RFC 8887, RFC 9610</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">RFC 9051</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">RFC 1939, RFC 5034</td>
                                <td align="left"></td>
                            </tr>
                            <tr>
                                <td align="left">SMTP</td>
                                <td align="left"><tt>smtp</tt></td>
                                <td align="left"></td>
                                <td align="left">RFC 5321, RFC 2822</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">RFC 4791</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">RFC 6352</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">RFC 4918</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">RFC 5804, RFC 5228</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</tt></name>
                    <t>This registers the <tt>user-agent-configuration</tt> name 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">Related information</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td align="left"><tt>user-agent-configuration</tt></td>
                                <td align="left">IETF</td>
                                <td align="left">This document</td>
                                <td align="left">/</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"/>
        <references anchor="sec-normative-references">
            <name>Normative References</name>
            <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.2595.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.3207.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.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.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.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.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.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.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.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.9112.xml"/>
            <xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.9525.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>
        <section anchor="configuration-schema">
            <name>Configuration JSON Schema</name>
            <t>The following JSON schema defines the format of the JSON configuration in <xref target="json-configuration"/></t>
            <sourcecode><![CDATA[
========== NOTE: '\' line wrapping per RFC 8792 ===========

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "ua-auto-conf",
    "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" },
                "smtp": { "$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>
