<?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" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version  (Ruby 3.2.3) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-bucksch-sasl-rememberme-00" category="info" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.26.0 -->
  <front>
    <title abbrev="sasl-rememberme">SASL Remember Me</title>
    <seriesInfo name="Internet-Draft" value="draft-bucksch-sasl-rememberme-00"/>
    <author fullname="Ben Bucksch">
      <organization>Beonex</organization>
      <address>
        <email>ben.bucksch@beonex.com</email>
      </address>
    </author>
    <author fullname="Stephen Farrell">
      <organization>Trinity College Dublin</organization>
      <address>
        <email>stephen.farrell@cs.tcd.ie</email>
      </address>
    </author>
    <date year="2025" month="January" day="31"/>
    <area>AREA</area>
    <workgroup>kitten</workgroup>
    <keyword>sasl</keyword>
    <keyword>rememberme</keyword>
    <keyword>login</keyword>
    <keyword>authentication</keyword>
    <abstract>
      <t>Introduces a SASL mechanism that allows the application to stay
logged in and re-login without user interaction, after completing a
time-consuming SASL login mechanism that involves the user.</t>
    </abstract>
    <note removeInRFC="true">
      <name>About This Document</name>
      <t>
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-bucksch-sasl-rememberme/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        kitten Working Group mailing list (<eref target="mailto:kitten@ietf.org"/>),
        which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/kitten/"/>.
        Subscribe at <eref target="https://www.ietf.org/mailman/listinfo/kitten/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.com/benbucksch/sasl-rememberme"/>.</t>
    </note>
  </front>
  <middle>
    <section anchor="introduction">
      <name>Introduction</name>
      <t>A client application might at first log in to a server using
Passkey or multi-factor authentication. However, these mechanisms
require complicated user interaction. These are too costly to
perform at every login. They can realistically only be
completed once during setup. To stay logged in, this SASL
mechanism allows the server to create a client-specific token that
the client application can then use to log in to the same account,
without further user interaction.</t>
      <t>The token is opaque to the client and the server can choose how to
implement it. It may be a custom random string that the server
stores, or an application-specific password generated for this
client together with the username, or a JWT token, or a
refresh token which does not expire.</t>
    </section>
    <section anchor="creation-of-the-token">
      <name>Creation of the token</name>
      <t>The client requests the token from the server using either
1. application-specific commands, like IMAP <tt>REMEMBERME</tt>,
which are to be defined in other standards.
2. the success response of another SASL mechanism.</t>
      <t>The client stores the token, instead of a password,
in a client-specific storage that is as secure as a password
storage.</t>
    </section>
    <section anchor="login-using-the-token">
      <name>Login using the token</name>
      <t>If the client needs to log in and has a token for this user and host, uses
the SASL <tt>REMEMBERME</tt> mechanism to log in.  <tt>REMEMBERME</tt> mechanism starts
with the client sending the initial client response, which has the following
format defined using ABNF:</t>
      <sourcecode type="abnf"><![CDATA[
rememberme-client-step1 = token
token                   = 1*OCTET
]]></sourcecode>
      <t>If the server accepts the response as valid and allows login, it responds with
a SASL success response. The user is logged in.  (ALTERNATIVE EXPIRY: ....  it
responds with a SASL success response, a new token, and the expiry time of the
new token. The user is logged in.  To avoid race conditions in clients that
open multiple connections at the same time, the previously used token <bcp14>MUST</bcp14> be
valid for at least 30 more seconds. Likewise, if the server returned a new
token, then it must return the same new token in response to the same old token
for the next 1 hour.  Reason: If the client opens 5 connections at the same
time, using the same token, but the server were to respond with 5 different new
tokens, and it were to allow only 1 of them, then the client would not know
which one to store, due to race conditions in the network response.)</t>
      <t>If the response is invalid, the server responds with a SASL error and a
human-readable error message for the end user.</t>
      <sourcecode type="abnf"><![CDATA[
server-final-message = server-error "," server-error-message
        ; Only returned on error. Omitted on success.

server-error = "e=" server-error-value

server-error-value = "invalid-encoding" /
                     "unknown-user" /
                     "invalid-username-encoding" /
                       ; invalid username encoding (invalid UTF-8 or
                       ; SASLprep failed)
                     "other-error" /
                     server-error-value-ext
        ; Unrecognized errors should be treated as "other-error".
        ; In order to prevent information disclosure, the server
        ; may substitute the real reason with "other-error".

server-error-value-ext = value
        ; Additional error reasons added by extensions
        ; to this document.

server-error-message = "m=" server-error-message-value

server-error-message-value = 1*OCTET
        ; Human readable error message in UTF-8
]]></sourcecode>
    </section>
    <section anchor="imap-example">
      <name>IMAP Example</name>
      <t>In IMAP, the exchange would be:</t>
      <artwork><![CDATA[
S: * OK ACME IMAP Server v1.23 is ready
C: 22 CAPABILITY
S: 22 CAPABILITY IMAP4rev1 IMAP4rev2 AUTH=PASSKEY AUTH=REMEMBERME
C: 23 AUTHENTICATE REMEMBERME QUVDNjU3NjU3NjU1Nwo=
S: 23 OK AUTHENTICATE completed
]]></artwork>
      <t>In the above example the token is "AEC6576576557" which is base64-encoded
