<?xml version='1.0' encoding='UTF-8'?>

<!-- draft submitted in xml v3 --> 

<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>

<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-extra-jmapaccess-09" number="9698" tocInclude="true" updates="" obsoletes="" category="std" consensus="true" submissionType="IETF" sortRefs="true" xml:lang="en" version="3">

  <front>
    <title abbrev="IMAP JMAPACCESS">The JMAPACCESS Extension for IMAP</title>
    <seriesInfo name="RFC" value="9698"/>
    <author initials="A." surname="Gulbrandsen" fullname="Arnt Gulbrandsen">
      <organization>ICANN</organization>
      <address>
        <postal>
          <street>6 Rond Point Schumann, Bd. 1</street>
          <city>Brussels</city>
          <code>1040</code>
          <country>Belgium</country>
        </postal>
        <email>arnt@gulbrandsen.priv.no</email>
        <uri>https://icann.org/ua</uri>
      </address>
    </author>
    <author initials="B." surname="Gondwana" fullname="Bron Gondwana">
      <organization>Fastmail</organization>
      <address>
        <postal>
          <street>Level 2, 114 William St.</street>
          <city>Melbourne VIC</city>
          <code>3000</code>
          <country>Australia</country>
        </postal>
        <email>brong@fastmailteam.com</email>
        <uri>https://fastmail.com</uri>
      </address>
    </author>
    <date year="2025" month="January"/>

    <area>ART</area>
    <workgroup>extra</workgroup>

    <keyword>IMAP</keyword>
    <keyword>JMAP</keyword>
    <abstract>

<t>This document defines an IMAP extension to let clients know that the
messages in this IMAP server are also available via the JSON Meta Application Protocol (JMAP), and how. It is
intended for clients that want to migrate gradually to JMAP or use
JMAP extensions within an IMAP client.</t>
    </abstract>
  </front>
  <middle>

<section anchor="introduction">
      <name>Introduction</name>
      <t>An IMAP server can declare that the messages in its mailstore are also
available via JMAP. For simplicity, only a complete equivalence is
supported (the same set of messages are available via both IMAP and
JMAP).</t>
    </section>
    <section anchor="requirements-language">
      <name>Requirements Language</name>
        <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&nbsp;14 <xref target="RFC2119"/> <xref
    target="RFC8174"/> when, and only when, they appear in all capitals, as
    shown here.
        </t>


</section>
    <section anchor="details">
      <name>Details</name>
      <t>By advertising the JMAPACCESS capability, the server asserts that if a
mailbox or message has a particular object ID when accessed via either
IMAP or JMAP (see <xref target="RFC3501"/>, <xref target="RFC9051"/>, and <xref target="RFC8620"/>), then the
same mailbox or message is accessible via the other protocol, and it
has the same ID.</t>

      <t>The server <bcp14>MUST</bcp14> also advertise the OBJECTID extension, defined by
<xref target="RFC8474"/>. The JMAP session resource that allows access to the same
messages is called "the JMAP server" below.</t>
      <t>This specification does not affect message lifetime: If a client
accesses a message via IMAP and half a second later via JMAP, then the
message may have been deleted between the two accesses.</t>
      <t>When the server processes the client's LOGIN/AUTHENTICATE command and
enters Authenticated state, the server considers the way the client
authenticated. If the IMAP server can infer from the client's
authentication process that its credentials suffice to authenticate
via JMAP, then the server <bcp14>MUST</bcp14> include a JMAPACCESS capability in any
capability list sent after that point.  This includes the capability
list that some servers send immediately when authentication succeeds.</t>

      <t>Servers are encouraged to report the same message flags and other data
via both protocols, as far as possible.</t>
      <t>This specification does not require mailboxes to have the same name in
IMAP and JMAP, even if they share a mailbox ID. However, the JMAP
specification regulates that in the text about the name and role
properties described in <xref target="RFC8620" sectionFormat="of" section="2"/>.</t>
      <t>Note that all JMAP servers support internationalized email addresses
(see <xref target="RFC6530"/>).  If this IMAP server does not or if the IMAP client
does not issue ENABLE UTF8=ACCEPT (see <xref target="RFC6855"/>), then it is possible
that the client will receive accurate address fields via JMAP
and downgraded fields via IMAP (see <xref target="RFC6857"/> and <xref target="RFC6858"/>
for examples). Issuing ENABLE UTF8=ACCEPT is a simple way to sidestep
the issue.</t>
    </section>
    <section anchor="the-jmapaccess-response-code">
      <name>The GETJMAPACCESS Command and the JMAPACCESS Response</name>
      <t>
   The GETJMAPACCESS command requests that the server respond with the
   session URL for the JMAP server that provides access to the same
   mail.</t>

<t>   If such a JMAP server is known to this server, the server <bcp14>MUST</bcp14>
   respond with an untagged JMAPACCESS response containing the JMAP
   server's session resource (a URL) followed by a tagged OK response.</t>

<t>   If such a JMAP server is not known, the server <bcp14>MUST</bcp14> respond with a
   tagged BAD response (and <bcp14>MUST NOT</bcp14> include JMAPACCESS in the
   capability list).</t>

