Skip to content
Snippets Groups Projects
specification.rst 45.1 KiB
Newer Older
  • Learn to ignore specific revisions
  • Kegan Dougal's avatar
    Kegan Dougal committed
        "session": "<session id>"
    
    Kegan Dougal's avatar
    Kegan Dougal committed
    The home server MUST respond to this with either new credentials, the next stage of 
    the login process, or a standard error response. 
    
    Kegan Dougal's avatar
    Kegan Dougal committed
    A common client implementation will be to periodically poll until the link is clicked.
    If the link has not been visited yet, a standard error response with an errcode of 
    ``M_LOGIN_EMAIL_URL_NOT_YET`` should be returned.
    
    Kegan Dougal's avatar
    Kegan Dougal committed
    N-Factor Authentication
    -----------------------
    Multiple login stages can be combined to create N-factor authentication during login.
    
    This can be achieved by responding with the ``next`` login type on completion of a 
    
    Kegan Dougal's avatar
    Kegan Dougal committed
    previous login stage::
    
    Kegan Dougal's avatar
    Kegan Dougal committed
        "next": "<next login type>"
    
    Kegan Dougal's avatar
    Kegan Dougal committed
    If a home server implements N-factor authentication, it MUST respond with all 
    
    ``stages`` when initially queried for their login requirements::
    
    Kegan Dougal's avatar
    Kegan Dougal committed
        "type": "<1st login type>",
        "stages": [ <1st login type>, <2nd login type>, ... , <Nth login type> ]
    
    Kegan Dougal's avatar
    Kegan Dougal committed
    This can be represented conceptually as::
    
       _______________________
      |    Login Stage 1      |
      | type: "<login type1>" |
      |  ___________________  |
      | |_Request_1_________| | <-- Returns "session" key which is used throughout.
      |  ___________________  |     
      | |_Request_2_________| | <-- Returns a "next" value of "login type2"
      |_______________________|
                |
                |
       _________V_____________
      |    Login Stage 2      |
      | type: "<login type2>" |
      |  ___________________  |
      | |_Request_1_________| |
      |  ___________________  |
      | |_Request_2_________| |
      |  ___________________  |
      | |_Request_3_________| | <-- Returns a "next" value of "login type3"
      |_______________________|
                |
                |
       _________V_____________
      |    Login Stage 3      |
      | type: "<login type3>" |
      |  ___________________  |
      | |_Request_1_________| | <-- Returns user credentials
      |_______________________|
    
    Kegan Dougal's avatar
    Kegan Dougal committed
    Clients cannot be expected to be able to know how to process every single
    login type. If a client determines it does not know how to handle a given
    login type, it should request a login fallback page::
    
    Kegan Dougal's avatar
    Kegan Dougal committed
      GET matrix/client/api/v1/login/fallback
    
    
    This MUST return an HTML page which can perform the entire login process.
    
    Identity
    ========
    
    TODO : Dave
    - 3PIDs and identity server, functions
    
    Federation
    ==========
    
    Federation is the term used to describe how to communicate between Matrix home 
    servers. Federation is a mechanism by which two home servers can exchange
    Matrix event messages, both as a real-time push of current events, and as a
    historic fetching mechanism to synchronise past history for clients to view. It
    uses HTTP connections between each pair of servers involved as the underlying
    transport. Messages are exchanged between servers in real-time by active pushing
    from each server's HTTP client into the server of the other. Queries to fetch
    historic data for the purpose of back-filling scrollback buffers and the like
    can also be performed.
    
    There are three main kinds of communication that occur between home servers:
    
    
       These are single request/response interactions between a given pair of
    
       servers, initiated by one side sending an HTTP GET request to obtain some
    
       information, and responded by the other. They are not persisted and contain
       no long-term significant history. They simply request a snapshot state at the
       instant the query is made.
    
    
       These are notifications of events that are pushed from one home server to
       another. They are not persisted and contain no long-term significant history,
       nor does the receiving home server have to reply to them.
    
    
       These are notifications of events that are broadcast from one home server to
       any others that are interested in the same "context" (namely, a Room ID).
       They are persisted to long-term storage and form the record of history for
       that context.
    
    
    EDUs and PDUs are further wrapped in an envelope called a Transaction, which is 
    transferred from the origin to the destination home server using an HTTP PUT request.
    
    The transfer of EDUs and PDUs between home servers is performed by an exchange
    
    of Transaction messages, which are encoded as JSON objects, passed over an 
    HTTP PUT request. A Transaction is meaningful only to the pair of home servers that 
    exchanged it; they are not globally-meaningful.
    
    Each transaction has:
     - An opaque transaction ID.
     - A timestamp (UNIX epoch time in milliseconds) generated by its origin server.
     - An origin and destination server name.
     - A list of "previous IDs".
     - A list of PDUs and EDUs - the actual message payload that the Transaction carries.
    
     {
      "transaction_id":"916d630ea616342b42e98a3be0b74113",
    
      "ts":1404835423000,
      "origin":"red",
      "destination":"blue",
      "prev_ids":["e1da392e61898be4d2009b9fecce5325"],
      "pdus":[...],
    
    The ``prev_ids`` field contains a list of previous transaction IDs that
    the ``origin`` server has sent to this ``destination``. Its purpose is to act as a
    
    sequence checking mechanism - the destination server can check whether it has
    successfully received that Transaction, or ask for a retransmission if not.
    
    
    The ``pdus`` field of a transaction is a list, containing zero or more PDUs.[*]
    Each PDU is itself a JSON object containing a number of keys, the exact details of
    which will vary depending on the type of PDU. Similarly, the ``edus`` field is
    
    another list containing the EDUs. This key may be entirely absent if there are
    no EDUs to transfer.
    
    (* Normally the PDU list will be non-empty, but the server should cope with
    receiving an "empty" transaction, as this is useful for informing peers of other
    transaction IDs they should be aware of. This effectively acts as a push
    mechanism to encourage peers to continue to replicate content.)
    
    
    PDUs and EDUs
    -------------
    
    All PDUs have:
     - An ID
     - A context
     - A declaration of their type
     - A list of other PDU IDs that have been seen recently on that context (regardless of which origin
       sent them)
    
    
    [[TODO(paul): Update this structure so that 'pdu_id' is a two-element
    [origin,ref] pair like the prev_pdus are]]
    
    
      "context":"#example.green",
      "origin":"green",
      "ts":1404838188000,
      "pdu_type":"m.text",
      "prev_pdus":[["blue","99d16afbc857975916f1d73e49e52b65"]],
      "content":...
    
    In contrast to Transactions, it is important to note that the ``prev_pdus``
    
    field of a PDU refers to PDUs that any origin server has sent, rather than
    
    previous IDs that this ``origin`` has sent. This list may refer to other PDUs sent
    
    by the same origin as the current one, or other origins.
    
    Because of the distributed nature of participants in a Matrix conversation, it
    is impossible to establish a globally-consistent total ordering on the events.
    However, by annotating each outbound PDU at its origin with IDs of other PDUs it
    has received, a partial ordering can be constructed allowing causallity
    relationships to be preserved. A client can then display these messages to the
    end-user in some order consistent with their content and ensure that no message
    that is semantically in reply of an earlier one is ever displayed before it.
    
    PDUs fall into two main categories: those that deliver Events, and those that
    synchronise State. For PDUs that relate to State synchronisation, additional
    keys exist to support this:
    
    
     {...,
      "is_state":true,
      "state_key":TODO
      "power_level":TODO
      "prev_state_id":TODO
      "prev_state_origin":TODO}
    
    [[TODO(paul): At this point we should probably have a long description of how
    State management works, with descriptions of clobbering rules, power levels, etc
    etc... But some of that detail is rather up-in-the-air, on the whiteboard, and
    so on. This part needs refining. And writing in its own document as the details
    relate to the server/system as a whole, not specifically to server-server
    federation.]]
    
    EDUs, by comparison to PDUs, do not have an ID, a context, or a list of
    "previous" IDs. The only mandatory fields for these are the type, origin and
    destination home server names, and the actual nested content.
    
    
     {"edu_type":"m.presence",
      "origin":"blue",
      "destination":"orange",
      "content":...}
    
    Backfilling
    -----------
    - What it is, when is it used, how is it done
    
    SRV Records
    -----------
    - Why it is needed
    
    Security
    ========
    - rate limiting
    - crypto (s-s auth)
    - E2E
    - Lawful intercept + Key Escrow
    
    TODO Mark
    
    Policy Servers
    ==============
    TODO
    
    Content repository
    ==================
    - thumbnail paths
    
    Address book repository
    =======================
    - format
    
    
    Glossary
    ========
    - domain specific words/acronyms with definitions
    
    User ID:
      An opaque ID which identifies an end-user, which consists of some opaque 
      localpart combined with the domain name of their home server.