Network Working Group C. Newman Internet Draft: IMAP URL Scheme Innosoft Document: draft-newman-url-imap-02.txt November 1996 IMAP URL Scheme Status of this memo This document is an Internet Draft. Internet Drafts are working documents of the Internet Engineering Task Force (IETF), its Areas, and its Working Groups. Note that other groups may also distribute working documents as Internet Drafts. Internet Drafts are draft documents valid for a maximum of six months. Internet Drafts may be updated, replaced, or obsoleted by other documents at any time. It is not appropriate to use Internet Drafts as reference material or to cite them other than as a ``working draft'' or ``work in progress``. To learn the current status of any Internet-Draft, please check the 1id-abstracts.txt listing contained in the Internet-Drafts Shadow Directories on ds.internic.net, nic.nordu.net, ftp.isi.edu, or munnari.oz.au. A revised version of this draft document will be submitted to the RFC editor as a Proposed Standard for the Internet Community. Discussion and suggestions for improvement are requested. This document will expire six months after publication. Distribution of this draft is unlimited. 1. Introduction IMAP [IMAP4] is a rich protocol for accessing remote message stores. It provides an ideal mechanism for accessing public mailing list archives as well as private and shared message stores. This document defines a URL scheme for referencing objects on an IMAP server. 2. IMAP scheme The IMAP URL scheme is used to designate mailboxes, messages, files, and search programs on Internet hosts accessible using the IMAP protocol. Newman [Page 1] Internet Draft IMAP URL Scheme November 1996 The IMAP URL follows the common Internet scheme syntax as defined in RFC 1738 [RFC1738]. If : is omitted, the port defaults to 143. An IMAP URL takes one of the following forms: imap:///;TYPE=[iauth] imap:///?[uidvalidity][iauth] imap:///[uidvalidity][isection][iauth] The first form is used to refer to a list of mailboxes, the second form refers to a list of messages, and the final form refers to a specific message or message part. 3. IMAP User Name, Password and Authentication mechanism A user name, password and/or authentication mechanism may be supplied. They are used in the "LOGIN" or "AUTHENTICATE" commands after making the connection to the IMAP server. If no user name, password or authentication mechanism is supplied, the user name "anonymous" is used with the "LOGIN" command and the password is supplied as the Internet e-mail address of the end user accessing the resource. If the URL supplies a user name but no password, the program interpreting the IMAP URL should request one from the user if necessary. An authentication mechanism can be expressed by adding ";AUTH=" to the end of the URL. When such an is indicated, the client should request appropriate credentials from that mechanism and use the "AUTHENTICATE" command instead of the "LOGIN" command. If no user name is specified, one should be obtained from the mechanism or requested from the user as appropriate. The string ";AUTH=*" indicates that the client should select an appropriate authentication mechanism. It MAY use any mechanism listed in the CAPABILITY command or use an out of band security service resulting in a PREAUTH connection. If no user name is specified and no appropriate authentication mechanisms are available, the client should fall back to anonymous login as described above. This allows a URL which grants read-write access to authorized users, and read-only anonymous access to other users. Newman [Page 2] Internet Draft IMAP URL Scheme November 1996 4. Lists of mailboxes An IMAP URL referring to a list of mailboxes has the following form: imap:///;TYPE=[iauth] The may be either "LIST" or "LSUB", and is case insensitive. The field ";TYPE=" MUST be included. The is any argument suitable for the list_mailbox field of the IMAP [IMAP4] LIST or LSUB commands. The field may be omitted, in which case the program interpreting the IMAP URL may use "*" or "%" as the . The program should use "%" if it supports a hierarchical view, otherwise it should use "*". Note that if unsafe or reserved characters such as " " or "%" are present in they must be encoded as defined in RFC 1738 [RFC1738]. 5. Lists of messages An IMAP URL referring to a list of messages has the following form: imap:///?[uidvalidity][iauth] The field is used as the argument to the IMAP4 "SELECT" command. Note that if unsafe or reserved characters such as " ", ";", or "?" are present in they must be encoded as defined in RFC 1738 [RFC1738]. The [uidvalidity] field is optional. If it is present, it must be the argument to the IMAP4 UIDVALIDITY status response at the time the URL was created. This MAY be used by the program interpreting the IMAP URL to determine if the URL is stale. The "?" field is optional. If it is not present, a list of all messages in the mailbox should be presented by the program interpreting the URL. If it is present, it should be used as the arguments following an IMAP4 SEARCH command with unsafe characters such as " " (which are likely to be present in the ) encoded as defined in RFC 1738 [RFC1738]. 6. A specific message or message part Newman [Page 3] Internet Draft IMAP URL Scheme November 1996 An IMAP URL referring to a specific message or message part has the following form: imap:///[uidvalidity][isection][iauth] The and [uidvalidity] are as defined above. If [uidvalidity] is present in this form, it SHOULD be used by the program interpreting the URL to determine if the URL is stale. The refers to an IMAP4 message UID, and should be used as the argument to the IMAP4 "UID FETCH" command. The [isection] field is optional. If not present, the URL refers to the entire RFC 822 message as returned by the IMAP command "UID FETCH RFC822.PEEK". If present, the URL refers to the object returned by a "UID FETCH BODY.PEEK[
]" command. The type of the object may be determined with a "UID FETCH BODYSTRUCTURE" command and locating the appropriate part in the resulting BODYSTRUCTURE. Note that unsafe characters in [isection], such as " " must be encoded as defined in RFC 1738 [RFC1738]. 7. Examples The following examples demonstrate how an IMAP4 client program might translate various IMAP4 URL into a series of IMAP4 commands. Commands sent from the client to the server are prefixed with "C:", and responses sent from the server to the client are prefixed with "S:". The URL: Results in the following client commands: C: A001 LOGIN ANONYMOUS sheridan@babylon5.org C: A002 SELECT grey-council C: A003 UID FETCH 20 RFC822.PEEK Newman [Page 4] Internet Draft IMAP URL Scheme November 1996 The URL: Results in the following client commands: C: A001 LOGIN MICHAEL zipper C: A002 LIST "" users.* The URL: Results in the following client commands: C: A001 AUTHENTICATE KERBEROS_V4 C: A002 SELECT grey-council C: A003 UID FETCH 20 BODY.PEEK[1.2] The URL: Could result in the following: C: A001 CAPABILITY S: * CAPABILITY IMAP4rev1 AUTH=GSSAPI S: A001 OK C: A002 AUTHENTICATE GSSAPI S: A002 OK user lennier authenticated C: A003 SELECT "grey council" ... C: A004 SEARCH SUBJECT shadows S: * SEARCH 8 10 13 14 15 16 S: A004 OK SEARCH completed C: A005 FETCH 8,10,13:16 ALL ... NOTE: In this final example, the client has implementation dependant choices. The authentication mechanism could be anything, including PREAUTH. And the final FETCH command could fetch more or less information about the messages, depending on what it wishes to display Newman [Page 5] Internet Draft IMAP URL Scheme November 1996 to the user. 8. ABNF for IMAP URL scheme This uses ABNF as used in the IMAP specification [IMAP4]. Terminals from the BNF for URLs [RFC1738] are also used. Strings are not case sensitive. encoded_char ::= uchar / ":" / "@" / "&" / "=" / "/" ; see RFC 1738 for "uchar" definition enc_auth_type ::= 1*encoded_char ; further defined in RFC 1730 "auth_type" enc_list_mailbox ::= *encoded_char ; further defined in RFC 1730 "list_mailbox" enc_mailbox ::= 1*encoded_char ; further defined in RFC 1730 "mailbox" enc_search_program ::= 1*encoded_char ; encoded version of search_program below imapurl ::= "imap://" login "/" [ icommand ] [ iauth ] ; see RFC 1738 for "login" terminal iauth ::= ";AUTH=" ( "*" / enc_auth_type ) icommand ::= imailboxlist / ipath / isearch imailboxlist ::= enc_list_mailbox [ ";TYPE=" list_type ] ipath ::= enc_mailbox [uidvalidity] iuid [isection] isearch ::= enc_mailbox [ "?" enc_search_program ] [uidvalidity] isection ::= ";SECTION=" section ; See RFC 1730 for "section" definition iuid ::= ";UID=" nz_number ; See RFC 1730 for "nz_number" definition list_type ::= "LIST" / "LSUB" search_program ::= ["CHARSET" SPACE astring SPACE] search_criteria ; IMAP4 literals may not be used Newman [Page 6] Internet Draft IMAP URL Scheme November 1996 ; See RFC 1730 for "astring" and "search_criteria" uidvalidity ::= ";UIDVALIDITY=" nz_number ; See RFC 1730 for "nz_number" definition 9. References [IMAP4] Crispin, M., "Internet Message Access Protocol - Version 4", RFC 1730, University of Washington, December 1994. [RFC1738] Berners-Lee, Masinter, McCahill, "Uniform Resource Locators (URL)", RFC 1738, CERN, Xerox Coproration, University of Minnesota, December 1994. 10. Security Considerations IMAP URLs have the same security considerations as general Internet URLs [RFC1738]. Specifically, including passwords in the URL makes the password vulnerable to network evesdroppers both when the URL is transmitted and when the "LOGIN" command is sent to the IMAP server. For this reason, including passwords in the URL is discouraged. Security considerations discussed in the IMAP specification [IMAP4] are also relevant. Client authors should be careful when selecting an authentication mechanism if ";AUTH=*" is specified. Clients SHOULD NOT fall back to the "LOGIN" command with a user other than "anonymous" if more secure mechanisms are available to the client. A client which violates this rule is vulnerable to an active attacker which spoofs the server and does not declare support for any AUTHENTICATE mechanisms. 11. Author's Address Chris Newman Innosoft International, Inc. 1050 East Garvey Ave. South West Covina, CA 91790 USA Newman [Page 7] Internet Draft IMAP URL Scheme November 1996 Email: chris.newman@innosoft.com Newman [Page 8]