<t>   The JMAPACCESS response is followed by a single link to a JMAP
   session resource.</t>

      <t>The formal syntax in <xref target="RFC9051"/> is extended as follows:</t>

<sourcecode type="abnf">
command-auth =/ "GETJMAPACCESS"

mailbox-data =/ resp-jmapaccess

resp-jmapaccess = "JMAPACCESS" SP quoted
</sourcecode>

      <t>The syntax in <xref target="RFC3501"/> is extended similarly (this extension may be
used with IMAP4rev1 as well as IMAP4rev2).</t>
    </section>
    <section anchor="Examples">


      <name>Examples</name>
      <t>Lines sent by the client are preceded by C: and lines sent by the server are preceded by S:. Each example starts with the IMAP banner issued by the server
on connection, and generally abbreviates the capability lists to
what's required by the example itself.</t>
      <t>Real connections use longer capability lists, much longer AUTHENTICATE
arguments and of course use TLS. However, these examples focus on JMAPACCESS.</t>

<t>Example 1:</t> <t>A client connects, sees that SASL OAuth <xref target="RFC7628"/> is available, and
authenticates in that way.</t>

<sourcecode type="">
S: * OK [CAPABILITY IMAP4rev1 AUTH=OAUTHBEARER SASL-IR] example1
C: 1 AUTHENTICATE OAUTHBEARER bixhPXVzZ...QEB
</sourcecode>

      <t>The server processes the command successfully. It knows that the
client used OAuth, and that it and its JMAP alter ego use the same
OAuth backend subsystem. Because of that it infers that the (next)
access token is just as usable via JMAP as via IMAP. It includes a
JMAPACCESS capability in its reply (again, real capability lists are much longer):
</t>

<sourcecode type="">
S: 1 OK [CAPABILITY IMAP4rev1 JMAPACCESS] done
C: 1b GETJMAPACCESS
S: * JMAPACCESS "https://example.com/.well-known/jmap"
S: 1b OK done
</sourcecode>

      <t>SASL OAuth is specified by <xref target="RFC7628"/>, and the argument in this
example is abbreviated from the more realistic length used in RFC 7628.</t>

      <t>Example 2:</t> <t>A client connects, sees no SASL method it recognizes, and
issues a LOGIN command.</t>

<sourcecode type="">
S: * OK [CAPABILITY IMAP4rev2] example2
C: 2 LOGIN "arnt" "trondheim"
</sourcecode>

      <t>The server sees that the password is accepted, knows that it and its
JMAP alter ego use the same password database, and issues a JMAPACCESS
capability:</t>

<sourcecode type="">
   S: * OK [CAPABILITY IMAP4rev2 JMAPACCESS] done
   S: 2 OK done
   C: 2b JMAPACCESS
   S: * JMAPACCESS "https://example.com/.well-known/jmap"
   S: 2b OK done
</sourcecode>

<t>The URL uses the same quoting rules as most other IMAP strings.</t>


     <t>Example 3:</t> <t>A client connects, sees no SASL method it recognizes, and
issues a LOGIN command with a correct password.</t>

<sourcecode type="">
S: * OK [CAPABILITY IMAP4rev1 IMAP4rev2] example3
C: 3 LOGIN "arnt" "trondheim"
</sourcecode>

      <t>The server operator has decided to disable password use with JMAP, but
allow it for a while with IMAP to cater to older clients.  Therefore, the login
succeeds, but there is no JMAPACCESS capability.</t>

<sourcecode type="">
S: 3 OK done
</sourcecode>


     <t>Example 4:</t> <t>A client connects, sees no SASL method it recognizes, and
issues a LOGIN command. Its password is incorrect.</t>

<sourcecode type="">
S: * OK [CAPABILITY IMAP4rev2 AUTH=GSS] example4
C: 4 LOGIN "arnt" "oslo"
</sourcecode>

      <t>The server does not enter Authenticated state, so nothing requires it
to mention JMAPACCESS. It replies curtly:</t>

<sourcecode type="">
S: 4 NO done
</sourcecode>
</section>

    <section anchor="IANA">
      <name>IANA Considerations</name>
      <t>The IANA has added the JMAPACCESS capability to the "Internet Message Access Protocol (IMAP) Capabilities Registry" and listed this document as the reference.</t>
    </section>
    <section anchor="Security">
      <name>Security Considerations</name>
      <t>JMAPACCESS reveals to authenticated IMAP clients that
they would be able to authenticate via JMAP using the same credentials
and that the object IDs match.</t>

      <t>One does not normally reveal anything at all about authentication.
However, if the client is an attacker, then the attacker is known to
have valid credentials, and <xref target="RFC8620" sectionFormat="of" section="2.2"/> tells the attacker
how to find the revealed URL without the help of this extension.
Therefore, it is believed that this document does not
benefit an attacker noticeably, and its value for migration far outweighs
its risk.</t>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references anchor="sec-normative-references">
        <name>Normative References</name>
	
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.3501.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8474.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.2119.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>

      </references>
      <references anchor="sec-informative-references">
        <name>Informative References</name>

	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6530.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6855.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6857.xml"/>
	<xi:include href="https://bib.ietf.org/public/rfc/bibxml/reference.RFC.6858.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.8620.xml"/>

      </references>
    </references>

  </back>


</rfc>