according to IMAP SASL profile.</t>
    </section>
    <section anchor="requirements-on-the-token">
      <name>Requirements on the token</name>
      <ol spacing="normal" type="1"><li>
          <t>The token <bcp14>MUST</bcp14> also allow the server to infer the authentication identity (e.g. username or email address).
The token alone must be sufficient to log in.
This SASL mechanism doesn't support separate authorization identities.</t>
        </li>
        <li>
          <t>The token <bcp14>MUST NOT</bcp14> expire.
(ALTERNATIVE EXPIRY: The token <bcp14>MUST</bcp14> be valid for at least 30 days.)</t>
        </li>
        <li>
          <t>The server <bcp14>SHOULD</bcp14> be able to revoke the tokens,
in case this specific user account or device was compromised.
In this case, the authentication <bcp14>MUST</bcp14> fail and the SASL error message
<bcp14>MUST</bcp14> explain the situation to the user and give instructions
how to remedy the situation.</t>
        </li>
      </ol>
    </section>
    <section anchor="conventions-and-definitions">
      <name>Conventions and Definitions</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 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.</t>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>Clients should treat the token like a password and store it securely.</t>
      <t>TODO Security</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>IANA is requested to add the following entries to the SASL Mechanism registry
established by <xref target="RFC4422"/>:</t>
      <artwork><![CDATA[
To: iana@iana.org
Subject: Registration of a new SASL mechanism REMEMBERME

SASL mechanism name (or prefix for the family): REMEMBERME
Security considerations: Section YY of [RFCXXXX]
Published specification (optional, recommended): [RFCXXXX]
Person & email address to contact for further information:
    IETF Kitten WG <kitten@ietf.org>
Intended usage: COMMON
Owner/Change controller: IESG <iesg@ietf.org>
Note:
]]></artwork>
    </section>
  </middle>
  <back>
    <references>
      <name>Normative References</name>
      <reference anchor="RFC2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author fullname="S. Bradner" initials="S." surname="Bradner"/>
          <date month="March" year="1997"/>
          <abstract>
            <t>In many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
        <seriesInfo name="DOI" value="10.17487/RFC2119"/>
      </reference>
      <reference anchor="RFC8174">
        <front>
          <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
          <author fullname="B. Leiba" initials="B." surname="Leiba"/>
          <date month="May" year="2017"/>
          <abstract>
            <t>RFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="8174"/>
        <seriesInfo name="DOI" value="10.17487/RFC8174"/>
      </reference>
      <reference anchor="RFC4422">
        <front>
          <title>Simple Authentication and Security Layer (SASL)</title>
          <author fullname="A. Melnikov" initials="A." role="editor" surname="Melnikov"/>
          <author fullname="K. Zeilenga" initials="K." role="editor" surname="Zeilenga"/>
          <date month="June" year="2006"/>
          <abstract>
            <t>The Simple Authentication and Security Layer (SASL) is a framework for providing authentication and data security services in connection-oriented protocols via replaceable mechanisms. It provides a structured interface between protocols and mechanisms. The resulting framework allows new protocols to reuse existing mechanisms and allows old protocols to make use of new mechanisms. The framework also provides a protocol for securing subsequent protocol exchanges within a data security layer.</t>
            <t>This document describes how a SASL mechanism is structured, describes how protocols include support for SASL, and defines the protocol for carrying a data security layer over a connection. In addition, this document defines one SASL mechanism, the EXTERNAL mechanism.</t>
            <t>This document obsoletes RFC 2222. [STANDARDS-TRACK]</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="4422"/>
        <seriesInfo name="DOI" value="10.17487/RFC4422"/>
      </reference>
    </references>
    <section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>TODO acknowledge.</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA4VZ63IbtxX+j6dAmZnWzpBUKMlxykYZUxQds5FERaLiaDKZ
CbgLkoh2FwywS5rNuM/SZ+mT9TsA9kZJU40tcbHAuXznDvZ6PZarPJFD3rkb
3V3yW5nKdCENv5IdJhYLI7d4ZYVNeia8SvEmErlcabMfcpUtNWOxjjKRgkps
xDLvLYro0Ubr3sG53ldfMVssUmWt0lm+3+DAdDJ/z/kXXCRWg5PKYrmR+JXl
nS7vyFjl2iiR0MN0dI4/2uDT7fx9h2UFkR2yGMIMWaQzKzNb2CHPTSEZ5D5h
wkgx5KPbyYjttHlcGV1shvxR5bnM2KPcY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