<?xml version="1.0" encoding="US-ASCII"?>
<!-- This document was derived from the template provided be Elwyn Davies (https://www.rfc-editor.org/template-bare-06.txt) -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- "Network Time Protocol (NTP)", D.L. Mills, September 1985 -->
<!ENTITY RFC0958 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.0958.xml">
<!-- "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies",
  N. Freed, N. Borenstein, November 1996 -->
<!ENTITY RFC2045 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2045.xml">
<!-- "Hypertext Transfer Protocol - HTTP/1.1", R. Fielding, J. Gettys, J. Mogul, H. Frystyk,
  L. Masinter, P. Leach, T. Berners-Lee, June 1999 -->
<!ENTITY RFC2616 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2616.xml">
<!-- "HTTP Authentication: Basic and Digest Access Authentication", J. Franks, P. Hallam-Baker,
  J. Hostetler, S. Lawrence, P. Leach, A. Luotonen, L. Stewart, June 1999 -->
<!ENTITY RFC2617 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2617.xml">
<!-- "Key words for use in RFCs to Indicate Requirement Levels", S. Bradner, March 1997 -->
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!-- "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies -
   Date and Time on the Internet: Timestamps", G. Klyne, C. Newman, July 2002 -->
<!ENTITY RFC3339 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3339.xml">
<!-- "Connection-Oriented Media Transport over the Transport Layer Security (TLS) Protocol in the
  Session Description Protocol (SDP), J. Lennox, July 2006 -->
<!ENTITY RFC4572 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4572.xml">
<!-- "Augmented BNF for Syntax Specifications: ABNF", D. Crocker, P. Overell,January 2008 -->
<!ENTITY RFC5234 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5234.xml">
<!-- "The Transport Layer Security (TLS) Protocol", T. Dierks, E. Rescorla, August 2008 -->
<!ENTITY RFC5246 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5246.xml">
]><?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<rfc category="info" docName="draft-baer-lightweight-token-authentication-00" ipr="trust200902">
  <!-- ***** FRONT MATTER ***** -->
  <front>
    <!-- The abbreviated title is used in the page header - it is only necessary if the full title is 
      longer than 39 characters -->
    <title abbrev="LTA 1.0">Lightweight Token authentication (LTA) 1.0</title>
    <!-- add 'role="editor"' below for the editors if appropriate -->
    <!-- Another author who claims to be an editor -->
    <author fullname="Sebastian Baer" initials="S.B." surname="Baer">
      <organization>Elektrobit</organization>
      <address>
        <postal>
          <street>Am Wolfsmantel 46</street>
          <city>Erlangen</city>
          <region></region>
          <code>91058</code>
          <country>Germany</country>
        </postal>
        <email>sebastian.baer@elektrobit.com</email>
      </address>
    </author>
    <author fullname="Bernd Haberstumpf" initials="B.H." surname="Haberstumpf">
      <organization>Elektrobit</organization>
      <address>
        <postal>
          <street>Am Wolfsmantel 46</street>
          <city>Erlangen</city>
          <region></region>
          <code>91058</code>
          <country>Germany</country>
        </postal>
        <email>bernd.haberstumpf@elektrobit.com</email>
      </address>
    </author>
    <date year="2015" />
    <!-- Meta-data Declarations -->
    <area>Internet</area>
    <workgroup></workgroup>
    <keyword>LTA token authentication</keyword>
    <abstract>
      <t>This document contains a specification for a token authentication mechanism that is
        sufficiently resource-friendly to use it on small embedded or mobile devices. The three
        involved parties are a service consumer (CON) a service provider (SP) and an authentication
        provider (AP). The authentication provider decouples authentication and the actual service
        that is consumed. It also serves as anonymizer. The consumer authenticates at the
        authentication provider, requests one or more authorization tokens and redeems those tokens
        when accessing the service provider's offered services.</t>
    </abstract>
  </front>
  <middle>
    <section title="Introduction">
      <t>The Lightweight Token Authentication is motivated by the need for a simple and resource
        friendly authentication mechanism mainly targeted (but not limited to) the use in embedded
        devices. This document specifies the LTA authentication protocol. 
      </t>
      <section title="Requirements Language">
        <t>
          The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD
          NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as
          described in
          <xref target="RFC2119">RFC 2119</xref>
          .
        </t>
      </section>
      <section title="Terminology">
        <t>
          <list style="hanging">
            <t>Authentication provider (AP): Network component that accepts authentication requests
              and issues authentication tokens to a consumer.</t>
            <t>Consumer (CON): Client application that wants to use a service offered by a service
              provider.</t>
            <t>Service provider (SP): Network component that offers a service to the consumer.</t>
            <t>Service identification URI (SIU): URI of the service used to identify a service in a
              token. Not necessarily the URI under which the service can be reached.</t>
            <t>Service permission URI (SPU): URI that represents a permission on the service.</t>
            <t>Time to use (TTU): Recommended time span for which a token should be used by a
              consumer before the consumer requests a new token.</t>
          </list>
        </t>
      </section>
      <section title="Design Goals">
        <t>The design of the Lightweight Token Authentication (LTA) aims to reach the goals
          described in the following sub-sections.</t>
        <section title="Low Resource Usage and Simple Implementation in the Consumer">
          <t> It is the most important goal of the LTA to be able to run on small embedded computers
            (like electronic control units in a car or motorcycle) and mobile devices. Therefore the
            design keeps the software dependencies and resource requirements low on the consumer
            side. Calculation and traffic intensive parts of the LTA are shifted to the
            authentication provider and the service provider. 
          </t>
          <t>
            The aim is to keep the following points down in order of importance:
            <list style="numbers">
              <t>Network traffic</t>
              <t>Memory consumption in the consumer</t>
              <t>CPU consumption in the consumer</t>
              <t>Dependencies on 3rd-party software modules in the consumer</t>
            </list>
          </t>
        </section>
        <section title="Works with Standard HTTP + TLS">
          <t>HTTP software libraries can be considered a commodity - just like the availability of
            network connections that can transport HTTP. LTA therefore uses HTTP as its transport
            protocol and TLS as transport security. 
          </t>
        </section>
        <section title="Small Network Overhead">
          <t> LTA aims to keep the additional network overhead low. Token requests and the token
            headers are both designed to stay as small as reasonable while still being in alignment
            with the philosophy of HTTP. Another goal is to keep the total number of request for
            authentication down. 
          </t>
          <t> Typical sizes for LTA tokens including signature are below 500 bytes. 
          </t>
          <t>
            The authors are clear on the fact that the biggest part of the network overhead comes
            from transport security, namely the use of TLS (see
            <xref target="sec:transport_security" />
            ) but they consider the advantages of using such widely accepted standards to be worth
            choosing them over proprietary protocol stacks that might reduce network overhead
            further.
          </t>
        </section>
        <section title="Robustness">
          <t>LTA works without a permanent connection between the authentication provider and the
            service provider in order to remove one possible cause for a service outage. 
          </t>
          <t>LTA allows consumers to repeat requests. This is important for mobile or embedded
            devices with an unstable network connection. Service providers that are based on LTA are
            encouraged to design their services so that they also accept request repetition. 
          </t>
        </section>
        <section title="Support a Stateless Service Provider">
          <t>The LTA does not force the service provider to manage state. Many services are
            intentionally designed stateless, especially to allow for efficient scaling. 
          </t>
        </section>
        <section title="Anonymization">
          <t>The separation into authentication provider and service provider aims to anonymize the
            consumer towards the service provider. This protects the consumer's privacy while still
            allowing the provider to offer services with access restrictions. 
          </t>
          <t>While the authentication provider knows the identity of the consumers - or even the
            users behind the consumer applications - it does not know, what data the consumers send
            to a service. 
          </t>
          <t>From the service provider's perspective the consumer is anonymous. The token that the
            user offers to the service provider does not allow the service provider to identify a
            consumer. 
          </t>
          <t>To ensure anonymization, service provider and authentication provider must be separate
            entities which should also be clearly separated on an organizational level. Especially
            the authentication provider must not disclose a token-to-consumer mapping to the service
            provider. 
          </t>
          <t>
            See
            <xref target="sec:anonymization_limitations" />
            for limitations on the achieved level of anonymity.
          </t>
        </section>
      </section>
    </section>
    <section title="Preconditions">
      <section title="Transport security" anchor="sec:transport_security">
        <t> LTA relies on transport encryption (as opposed to message encryption) between the three
          involved parties. 
        </t>
        <t>
          Consumer, authentication provider and service provider MUST all use Transport Layer
          Security (TLS) in version 1.2 or newer. See
          <xref target="RFC5246" />
          for details.
        </t>
      </section>
      <section title="Authentication of the communication partners">
        <t>The consumer MUST verify the authenticity of the communication partners - i.e.
          authentication provider and service provider. 
        </t>
        <t>
          The recommended way is using TLS server certificates. See
          <xref target="RFC5246" />
          section 7.4.2 for details.
        </t>
        <t>
          The service provider indirectly authenticates the authentication provider via the token
          signature. See
          <xref target="sec:service_provider_validates_and_authentications_token" />
          for more information.
        </t>
      </section>
      <section title="Syntax Definitions">
        <t>
          The syntax definitions in this document use the "Augmented Backus Naur Form" (ABNF) as
          defined in
          <xref target="RFC5234" />
          .
        </t>
      </section>
      <section title="Base Elements of the Syntax Definitions">
        <t> The following recurring syntax elements are used throughout the document and therefore
          introduced here.</t>
        <t> LTA's protocol version (and implicitly the token format): 
        </t>
        <figure>
          <artwork type="abnf">lta-version = 1*DIGIT "." 1*DIGIT</artwork>
        </figure>
        <t> In this revision of the LTA specification the LTA version is 1.0. 
        </t>
        <t>The URI that identifies a service: 
        </t>
        <figure>
          <artwork type="abnf">service-identification-uri</artwork>
        </figure>
      </section>
    </section>
    <section title="Authentication Overview">
      <t>The authentication provider is a service that provides consumer authentication and
        authorization. It also anonymizes the consumers towards the service provider. Instead of
        authenticating themselves directly at the service provider the consumers use the
        authentication provider as authentication authority. 
      </t>
      <t>In short a successful authentication follows these steps: 
      </t>
      <t>
        <list style="numbers">
          <t>Consumer uses the authentication offers discovery to find out where to request tokens. 
          </t>
          <t>Consumer requests a token at the authentication provider. 
          </t>
          <t>Authentication provider authenticates the consumer and issues a token. 
          </t>
          <t>Consumer redeems the token at the 3rd party service. 
          </t>
          <t>Service provider verifies the authenticity of the token. 
          </t>
        </list>
      </t>
    </section>
    <section title="Consumer Authentication at the Authentication Provider">
      <t>The consumer MUST provide credentials with all requests to the authentication header. This
        rule applies to the authentication offer list request and all other (subsequent) requests to
        the authentication provider. 
      </t>
      <t>
        An authentication provider SHOULD at least support the "Basic" authentication scheme as
        defined in
        <xref target="RFC2617" />
        section 2. Other authentication schemes can be used between the consumer and the
        authentication provider also but implementers should keep in mind that complicated
        authentication schemes are in conflict with the design goal to keep the effort low for the
        consumer.
      </t>
      <t>A consumer using basic authentication would set the following header: 
      </t>
      <figure>
        <artwork type="abnf">authorization = "Authorization:" 1*SP "Basic" 1*SP credentials</artwork>
      </figure>
      <t>
        The credentials are encoded with the "Base64 Content-Transfer-Encoding" described in
        <xref target="RFC2045" />
        section 6.8.
      </t>
      <t>Example:</t>
      <figure>
        <artwork type="abnf"><![CDATA[Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==]]></artwork>
      </figure>
      <t>Since basic authentication can be considered a commodity of the widely available web
        servers the implementation is not in the scope of this document. 
      </t>
    </section>
    <section title="Authentication Offers Discovery" anchor="sec:authentication_offers_discovery">
      <t>The authentication provider has a single entry point. The consumer accesses this entry
        point and gets a list of URIs that it uses to find out for which services the authentication
        provider offers tokens. 
      </t>
      <figure>
        <artwork align="center" type="abnf"><![CDATA[
+-----+                                         +-----+
| CON |                                         | AP  |
+--+--+                                         +--+--+
   |   discoverAuthenticationOffers(credentials)   |
   |---------------------------------------------->|
   |                                               |--.
   |                            checkCredentials() |  |
   |                                               |<-'
   |          : authenticationOfferList            |
   |< - - - - - - - - - - - - - - - - - - - - - - -|
   |                                               |]]>
        </artwork>
      </figure>
      <section title="Consumer Request for Authentication Offer List">
        <t>The consumer requests the offer list with the following request: 
        </t>
        <figure>
          <artwork type="abfn">authentication-offer-uri = "GET" SP ap-entry-uri "/"
            lta-version-number</artwork>
        </figure>
        <t>Where "ap-entry-uri" is the entry URI of the authentication provider that the consumer
          must know. 
        </t>
        <t>The mandatory protocol version number allows to easily route consumers that use different
          protocol versions to the right authentication provider. If the authentication provider
          supports multiple versions it MUST offer one offer discovery URI in the form of
          "authentication-offer-uri" for each supported protocol version. 
        </t>
        <section title="Authentication Offer List Response">
          <t>The authentication provider first checks the credentials of the consumer. If the user
            has a valid account, the authentication provider creates a list of all services the
            consumer is registered for. 
          </t>
        </section>
        <section title="Access to Offer List Granted">
          <t>If the consumer's credentials are valid, the authentication provider MUST answer with
            200 (OK). 
          </t>
          <t>The offer response body MUST contain a map of URIs with the Mime type "text/uri-map". 
          </t>
          <t>Each line of the map has the following format: 
          </t>
          <figure>
            <artwork type="abfn">offer-list-entry = service-identification-uri "&gt;"
              token-request-uri CR LF</artwork>
          </figure>
          <t>So for each service the map tells the consumer under which URI it must request the
            authentication token. 
          </t>
          <t>Example URI map:</t>
          <figure>
            <artwork align="left"><![CDATA[https://www.example.org/wiki>https://example.com/
  ap_node234/1.0/https%3A%2F%2Fexample.org%2Fwiki
org.example.blog>https://example.com/ap/1.0/org.example.blog]]>
            </artwork>
          </figure>
          <t>Note that in the example above there is an extra newline an indentation due to line
            length restrictions. Both are not present in the actual URI map. 
          </t>
          <t>The authentication provider MUST only list those services for which it actually offers
            a token to the individual consumer. That means a consumer can expect that it has the
            necessary rights to request a token under each of the listed URIs. 
          </t>
          <t>If the authentication provider does not offer authentication for any services to the
            consumer, the offer list MUST be empty. 
          </t>
        </section>
        <section title="Offer List Request Denied Because of Missing Credentials">
          <t>The authentication provider MUST answer 401 (Unauthorized) if the consumer does not
            provide the required authentication header. 
          </t>
        </section>
        <section title="Offer List Request Denied Because of Invalid Credentials">
          <t>The authentication provider MUST answer 401 (Unauthorized) if the credentials the
            consumer used are not valid. 
          </t>
        </section>
      </section>
    </section>
    <section title="Authentication Step by Step">
      <t>The following diagram depicts the sequence for a successful authentication: 
      </t>
      <figure>
        <artwork align="center"><![CDATA[
+-----+                         +-----+                       +-----+
| CON |                         | AP  |                       | SP  |
+--+--+                         +--+--+                       +--+--+
   |   requestToken(credentials)   |                             |
   |------------------------------>|                             |
   |                               |--. checkCredentials()       |
   |                               |  | calculateExpiration()    |
   |                               |  | createToken()            |
   |                               |  | signPayload()            |
   |            : token            |<-'                          |
   |< - - - - - - - - - - - - - - -|                             |
   |                               |                             |
   |                    requestService(..., token)               |
   |------------------------------------------------------------>|
   |                               |                             |--.
   |                               |          checkTokenFormat() |  |
   |                               |           checkAddressing() |  |
   |                               |            checkSignature() |  |
   |                               |           checkExpiration() |  |
   |                               |                             |<-'
   |                               |                             |--.
   |                               |   executeRequestedService() |  |
   |                               |                             |<-'
   |                          : response                         |
   |< - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
   |                               |                             |]]></artwork>
      </figure>
      <section title="Consumer Requests Token">
        <t>The consumer MUST initiate the authentication by requesting a token from the
          authentication provider with the following request:</t>
        <figure>
          <artwork type="abfn">token-request = "GET" SP token-request-uri</artwork>
        </figure>
        <t>
          Where the "token-request-uri" is a URI that the consumer previously discovered via an
          offer list request to the authentication provider. See
          <xref target="sec:authentication_offers_discovery" />
          for details.
        </t>
        <figure>
          <preamble>Example:</preamble>
          <artwork><![CDATA[GET https://example.com/ap/1.0/https%3A%2F%2Fexample.org%2Fwiki]]></artwork>
        </figure>
      </section>
      <section title="Consumer Sets &quot;Accept&quot; Headers">
        <t> The consumer MUST NOT set the "Accept" header since the token format is dictated by the
          common denominator of authentication provider and service provider. 
        </t>
        <t>
          The consumer CAN set an "Accept-Charset" header that has one of the following values:
          <list style="symbols">
            <t>UTF-8</t>
            <t>US-ASCII</t>
          </list>
        </t>
        <t>
          Tokens only contain only 7bit ASCII characters. See
          <xref target="sec:creating_a_token" />
          for details.
        </t>
        <t>
          The consumer CAN set an "Accept-Language"" header. See
          <xref target="RFC2616" />
          section 14.4 for more information. This only has an influence on the language of error
          messages issued by the authentication provider. Those error messages are used in response
          to illegal requests or other abnormal situations. Note that authentication providers are
          allowed to ignore this header and only provide English error messages. See
          <xref target="sec:error_reporting_in_the_response_body" />
          for details.
        </t>
      </section>
      <section title="Authentication Provider Authenticates the Consumer">
        <t>The authentication provider checks the credentials provided by the consumer. 
        </t>
      </section>
      <section title="Creating a Token" anchor="sec:creating_a_token">
        <t>An authentication token is a credential issued by the authentication provider and used by
          the consumer to gain access to a service provider's services. 
        </t>
        <t>The authentication token MUST only contain characters from the 7bit ASCII character set.
          This way maximum compatibility across different character sets is ensured. For example
          UTF-8 is compatible to 7bit ASCII. 
        </t>
        <t>An authentication token created by the authentication provider MUST have the following
          format:</t>
        <figure>
          <artwork type="abfn">token = token-payload " " signature</artwork>
        </figure>
        <t>The token payload is defined as follows:</t>
        <figure>
          <artwork type="abfn">token-payload = lta-version " " service-specification " " expiration
            " " time-to-use</artwork>
        </figure>
        <t>The service specification identifies service and permissions: 
        </t>
        <figure>
          <artwork type="abfn">service-specification = service-identification-uri ( *( "|"
            service-permission-uri ) / "*" )</artwork>
        </figure>
        <t> The signature is defined as follows: 
        </t>
        <figure>
          <artwork type="abfn">signature = signature-info "|" signature-container</artwork>
        </figure>
        <figure>
          <artwork>signature-info = ( hash-algorithm "|" encryption ) / container-format</artwork>
        </figure>
        <t>
          Note that the payload of the token and the signature meta-data are not encrypted since the
          consumer must be able to read the contents of the token but not to modify them. Refer to
          <xref target="sec:creating_the_token_signature" />
          for details. This is important because the consumer has to take the token expiration into
          account before trying to redeem a token at a service provider. It would cause unnecessary
          traffic if the consumer tried to redeem an expired token.
        </t>
        <t>The list of service permission URIs can be replaced by an asterisk "*" symbol in case no
          access restrictions below the service level are necessary.</t>
        <t>Examples for service specifications:</t>
        <figure>
          <artwork><![CDATA[https://example.org/blog|*]]></artwork>
        </figure>
        <figure>
          <artwork><![CDATA[https://example.org/blog|get|head]]></artwork>
        </figure>
        <figure>
          <artwork><![CDATA[blog.example.org editor|admin]]></artwork>
        </figure>
        <section title="The Token Format Explained">
          <t>
            There are restrictions that lead to the design of the token format.
            <list style="numbers">
              <t>The consumer MUST be able to copy the received token directly into an HTTP header
                without modifying it. Therefore only ASCII characters that are allowed as header
                fields values can be used.</t>
              <t>
                The parts the token consists of MUST be separable by the most simple string
                manipulation. It is designed to be split at separator characters.
                <list>
                  <t>Since parts of the token are URIs, only characters that are not allowed in a
                    URI are suitable as separators</t>
                  <t>The building blocks are split at the " " character</t>
                  <t>The permissions and signature parts are separated by "|"</t>
                </list>
              </t>
            </list>
          </t>
          <t>The reason why there are two kinds of separators is that we want to be able to vary the
            number of sub-items. 
          </t>
        </section>
        <section title="Token Expiration">
          <t>The authentication provider MUST calculate an expiration date and time for each token.</t>
          <t>The expiration delay of a token MUST be configurable in the authentication provider per
            service provider URI.</t>
          <t>
            The expiration time in the token MUST be encoded as date and time according to the
            following pattern as specified in
            <xref target="RFC3339" />
            section 5.6.
          </t>
          <figure>
            <artwork type="abfn">expiration = year "-" month "-" day "T" hours ":" minutes ":"
              seconds "Z"</artwork>
          </figure>
          <figure>
            <artwork type="abfn">year = 4DIGIT month = ( "0" DIGIT ) / 11 / 12</artwork>
          </figure>
          <figure>
            <artwork type="abfn">day = ( "0" / "1" / "2") DIGIT / 30 / 31</artwork>
          </figure>
          <figure>
            <artwork type="abfn">hours = ( ( "0" / "1") DIGIT ) / 21 / 22 / 23</artwork>
          </figure>
          <figure>
            <artwork type="abnf">minutes = ( "0" / "1" / "2" / "3" / "4" / "5") DIGIT</artwork>
          </figure>
          <figure>
            <artwork type="abfn">seconds = ( "0" / "1" / "2" / "3" / "4" / "5") DIGIT</artwork>
          </figure>
          <t>All expiration timestamps MUST be encoded in Coordinated Universal Time (UTC). If the
            server is in a different time zone , the authentication provider MUST convert the time
            accordingly.</t>
          <figure>
            <artwork type="abfn">time-to-use = 1*DIGIT</artwork>
          </figure>
          <t>The time to use (TTU) is the number of seconds the token should be used after it was
            issued.</t>
          <t>
            In simple implementations the time to use is equal to the time to live. In this case the
            TTU is redundant at first glance, but it is a concession to consumers that do not have
            proper clock synchronization. See
            <xref target="sec:time_to_use" />
            for details.
          </t>
          <t>
            In more sophisticated implementations the authentication provider chooses a TTU that is
            shorter than the difference between token issuing time and expiration time. See
            <xref target="sec:issuing_new_token_shortly_before_the_existing_token_expires" />
            for more information.
          </t>
        </section>
      </section>
      <section anchor="sec:creating_the_token_signature" title="Creating the token signature">
        <t>The authentication provider MUST sign the token payload using a hash algorithm and its
          private key. 
        </t>
        <t>LTA supports exchanging the signing mechanism. It needs an asymmetric encryption in order
          to create a token signature. 
        </t>
        <t>The authentication provider MUST state either the hash algorithm and encryption it uses
          to create in the token signature or a signature container format. This tells the service
          provider how to validate the signature. 
        </t>
        <t>
          Refer to
          <xref target="sec:supported_signing_mechanisms" />
          for a list of supported algorithms.
        </t>
      </section>
    </section>
    <section title="Authentication Provider Answers Token Request">
      <t>Depending on whether or not the authentication provider was able to identify the consumer,
        the authentication provider either issues a token or tells the consumer that it could not be
        authenticated.</t>
      <section title="Token Request Granted">
        <t>The authentication provider must answer 200 (OK) if the consumer was authenticated
          successfully and if the user is authorized to use the requested service or services. 
        </t>
        <t>In this case the response body contains the token.</t>
        <figure>
          <artwork type="abfn">token-response-body = token</artwork>
        </figure>
        <t>The authentication provider MUST mark responses that contain an LTA token with MIME type
          "application/lta" in the "Content-Type" header.</t>
        <t>Example:</t>
        <figure>
          <artwork><![CDATA[HTTP/1.1 200 OK Date: Mon, 01 Jan 2015 14:21:16 GMT
Content-Type: application/lta
Content-Length: 451

1.0 org.example.wiki * 2015-01-01T14:21:46Z 25
sha-1|rsa|iQEcBA[...]c+s=]]></artwork>
        </figure>
        <t>The example above is shortened (marked by "[...]") for better readability.</t>
      </section>
      <section title="Token Request Denied Because of Missing Credentials">
        <t>The authentication provider MUST answer 401 (Unauthorized) if the consumer does not
          provide the required authentication header. 
        </t>
      </section>
      <section title="Token Request Denied Because of Invalid Credentials">
        <t>The authentication provider MUST answer 401 (Unauthorized) if the credentials the
          consumer provided are invalid. 
        </t>
      </section>
    </section>
    <section title="Consumer Redeems Token">
      <t>The consumer sends a requests to the service provider and uses the token as credential. For
        this it MUST set the following HTTP header in the service request:</t>
      <figure>
        <artwork type="abfn">auth-header = "Authorization:" SP "Token" token</artwork>
      </figure>
      <t>Note that the consumer does not necessarily need to understand the signature. It can rely
        on the authenticity of the sender when using HTTPS instead. This allows the consumer to work
        without needing to decode the signature. 
      </t>
      <section title="Consumers Should Not Try to Use Expired Tokens">
        <t>
          Consumers SHOULD NOT try to use expired tokens. There are two alternative ways for the
          consumer to determine if a token is expired:
          <list style="numbers">
            <t>via the absolute expiration time - for a consumer with reliable time synchronization</t>
            <t>via the time to use (TTU) - works without time synchronization</t>
          </list>
        </t>
      </section>
      <section title="Expiration Time">
        <t>Properly time synchronized consumers should use the absolute expiration time from the
          token to determine if the token can still be used or if it already expired.</t>
      </section>
      <section title="Time to Use" anchor="sec:time_to_use">
        <t>
          The time to use (TTU) is a time span between issuing of the token and the time when it is
          recommended the consumer requests a new token. The TTU may be lower than the difference
          between issuing and expiration of a token See
          <xref target="sec:issuing_new_token_shortly_before_the_existing_token_expires" />
          for more information.
        </t>
        <t>Also consumers like mobile devices and embedded computers might not have proper time
          synchronization or might use the wrong time zone. Therefore using the TTU instead of the
          absolute expiration time is recommended on the consumer side.</t>
        <t>The downside of this mechanism is that a part of the TTU given in the token is already
          used up in the transmission from the authentication provider to the consumer. Since the
          consumer has no simple means to tell how long this delay is, it will consider the token
          valid longer than it actually is. The authentication provider CAN mitigate that problem by
          choosing reasonable safety margin between the expiration of a token and the TTU specified
          in the token. 
        </t>
      </section>
    </section>
    <section title="Service Provider Validates and Authenticates Token" anchor="sec:service_provider_validates_and_authentications_token">
      <t>Before the service provider offers its services, it validates and authenticates the token
        sent by the consumer.</t>
      <section title="Validating a token">
        <t>The service provider MUST validate the token format. If the token format does not conform
          to this document, the service provider MUST deny the request.</t>
      </section>
      <section title="Checking if the Token Is Addressed to the Right Service Provider"
        anchor="sec:checking_addressed_to_the_right_service_provider">
        <t>Since consumers might accidently or maliciously try to use an authentication token for
          the wrong service provider, a service provider MUST always check if a token is really
          addressed to it. The service provider MUST check if the service identification URI in the
          token matches the requested service.</t>
        <t>Note that the service identification URI is not necessarily the URI under which the
          service can be reached in a network. Authentication provider and service provider just
          have to agree on a common URI.</t>
      </section>
      <section title="Checking the Signature">
        <t>The service provider checks the signature of the token to verify that it has been issued
          by the authentication provider and has not been modified.</t>
        <t>If the signature does not match the token payload, the service provider MUST deny the
          request.</t>
      </section>
      <section title="Checking if the Token Expired">
        <t>The service provider compares the expiration date and time from the token to the current
          date and time. If the token's expiration time lies in the past, the service provider MUST
          deny the request.</t>
        <t>
          The service provider MUST always use the absolute expiration time from the token. The
          time-to-use is reserved for consumer use only and MUST be ignored by the service provider.
          The service provider MUST use clock synchronization (e.g. the "Network Time Protocol", see
          <xref target="RFC0958" />
          ) that grants a synchronization quality of typically below one second. See
          <xref target="sec:time_synchronization_attack" />
          for security considerations of time synchronization.
        </t>
        <t>
          The service provider MUST take the time differences into account that result from the
          timezone the service provider is located in. Token expiration times inside the token are
          always given in UTC (see
          <xref target="RFC3339" />
          ). Service providers MUST convert their local time to UTC before evaluating token expiry.
        </t>
        <t>Service providers MUST NOT accept tokens where the expiration time is more than two hours
          in the future. This is a safety measure in order to avoid long-term valid tokens issued by
          accident by the authentication provider.</t>
      </section>
    </section>
    <section title="Service Provider Answers the Request">
      <section title="Service access granted">
        <t>The service provider MUST answer 200 (OK) if the token was successfully validated and
          authenticated. The response body is the normal service response. 
        </t>
      </section>
      <section title="Access Denied due to Missing Authentication Token">
        <t>The service provider MUST answer 401 (Unauthorized) if the consumer does not provide the
          token in the authentication header. 
        </t>
        <t>
          In addition the service provider must set the "WWW-Authenticate" header (see
          <xref target="RFC2617" />
          section 1.2 ) as follows:
        </t>
        <figure>
          <artwork type="abfn">challenge = "Token" 1*SP "realm" "=" DQOUTE
            service-identification-uri DQUOTE</artwork>
        </figure>
        <t>Example:</t>
        <figure>
          <artwork><![CDATA[WWW-Authenticate: Token realm="https://example.org/blog"]]></artwork>
        </figure>
      </section>
      <section title="Access Denied Because of Illegal Token Format">
        <t>The service provider MUST answer 400 (Bad Request) if the token or parts of the token do
          not conform to this document.</t>
      </section>
      <section title="Access Denied Because of Signature Mismatch">
        <t>The service provider MUST answer 401 (Unauthorized) if the token signature and does not
          match the token payload.</t>
      </section>
      <section title="Access Denied Because of Unsupported Signing Mechanism">
        <t>If the service provider does not understand the encryption algorithm or hash function
          used for signing the token it MUST answer 400 (Bad Request). 
        </t>
        <t>The response MUST contain a header field listing the supported hash algorithms: 
        </t>
        <figure>
          <artwork type="abfn">accept-hash-header = "Accept-Token-Hashes:" SP hash *( "," SP hash)</artwork>
        </figure>
        <t>The response MUST contain a header field listing the supported ciphers: 
        </t>
        <figure>
          <artwork type="abfn">accept-cipher-header = "Accept-Token-Ciphers:" SP cipher *( "," SP
            cipher)</artwork>
        </figure>
        <t> Example: 
        </t>
        <figure>
          <artwork><![CDATA[Accept-Token-Hashes: sha-1, sha-256
Accept-Token-Ciphers: rsa]]></artwork>
        </figure>
      </section>
      <section title="Access Denied Because of Expired Token">
        <t>The service provider MUST answer 401 (Unauthorized) if the token expired. 
        </t>
      </section>
      <section title="Access Denied Because of Insufficient Permissions">
        <t>The service provider MUST answer 403 (Forbidden) if the rights specified in the token are
          not sufficient to execute the service request. 
        </t>
      </section>
      <section title="Supported Signing Mechanisms" anchor="sec:supported_signing_mechanisms">
        <t>LTA is designed to support different token representations in order to be able to replace
          the signing mechanism when a more efficient or more secure algorithm is available.</t>
        <t>This document therefore contains only a very short list of supported hashes and cyphers.
          While requiring mandatory implementations is good for interoperability, it would be unwise
          to use mechanisms that are not cryptographically secure anymore. 
        </t>
        <t>
          The hash function textual names are as defined in
          <xref target="IANA1"> in the IANA registry.</xref>
        </t>
        <t>
          Examples:
          <list style="symbols">
            <t>sha-1</t>
            <t>sha-256</t>
          </list>
        </t>
        <t>The textual names for encryptions follow the same style.</t>
        <t>
          Examples
          <list style="symbols">
            <t>rsa</t>
            <t>ecc</t>
          </list>
        </t>
        <t>As long as AP and SP agree, they can use implementations not listed here.</t>
      </section>
      <section title="Using a Signature container">
        <t>
          Signature container formats contain the signature plus the meta information on how to
          verify it and can be used as an alternative to encoding the hash function an encryption
          algorithm. While in principle any container format could be used, some technical
          restrictions apply:
          <list style="numbers">
            <t>The signature containers encoding must only contain characters allowed in an HTTP
              header field.</t>
            <t>The container should be small because it otherwise conflicts with the goal of low
              network overhead.</t>
          </list>
        </t>
        <t>The benefit for using standard containers is that they often come with a full
          infrastructure for key distribution and revoking (both mechanisms outside of the scope of
          this document). 
        </t>
      </section>
      <section anchor="sec:error_reporting_in_the_response_body" title="Error reporting in the response body">
        <t>When connecting to web services, it is useful to have clear error messages in case
          something went wrong. The following recommendations apply to both, the authentication
          provider and the service provider. 
        </t>
        <t>The response body of a response with an "4xx" error code should contain a clear text
          description of the error cause. 
        </t>
        <t>The
          error message SHOULD respect the language requested if an <![CDATA[Accept-Language]]>
          header was set in the request. At least English error messages SHOULD be supported. 
        </t>
        <t>Unless specified explicitly, the error messages do not have to be machine readable.</t>
        <t>Error messages MUST NOT disclose confidential information to the consumer. Especially
          error messages MUST NOT contain information that helps an attacker to guess credentials.</t>
      </section>
    </section>
    <section title="Optimizations">
      <section title="Authentication Provider Optimizations">
        <section title="Authentication Provider Sets Cache Header of a Token">
          <t>The authentication provider MAY set the following cache header:</t>
          <figure>
            <artwork type="abfn">cache-control = "cache-control:" SP "private," SP "max-age="
              time-to-use</artwork>
          </figure>
          <t>The cache directive "private" tells all involved parties that caching is only supposed
            to happen in the consumer. 
          </t>
          <t>Where the time to use in seconds is used as maximum cache age of the response.</t>
          <figure>
            <artwork type="abfn">time-to-use = 1*DIGIT</artwork>
          </figure>
          <t>Example:</t>
          <figure>
            <artwork><![CDATA[cache-control: private, max-age=25]]></artwork>
          </figure>
          <t>This is useful for consumers that do not implement their own consumer side token cache
            and rely on the caching their HTTP client library offers. Otherwise it is superfluous. 
          </t>
        </section>
        <section title="Token Cache on Authentication Provider Side">
          <t>If the same consumer requests a token with an unconditional "GET" before the old
            token's time-to-use is reached, the authentication provider SHOULD return the same token
            instead of creating a new one. For this the authentication provider needs a token cache
            that holds one not-expired token per consumer. 
          </t>
          <t>
            If the same consumer requests a token with a conditional "GET" before the time to use is
            reached, the authentication provider SHOULD answer with 304 as specified in
            <xref target="RFC2616" />
            section 10.3.5.
          </t>
          <t>On the one hand this optimization improves the behaviour of the "GET" requests for
            tokens. The authentication provider does not create new tokens while the old token is
            still valid - a desired feature for a get request. 
          </t>
          <t>On the other hand this introduces a shared state between instances of the
            authentication provider making scalability more complicated.</t>
          <t>Implementors should decide on which argument is more important for their use cases.</t>
        </section>
        <section anchor="sec:issuing_new_token_shortly_before_the_existing_token_expires"
          title="Issuing a new Token Shortly Before the Existing Token Expires">
          <t>The authentication provider SHOULD introduce a configurable time span (TTU) that is
            smaller than the difference of token issuing time to expiration time. The TTU is used to
            determine when a new token must be issued. This helps to avoid situations where the
            consumer gets a token that is almost expired.</t>
        </section>
        <section title="Token Representation Compatibility with Service Provider">
          <t>The applicable token formats are dictated by the common denominator between
            authentication provider and service provider. For each service the authentication
            provider SHOULD store and respect the token representations the service provider
            understands.</t>
        </section>
      </section>
      <section title="Service Provider Optimizations">
        <section title="Token Cache on Service Provider Side">
          <t>Service providers MAY cache the result of a token evaluation until the token expires,
            especially for services where a series of request can be expected during the life time
            of a token. 
          </t>
          <t>Note that in a clustered service this would have to be centralized potentially
            introducing a new point of failure and requiring additional network communication. 
          </t>
          <t>Therefore in clustered environments a node-local token cache is recommended in
            combination with consumer affinity (e.g. IP affinity).</t>
        </section>
      </section>
      <section title="Consumer Optimizations">
        <section title="Caching the Token Request URIs">
          <t>The Consumer SHOULD cache the token request URIs listed by the authentication provider.
            This removes unnecessary subsequent discovery traffic. 
          </t>
          <t>The recommended way is doing this is on application layer.</t>
          <t>If a token request fails, a consumer MUST invalidate its token request URI cache,
            because it is likely that either the URI or the consumers permissions changed.</t>
          <t>For security reasons the consumers MUST NOT cache the token request URIs indefinitely.
            The recommended caching time is a day.</t>
          <t>Example:</t>
          <t>An embedded device requests the token offer list and keeps the result cached in RAM
            until the next power cycle or day.</t>
        </section>
        <section title="Using Tokens until They Expire">
          <t>Although it is possible that consumers request a token before each service request,
            this introduces unnecessary network traffic if the last token is not yet expired. 
          </t>
          <t>The Consumer SHOULD reuse the token until the token expired. 
          </t>
        </section>
      </section>
    </section>
    <section title="Permission Handling">
      <section title="Service identification URIs">
        <t> A service identification URI (short "SIU") uniquely identifies a service. It MUST be
          agreed upon by both, the service provider and the authentication provider. 
        </t>
        <t> If permissions on a sub-service level are necessary, then the service provider MUST
          define a service permission URI for each permission. 
        </t>
      </section>
      <section title="Choosing Service Identification URIs and Permission URIs">
        <t>It is not mandatory that service identification URIs or permission URIs are can be
          dereferenced.</t>
        <t>While it is easier to understand if the service identification URI is identical to the
          URI the service can be reached, it is not required.</t>
        <t>Note that the token - and therefore the SIUs are transmitted in the HTTP header. Although
          the HTTP specification does not define a size limit on the HTTP headers, in real-world
          scenarios the web servers use default limits between four and eight kilobytes.</t>
        <t>This fact and the goal that LTA should be resource-friendly both suggest that service
          providers define short URIs to identify services.</t>
        <t>Permission URIs should be relative to the service identification URI to save more space.</t>
        <t>
          Examples:
          <list style="numbers">
            <t>Sub-service level permissions for a restful HTTP service could be the request verbs
              "get", "put" or "delete". 
            </t>
            <t>For an accounting system permissions could be on artifact level "invoices",
              "cancellations" or "customers". 
            </t>
            <t>A service could also use roles instead of permissions "admin", "user" or "guest". 
            </t>
          </list>
        </t>
      </section>
      <section title="Permission URI wildcard">
        <t>If no sub-service level permissions are needed, the authentication provider should use
          the wildcard "*" instead of listing of all permissions. 
        </t>
        <t>Example:</t>
        <t>A service provider defines dot-notation URIs for its services like "org.example.wiki".
          The service provider does not impose restrictions on the use of the service and marks this
          with the "*" wildcard.</t>
        <t>Internally it assembles the permission URI to "org.example.wiki.*"" and uses this for
          authorization checks.</t>
      </section>
      <section title="Parameterized Permissions">
        <t>Imagine a user payed for a storing ten photos with a total size of not more than 20 MiB
          on a service. The service provider and the authentication provider agreed on a common
          scheme for representing this as a permission URI which looks like: 
        </t>
        <figure>
          <artwork><![CDATA[store?max-items=10&max-size=20M]]></artwork>
        </figure>
        <t> It is a valid URI and it contains parameters. Given that the authentication provider
          knows how to build this URI and the service provider knows how to interpret it. 
        </t>
      </section>
    </section>
    <section title="Examples">
      <section title="Token Requests">
        <t>Consumer: 
        </t>
        <figure>
          <artwork><![CDATA[GET https://example.com/ap/https%3A%2F%2Fexample.org%2Fblog
Authorization: Basic ZXhhbXBsZV91c2VyOmV4YW1wbGVfcGFzc3dvcmQ=
[...]]]></artwork>
        </figure>
        <t> Authentication provider: 
        </t>
        <figure>
          <artwork><![CDATA[HTTP/1.1 200 OK
Date: Mon, 01 Jan 2015 14:21:16 GMT
Content-Type: application/lta
Content-Length: 451

1.0 https://example.org/blog|get|post|delete 2015-01-01T14:21:46Z 25 
sha-1|rsa|iQEcBAABAgAGBQJT/yYfAAoJEBYE2BQYko+r47sH/jZNWgVpzoVXwfdFMVd
FkZYG69qDnYNy3rfxw8HtYWa7x1VEngo9x79G+Bk5GhlG62rNpyZAFc63pi9/9eddZEO
BBBwqWu7RA/h24DHfp0ngT0MO+H0zLldzTMSLCVkYYp+O3K5HlIqGhA9Rj32XKYBwjiM
wPBoIYAcTzbUOb9kih0Ru3jGp/7+K/FbQPZHYK98znvKN/r81PqK0LM3KFpBi1SL+gpv
IDm1sz/GjXGlAtBfMViHPcY6Vw6kjhpbuYEqPkOWty5gjhUntrrCyKpA069COR64bLqC
eIM7++3E5rZvH1dIYZ86u629xNna5Tj+TJSkev7Jnlfw0YFoc+s=]]></artwork>
        </figure>
        <t>Note that the line breaks in the example HTTP body have been added for readability and
          are _not_ present in an actual token. 
        </t>
      </section>
      <section title="Service Request with LTA Token">
        <t>Consumer:</t>
        <figure>
          <artwork><![CDATA[GET https://example.org/blog/2015/01/01/img42.jpg

Authorization: Token 1.0 https://example.org/blog|get|post|delete
2015-01-01T14:21:46Z 25 sha-1|rsa|iQEcBAABAgAGBQJT/yYfAAoJEBYE2BQYko+
r47sH/jZNWgVpzoVXwfdFMVdFkZYG69qDnYNy3rfxw8HtYWa7x1VEngo9x79G+Bk5Ghl
G62rNpyZAFc63pi9/9eddZEOBBBwqWu7RA/h24DHfp0ngT0MO+H0zLldzTMSLCVkYYp+
O3K5HlIqGhA9Rj32XKYBwjiMwPBoIYAcTzbUOb9kih0Ru3jGp/7+K/FbQPZHYK98znvK
N/r81PqK0LM3KFpBi1SL+gpvIDm1sz/GjXGlAtBfMViHPcY6Vw6kjhpbuYEqPkOWty5g
jhUntrrCyKpA069COR64bLqCeIM7++3E5rZvH1dIYZ86u629xNna5Tj+TJSkev7Jnlfw
0YFoc+s=
[...]]]></artwork>
        </figure>
        <t> Again the line breaks are for readability an do not exist in a real token. 
        </t>
        <t> Service provider: 
        </t>
        <figure>
          <artwork><![CDATA[HTTP/1.1 200 OK
Date: Mon, 01 Jan 2015 14:21:17 GMT
Content-Type: image/jpeg
Content-Length: 513017

[...]]]></artwork>
        </figure>
      </section>
    </section>
    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>This document's structure is based on a template by Elwyn Davies (initial version by Pekka
        Savola).</t>
      <t>We'd like to thank Peer Sterner for his thorough reviews of the early drafts.</t>
      <t>Thomas Fleischmann</t>
    </section>
    <!-- Possibly a 'Contributors' section ... -->
    <section title="IANA Considerations" anchor="IANA">
      <!-- All drafts are required to have an IANA considerations section (see <xref target="RFC5226">Guidelines 
        for Writing an IANA Considerations Section in RFCs</xref> for a guide). If the draft does not require 
        IANA to do anything, the section contains an explicit statement that this is the case (as above). If 
        there are no requirements for IANA, the section will be removed during conversion into an RFC by the 
        RFC Editor. -->
      <t>
        This document uses the existing IANA registry for "Hash Function Textual Names" in
        <xref target="sec:supported_signing_mechanisms" />
        which was introduced in
        <xref target="RFC4572" />
        (see
        <xref target="IANA1" />
        for a list of values) .
      </t>
      <t>
        This document defines a public key protocol value in
        <xref target="sec:supported_signing_mechanisms" />
        .
        <xref target="fig:initial_pub_key_values" />
        contains the initial values.
        <figure title="IANA Public Key Algorithm Textual Name Registry" anchor="fig:initial_pub_key_values">
          <artwork><![CDATA[
Public Key Algorithm     Reference
--------------------     ---------
   "rsa"                 RFC2313]]>
          </artwork>
        </figure>
      </t>
      <t>The mime type "text/uri-map" was requested at the IANA in parallel to the submission of the
        LTA to the IETF. 
      </t>
      <t>The mime type "application/lta" will be requested at the the IANA at the end of the review
        process for the LTA in order to be able to react on changes proposed by the reviewers. 
      </t>
    </section>
    <!-- See RFC3552 -->
    <section anchor="sec:security" title="Security Considerations">
      <t>The following section lists possible attack vectors and mitigation strategies (if
        applicable).</t>
      <section title="Attack Vectors">
        <section title="Flooding of the Service Provider">
          <t>Since tokens described in this document are intentionally designed to be reused until
            they expire, they do not grant any protection against flooding of the service provider 
          </t>
          <t>Tokens with a usage limit would either require the service provider to consult the
            authentication provider for each service request or require holding a connection state
            at the service providers. 
          </t>
          <t>Service providers must implement their own flood protection mechanisms - independently
            of the LTA.</t>
        </section>
        <section title="Time Synchronization Attack" anchor="sec:time_synchronization_attack">
          <t>Depending on the expiry delay a few seconds difference in the token expiration between
            what the authentication provider specified and the expiry in the service provider are no
            problem. Whereas minutes or more would open a potential attack vector where outdated
            tokens could be used. 
          </t>
          <t>Therefore proper time synchronization of the AP and SP is crucial.</t>
          <t>Attackers could try to fake the time source of either the AP or SP. Therefore both must
            make sure to use a secure and trusted time source. 
          </t>
        </section>
        <section title="Token Hijacking">
          <t>One of the goals of the LTA is to provide anonymization of the consumer towards the
            service provider. Since the service provider does not know the sender, it can not verify
            if the token belongs to the sender or was copied from another consumer. 
          </t>
          <t>For this reason it is recommended to use LTA alone only for services that do not
            disclose personal or confidential data. If service designers plan to use LTA for such a
            service it is recommended that they use additional user authentication. 
          </t>
        </section>
        <section title="Man-in-the-Middle">
          <t>If an attacker manages to intercept the communication between the SP and the AP, the
            attacker could try to impose an authentication provider towards the unknowing consumer.
            The consumer would then either disclose its credentials to the attacker or the attacker
            would intercept and abuse the issued token.</t>
          <t>In a different scenario the attacker could impose a service provider to collect tokens
            which it could redeem at the real service provider.</t>
          <t>Consumers need to verify the identity of both, authentication provider and service
            provider in order to prevent man-in-the-middle attack. 
          </t>
        </section>
        <section title="Replay Attacks">
          <t>If attackers are able to record a token during transmission, they can try to run a
            replay attack. Tokens that are not expired can be used in a replay attack. 
          </t>
          <t>The first countermeasure is the mandatory use of TLS to prevent eavesdropping. If you
            are really concerned about replay attacks, the service provider may use the token cache
            to accept each token only once. The tradeoff is that this contradicts the design goal of
            keeping the number of requests to the authentication provider down.</t>
        </section>
        <section title="Service Permission Information Leaking">
          <t>Since tokens contain service identification URIs, an attacker could try to get tokens
            to gather information about the services a consumer is using and the associated
            permissions.</t>
          <t>Consumers are responsible for protecting their token on the local machine and making
            sure they are addressing them at the authentic service provider.</t>
          <t>Losing a token has - at least for the time the token is valid - the same effect as
            losing other credentials like user name and password.</t>
        </section>
        <section title="Addressing a Token to the Wrong Service">
          <t>
            Token based authentication without callback to the authentication provider from the
            service provider carries the risk of a malicious consumer trying to feed a token to the
            service provider that is a valid token addressed at a different service provider. See
            also
            <xref target="sec:checking_addressed_to_the_right_service_provider" />
            for more information.
          </t>
          <t>Therefore service providers must check the service identification URI in the token.</t>
        </section>
        <section title="Using Token Request URIs That Are Not Valid Anymore">
          <t>If the consumer cached a token request URI which is not used anymore by an
            authentication provider and that URI belongs to a different domain there is the chance
            of an attacker to impose the authentication provider. For this the attacker would need
            to gain control over the domain, create a matching certificate and deploy what looks
            like the token granting part of the authentication provider. 
          </t>
          <t>It is an unlikely scenario but theoretically possible. To mitigate the potential damage
            consumers SHOULD NOT cache token request URIs indefinitely. 
          </t>
        </section>
        <section title="Compromized Authentication Provider or Stolen AP Secrets">
          <t>If attackers successfully take over an authentication provider or copy the
            authentication providers secret, they can use this to create valid tokens.</t>
          <t>It is recommended to use a signing mechanism that supports the revocation of encryption
            keys so that at least after the attack was discovered, the compromised key can be
            rejected.</t>
        </section>
      </section>
      <section title="Anonymization Limitations" anchor="sec:anonymization_limitations">
        <t>A malicious service provider can collect and compare meta-data of a service request in
          order to break the anonymization. In the simplest case IP addresses already help narrowing
          down the consumer. More sophisticated methods include fingerprinting (e.g. by using
          additional HTTP headers or timing) 
        </t>
        <t>If anonymity is an important requirement then consumers can only prevent metadata
          exploitation by adding additional anonymization measures (like using the TOR network). 
        </t>
      </section>
    </section>
  </middle>
  <!-- ***** BACK MATTER ***** -->
  <back>
    <references title="Normative References">
      &RFC2119;
      &RFC2616;
      &RFC3339;
      &RFC5246;
    </references>
    <references title="Informative References">
      &RFC0958;
      &RFC2045;
      &RFC2617;
      &RFC4572;
      &RFC5234;
      <reference anchor="IANA1"
        target="https://www.iana.org/assignments/hash-function-text-names/hash-function-text-names.xhtml">
        <front>
          <title>Textual names for hash functions 
          </title>
          <author>
            <organization>IANA</organization>
          </author>
          <date year="2015" />
        </front>
      </reference>
    </references>
  </back>
</rfc>
<!-- Change Log -->
<!-- r5 - 2015-05-11 - Reformatted to XML in compliance with RFC2629 - Baer -->
<!-- * Corrected distinction between HTTP response 401 and 403 -->
<!-- * Added link to IANA registry for hash function names -->
<!-- * Changed title capitalization -->