ACE Working Group                                               L. Seitz
Internet-Draft                                                      SICS
Intended status: Standards Track                             G. Selander
Expires: August 28, December 12, 2016                                      Ericsson
                                                           E. Wahlstroem
                                                              S. Erdtman
                                                        Nexus Technology
                                                              S. Erdtman
                                                              Spotify AB
                                                           H. Tschofenig
                                                                ARM Ltd.
                                                       February 25,
                                                           June 10, 2016

  Authentication and Authorization for the Internet of Things using OAuth 2.0
                     draft-ietf-ace-oauth-authz-01 Constrained Environments (ACE)
                     draft-ietf-ace-oauth-authz-02

Abstract

   This memo specification defines how to use OAuth 2.0 as an authorization the ACE framework
   with for authentication and
   authorization in Internet of Things (IoT) deployments, deployments.  The ACE
   framework is based on a set of building blocks including OAuth 2.0
   and CoAP, thus bringing making a well-known and widely used security authorization
   solution to suitable for IoT devices.  Where possible
   vanilla OAuth 2.0 is used,  Existing specifications are used
   where possible, but where the limitations of IoT devices require it,
   profiles and extensions are provided.

Status of This Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 78 and BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at http://datatracker.ietf.org/drafts/current/.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on August 28, December 12, 2016.

Copyright Notice

   Copyright (c) 2016 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (http://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   3
   2.  Terminology . . . . . . . . . . . . . . . . . . . . . . . . .   4
   3.  Overview  . . . . . . . . . . . . . . . . . . . . . . . . . .   4   5
     3.1.  OAuth 2.0 . . . . . . . . . . . . . . . . . . . . . . . .   5   6
     3.2.  CoAP  . . . . . . . . . . . . . . . . . . . . . . . . . .   7
     3.3.  Object Security   8
   4.  Protocol Interactions . . . . . . . . . . . . . . . . . . . .   9
   5.  Framework .   8
   4.  Protocol Interactions . . . . . . . . . . . . . . . . . . . .   9
   5.  OAuth 2.0 Profiling . . . . .  13
   6.  The 'Token' Resource  . . . . . . . . . . . . . . . .  12
     5.1.  Client Information . . . .  14
     6.1.  Client-to-AS Request  . . . . . . . . . . . . . . .  12
     5.2.  CoAP Access-Token Option . . .  14
     6.2.  AS-to-Client Response . . . . . . . . . . . . .  15
     5.3.  Authorization Information Resource at the Resource Server  15
       5.3.1.  Authorization Information Request . . . . .  17
     6.3.  Error Response  . . . . .  16
       5.3.2.  Authorization Information Response . . . . . . . . .  16
         5.3.2.1.  Success Response . . . . . . .  18
     6.4.  New Request and Response Parameters . . . . . . . . .  16
         5.3.2.2.  Error Response . .  18
       6.4.1.  Grant Type  . . . . . . . . . . . . . . .  16
     5.4.  Authorization Information Format . . . . . .  19
       6.4.2.  Token Type and Algorithms . . . . . .  17
     5.5.  CBOR Data Formats . . . . . . . .  19
       6.4.3.  Profile . . . . . . . . . . . .  17
     5.6.  Token Expiration . . . . . . . . . . .  20
       6.4.4.  Confirmation  . . . . . . . . .  17
   6.  Deployment Scenarios . . . . . . . . . . .  20
     6.5.  Mapping parameters to CBOR  . . . . . . . . .  18
     6.1.  Client and Resource Server are Offline . . . . . .  22
   7.  The 'Introspect' Resource . . .  19
     6.2.  Resource Server Offline . . . . . . . . . . . . . . .  22
     7.1.  RS-to-AS Request  . .  22
     6.3.  Token Introspection with an Offline Client . . . . . . .  26
     6.4.  Always-On Connectivity . . . . . . . . . . .  23
     7.2.  AS-to-RS Response . . . . . .  30
     6.5.  Token-less Authorization . . . . . . . . . . . . . .  23
     7.3.  Error Response  . .  31
     6.6.  Securing Group Communication . . . . . . . . . . . . . .  34
   7.  Security Considerations . . . . .  24
     7.4.  Client Token  . . . . . . . . . . . . . .  35
   8.  IANA Considerations . . . . . . . .  25
     7.5.  Mapping Introspection parameters to CBOR  . . . . . . . .  26
   8.  The Access Token  . . . . .  35
     8.1.  CoAP Option Number Registration . . . . . . . . . . . . .  35
   9.  Acknowledgments . . . .  27
     8.1.  The 'Authorization Information' Resource  . . . . . . . .  27
     8.2.  Token Expiration  . . . . . . . . . . .  36
   10. References . . . . . . . . .  28
   9.  Security Considerations . . . . . . . . . . . . . . . .  36
     10.1.  Normative References . . .  28
   10. IANA Considerations . . . . . . . . . . . . . . .  36
     10.2.  Informative References . . . . . .  29
     10.1.  OAuth Introspection Response Parameter Registration  . .  29
     10.2.  OAuth Parameter Registration . . . . . . . . .  38
   Appendix A.  Design Justification . . . . .  30
     10.3.  OAuth Access Token Types . . . . . . . . . . .  40
   Appendix B.  Roles and       Responsibilites -- a Checklist . . .  41
   Appendix C.  Optimizations . .  30
     10.4.  Token Type Mappings  . . . . . . . . . . . . . . . . .  44
   Appendix D.  CoAP and CBOR profiles for OAuth 2.0 .  30
       10.4.1.  Registration Template  . . . . . . . . . .  45
     D.1.  Profile for Token resource . . . . .  30
       10.4.2.  Initial Registry Contents  . . . . . . . . . . . .  45
       D.1.1. .  31
     10.5.  JSON Web Token Request Claims  . . . . . . . . . . . . . . . . .  31
     10.6.  ACE Profile Registry . . . . .  46
       D.1.2.  Token Response . . . . . . . . . . . . .  31
       10.6.1.  Registration Template  . . . . . .  47

     D.2.  CoAP Profile for . . . . . . . . .  31
     10.7.  OAuth Introspection Parameter Mappings Registry  . . . . . . . . . .  48
       D.2.1.  Introspection Request .  32
       10.7.1.  Registration Template  . . . . . . . . . . . . . . .  48
       D.2.2.  32
       10.7.2.  Initial Registry Contents  . . . . . . . . . . . . .  32
     10.8.  Introspection Response Resource CBOR Mappings Registry  . . . . .  34
       10.8.1.  Registration Template  . . . . . . . . . .  49
   Appendix E.  Document Updates . . . . .  35
       10.8.2.  Initial Registry Contents  . . . . . . . . . . . . .  51
     E.1.  Version -00 to -01  35
     10.9.  CoAP Option Number Registration  . . . . . . . . . . . .  37
   11. Acknowledgments . . . . . . .  51
   Authors' Addresses . . . . . . . . . . . . . . . .  37
   12. References  . . . . . . .  52

1.  Introduction

   Authorization is the process for granting approval to an entity to
   access a resource [RFC4949].  Managing authorization information for
   a large number of devices and users is often a complex task where
   dedicated servers are used.

   Managing authorization of users, services . . . . . . . . . . . . . . . . . .  38
     12.1.  Normative References . . . . . . . . . . . . . . . . . .  38
     12.2.  Informative References . . . . . . . . . . . . . . . . .  38
   Appendix A.  Design Justification . . . . . . . . . . . . . . . .  40
   Appendix B.  Roles and their devices with the
   help of dedicated authorization servers (AS) Responsibilites  . . . . . . . . . . . . .  42
   Appendix C.  Deployment Examples  . . . . . . . . . . . . . . . .  44
     C.1.  Local Token Validation  . . . . . . . . . . . . . . . . .  44
     C.2.  Introspection Aided Token Validation  . . . . . . . . . .  48
   Appendix D.  Document Updates . . . . . . . . . . . . . . . . . .  51
     D.1.  Version -01 to -02  . . . . . . . . . . . . . . . . . . .  52
     D.2.  Version -00 to -01  . . . . . . . . . . . . . . . . . . .  52
   Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . .  53

1.  Introduction

   Authorization is a common task, found
   in enterprise networks as well as on the Web.  In its simplest form the process for granting approval to an entity to
   access a resource [RFC4949].  The authorization task itself can best
   be described as granting access to a requesting client, for a
   resource hosted on a device, the resource server (RS).  This exchange
   is mediated by one or multiple authorization servers. servers (AS).  Managing
   authorization for a large number of devices and users is a complex
   task.

   We envision that end consumers and enterprises will want to manage
   access-control and authorization for their access to
   resources on, or produced by, Internet of Things (IoT) devices in the
   same style as they do today with data, services and this applications on
   the Web or with their mobile devices.  This desire will increase with
   the number of exposed services and capabilities provided by
   applications hosted on the IoT devices.  The

   While prior work on authorization solutions for the Web and for the
   mobile environment also applies to the IoT devices may be constrained environment many IoT
   devices are constrained, for example in
   various ways including processing, terms of processing
   capabilities, available memory, code-size, energy, etc.,
   as defined etc.  For web applications on
   constrained nodes this specification makes use of CoAP [RFC7252].

   A detailed treatment of constraints can be found in [RFC7228], and
   the different IoT deployments present a continuous range of device
   and network capabilities.  Taking energy consumption as an example:

   At one end there are energy-harvesting or battery powered devices
   which have a tight power budget, on the other end there are devices connected to a continuous power supply which
   are not constrained in terms of power, mains-
   powered devices, and all levels in between.
   Thus

   Hence, IoT devices are may be very different in terms of available
   processing and message exchange capabilities. capabilities and there is a need to
   support many different authorization use cases [RFC7744].

   This memo specification describes how to a framework for authentication and
   authorization in constrained environments (ACE) built on re-use of
   OAuth 2.0 [RFC6749] to extend [RFC6749], thereby extending authorization to Internet of
   Things devices with different kinds of
   constraints.  At devices.  This specification contains the time of writing, necessary building
   blocks for adjusting OAuth 2.0 is already used with
   certain types of to IoT devices and this document will provide
   implementers additional guidance for using it environments.

   More detailed, interoperable specifications can be found in profiles.
   Implementations may claim conformance with a secure and
   privacy-friendly way.  Where possible specific profile,
   whereby implementations utilizing the basic OAuth 2.0 mechanisms
   are used; in some circumstances same profile interoperate while
   implementations of different profiles are defined, for example not expected to
   support smaller the over-the-wire message size be
   interoperable.  Some devices, such as mobile phones and smaller code size. tablets, may
   implement multiple profiles and will therefore be able to interact
   with a wider range of low end devices.

2.  Terminology

   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 [RFC2119].

   Certain security-related terms such as "authentication",
   "authorization", "confidentiality", "(data) integrity", "message
   authentication code", and "verify" are taken from [RFC4949].

   Since we describe exchanges as RESTful protocol interactions HTTP
   [RFC7231] offers useful terminology.

   Terminology for entities in the architecture is defined in OAuth 2.0
   [RFC6749] and [I-D.ietf-ace-actors], such as client (C), resource
   server (RS), and authorization server (AS).  OAuth 2.0 uses

   Note that the term "endpoint" is used here following its OAuth
   definition, which is to denote HTTP resources such as /token and /authorize
   /introspect at the AS, but we will use AS and /authz-info at the term "resource" RS.  The CoAP [RFC7252]
   definition, which is "An entity participating in this memo to avoid
   confusion with the CoAP [RFC7252] term "endpoint". protocol"
   is not used in this memo.

   Since this draft specification focuses on the problem of access control to
   resources, we simplify the actors by assuming that the client
   authorization server (CAS) functionality is not stand-alone but
   subsumed by either the authorization server or the client (see
   section 2.2 in [I-D.ietf-ace-actors]).

3.  Overview

   This specification describes a the ACE framework for authorization in
   the Internet of Things consisting of a set of building blocks.

   The basic block is the OAuth 2.0 [RFC6749] framework, which enjoys
   widespread deployment.  Many IoT devices can support OAuth 2.0
   without any additional extensions, but for certain constrained
   settings additional profiling is needed.

   Another building block is the lightweight web transfer protocol CoAP
   [RFC7252] for those communication environments where HTTP is not
   appropriate.  CoAP typically runs on top of UDP which further reduces
   overhead and message exchanges.  Transport layer security can be
   provided either by DTLS 1.2 [RFC6347] or TLS 1.2 [RFC5246].

   A third  While this specification defines
   extensions for the use of OAuth over CoAP, we do envision further
   underlying protocols to be supported in the future, such as MQTT or
   QUIC.

   A third building block is CBOR [RFC7049] for encodings where JSON
   [RFC7159] is not sufficiently compact.  CBOR is a binary encoding
   designed for extremely small code size and fairly small message size.
   OAuth 2.0 allows access tokens to use different encodings size, which may be used for
   encoding of self contained tokens, and this
   document defines such an alternative encoding.  The COSE message
   format [I-D.ietf-cose-msg] is also based on CBOR. for encoding CoAP POST
   parameters and CoAP responses.

   A fourth building block is the compact CBOR-based secure message
   format COSE [I-D.ietf-cose-msg], which enables application layer security, which is used
   where
   security as an alternative or complement to transport layer security
   (DTLS [RFC6347] or TLS [RFC5246]).  COSE is insufficient.  At the time of
   writing the preferred approach for securing CoAP at the application
   layer used to secure self
   contained tokens such as proof-of-possession (PoP) tokens
   [I-D.ietf-oauth-pop-architecture], which is via an extension to the use of COSE [I-D.ietf-cose-msg], OAuth
   access tokens, and "client tokens" which adds object are defined in this
   framework (see Section 7.4).  The default access token format is
   defined in CBOR web token (CWT) [I-D.ietf-ace-cbor-web-token].
   Application layer security to CBOR-encoded data.  More details about applying COSE to for CoAP using COSE can be found in provided with
   OSCOAP [I-D.selander-ace-object-security].

   With the building blocks listed above, solutions satisfying various
   IoT device and network constraints are possible.  A list of
   constraints is described in detail in RFC 7228 [RFC7228] and a
   description of how the building blocks mentioned above relate to the
   various constraints can be found in Appendix A.

   Luckily, not every IoT device suffers from all constraints.  The
   described ACE
   framework nevertheless takes all these aspects into account and
   allows several different deployment variants to co-exist rather than
   mandating a one-size-fits-all solution.  We believe this is important
   to cover the wide range of possible interworking use cases and the
   different requirements from a security point of view.  Once IoT
   deployments mature, popular deployment variants will be documented in
   form of ACE profiles.

   In the subsections below we provide further details about the
   different building blocks.

3.1.  OAuth 2.0

   The OAuth 2.0 authorization framework enables a client to obtain
   limited access to a resource with the permission of a resource owner.
   Authorization related information information, or references to it, is passed between the
   nodes using access tokens.  These access tokens are issued to clients
   by an authorization server with the approval of the resource owner.
   The client uses the access token to access the protected resources
   hosted by the resource server.

   A number of OAuth 2.0 terms are used within this memo:

   Access Tokens:

      Access tokens are credentials used specification:

   The token and introspect Endpoints:

      The AS hosts the /token endpoint that allows a client to request
      access protected resources.
      An access token is tokens.  The client makes a data structure representing authorization
      permissions issued POST request to the client.  Access tokens are generated by /token
      endpoint on the authorization server AS and consumed by receives the resource server.  The access token in the response
      (if the request was successful).

      The token introspection endpoint, /introspect, is opaque to used by the client.

      Access tokens can have different formats, RS
      when requesting additional information regarding a received access
      token.  The RS makes a POST request to /introspect on the AS and
      receives information about the access token contain in the
      response.  (See "Introspection" below.)

   Access Tokens:

      Access tokens are credentials needed to access protected
      resources.  An access token is a data structure representing
      authorization permissions issued by the AS to the client.  Access
      tokens are generated by the authorization server and consumed by
      the resource server.  The access token content is opaque to the
      client.

      Access tokens can have different formats, and various methods of
      utilization (e.g., cryptographic properties) based on the security
      requirements of the given deployment.

   Proof of Possession Tokens:

      An access token may be bound to a cryptographic key, which is then
      used by an RS to authenticate requests from a client.  Such tokens
      are called proof-of-possession tokens (or PoP tokens)
      [I-D.ietf-oauth-pop-architecture].

      The proof-of-possession (PoP) security concept assumes that the AS
      acts as a trusted third party that binds keys to access tokens.
      These so called PoP keys are then used by the client to
      demonstrate the possession of the secret to the RS when accessing
      the resource.  The RS, when receiving an access token, needs to
      verify that the key used by the client matches the one included in
      the access token.  When this memo specification uses the term "access
      token" it is assumed to be a PoP token unless specifically stated
      otherwise.

      The key bound to the access token (aka PoP key) may be based on
      symmetric as well as on asymmetric cryptography.  The appropriate
      choice of security depends on the constraints of the IoT devices
      as well as on the security requirements of the use case.

      Symmetric PoP key:  The AS generates a random symmetric PoP key,
         encrypts it for the RS and includes it inside an access token.
         The PoP key is also encrypted for the client and sent together
         with the access token to the client. client.>

      Asymmetric PoP key:  An asymmetric key pair is generated on the
         client and the public key is sent to the AS (if it does not
         already have knowledge of the client's public key).
         Information about the public key, which is the PoP key in this
         case, is then included inside the access token and sent back to
         the requesting client.  The RS can identify the client's public
         key from the information in the token, which allows the client
         to use the corresponding private key for the proof of
         possession.

      The access token is protected against modifications using a MAC or
      a digital signature of signature, which is added by the AS.  The choice of PoP
      key does not necessarily imply a specific credential type for the
      integrity protection of the token.  More information about PoP
      tokens can be found in [I-D.ietf-oauth-pop-architecture].

   Scopes and Permissions:

      In OAuth 2.0, the client specifies the type of permissions it is
      seeking to obtain (via the scope parameter) in the access request.
      In turn, the AS may use the "scope" scope response parameter to inform the
      client of the scope of the access token issued.  As the client
      could be a constrained device as well, this memo specification uses
      CBOR encoded messages for CoAP, defined in Appendix D Section 5, to request
      scopes and to be informed what scopes the access token was
      actually authorized for by the AS.

      The values of the scope parameter are expressed as a list of
      space- delimited, case-sensitive strings, with a semantic that is
      well-known to the AS and the RS.  More details about the concept
      of scopes is found under Section 3.3 in [RFC6749].

   Claims:

      The information

      Information carried in the access token token, called claims, is in the
      form of type-
      value pairs is called claims. type-value pairs.  An access token may may, for example example,
      include a claim about identifying the AS that issued the token (the (via the
      "iss" claim) and what audience the access token is intended for (the
      (via the "aud" claim).  The audience of an access token can be a
      specific resource or one or many resource servers.  The resource
      owner policies influence the what claims are put into the access token
      by the authorization server.

      While the structure and encoding of the access token varies
      throughout deployments, a standardized format has been defined
      with the JSON Web Token (JWT) [RFC7519] where claims are encoded
      as a JSON object.  In [I-D.wahlstroem-ace-cbor-web-token] [I-D.ietf-ace-cbor-web-token] an equivalent
      format using CBOR encoding (CWT) has been defined.

   Introspection:

      Introspection is a method for a resource server to query the
      authorization server for the active state and content of a
      received access token.  This is particularly useful in those cases
      where the authorization decisions are very dynamic and/or where
      the received access token itself is a reference rather than a
      self-contained token.  More information about introspection in
      OAuth 2.0 can be found in [I-D.ietf-oauth-introspection]. [RFC7662].

3.2.  CoAP

   CoAP is an application layer protocol similar to HTTP, but
   specifically designed for constrained environments.  CoAP typically
   uses datagram-oriented transport, such as UDP, where reordering and
   loss of packets can occur.  A security solution need to take the
   latter aspects into account.

   While HTTP uses headers and query-strings to convey additional
   information about a request, CoAP encodes such information in so-
   called 'options'.

   CoAP supports application-layer fragmentation of the CoAP payloads
   through blockwise transfers [I-D.ietf-core-block].  However, this
   method block-
   wise transfer does not allow increase the fragmentation size limits of large CoAP options,
   therefore data encoded in options has to be kept small.

3.3.  Object Security

   Transport layer security is not always sufficient and application
   layer security has to for CoAP can be provided.  COSE [I-D.ietf-cose-msg] provided by DTLS 1.2
   [RFC6347] or TLS 1.2 [RFC5246].  CoAP defines a message format for cryptographic protection number of data using CBOR
   encoding.  There are two main approaches for application proxy
   operations which requires transport layer
   security:

   Object Security of CoAP (OSCOAP)

      OSCOAP [I-D.selander-ace-object-security] is a method security to be terminated
   at the proxy.  One approach for protecting CoAP request/response message exchanges, including CoAP
      payloads, communication end-to-
   end through proxies, and also to support security for CoAP header fields as well over
   different transport in a uniform way, is to provide security on
   application layer using an object-based security mechanism such as CoAP options.
   CBOR Encoded Message Syntax [I-D.ietf-cose-msg].

   One application of COSE is OSCOAP [I-D.selander-ace-object-security],
   which provides end-to-end confidentiality, integrity and replay
   protection, and a secure binding between CoAP request and response
   messages.

      A CoAP message protected with OSCOAP contains the CoAP option
      "Object-Security" which signals that  In OSCOAP, the CoAP message carries a
      COSE message ([I-D.ietf-cose-msg]).  OSCOAP defines a profile of
      COSE which includes replay protection.

   Object Security of Content (OSCON)

      For the case of wrapping of application layer payload data
      ("content") only, such as resource representations or claims of
      access tokens, the same COSE profile can be applied to obtain end-
      to-end confidentiality, integrity and replay protection.
      [I-D.selander-ace-object-security] defines this functionality as
      Object Security of Content (OSCON).

      In this case, the message is not bound to the underlying
      application layer protocol and can therefore be used with HTTP,
      CoAP, Bluetooth Smart, etc.  While OSCOAP integrity protects
      specific CoAP message meta-data like request/response code, and
      binds a response to a specific request, OSCON protects only
      payload/content, therefore those security features are lost.  The
      advantages messages are that an OSCON message can be passed across
      different protocols, from request to response, wrapped in COSE objects
   and used to secure
      group communications. sent using CoAP.

4.  Protocol Interactions

   This

   The ACE framework is based on the same OAuth 2.0 protocol interactions as OAuth
   2.0:
   using the /token and /introspect endpoints.  A client obtains an
   access token from an AS using the /token endpoint and subsequently
   presents the access token to an a RS to gain access to a protected
   resource.  The RS, after receiving an access token, may present it to
   the AS via the /introspect endpoint to get information about the
   access token.  In other deployments the RS may process the access
   token locally without the need to contact an AS.  These interactions
   are shown in Figure 1.  An overview of various OAuth concepts is
   provided in Section 3.1.

   The consent of the resource owner, for giving a client access to a
   protected resource, can be pre-configured authorization policies or
   dynamically at the time when the request is sent.  The resource owner
   and the requesting party (= (i.e. client owner) are not shown in
   Figure 1.

   For

   This framework supports a wide variety of communication security
   mechanisms between the description in this document we ACE entities, such as client, AS, and RS.  We
   assume that the client has been registered (also called enrolled or
   onboarded) to an AS.  Registration means AS using a mechanism defined outside the scope of
   this document.  In practice, various techniques for onboarding have
   been used, such as factory-based provisioning or the use of
   commissioning tools.  Regardless of the onboarding technique, this
   registration procedure implies that the two client and the AS share
   credentials, configuration parameters and that some form of
   authorization has taken place. configuration parameters.  These credentials are
   used to mutually authenticate each other and to protect
   the token request by messages
   exchanged between the client and the transport of access tokens
   and client information from AS to the client. AS.

   It is also assumed that the RS has been registered with the AS,
   potentially in a similar way as the client has been registered with
   the AS.  Established keying material between the AS and the RS allows
   the AS to apply cryptographic protection to the access token to
   ensure that
   the its content cannot be modified, and if needed, that the
   content is confidentiality protected.

   The keying material necessary for establishing communication security
   between C and RS is dynamically established as part of the protocol
   described in this document.

   At the start of the protocol there is an optional discovery step
   where the client discovers the resource server and the resources this
   server hosts.  In this step the client might also determine what
   permissions are needed to access the protected resource.  The exact
   procedure depends
   detailed procedures for this discovery process may be defined in an
   ACE profile and depend on the protocols being used and the specific
   deployment environment.

   In Bluetooth Smart, Low Energy, for example, advertisements are broadcasted
   by a peripheral, including information about the supported primary services.
   In CoAP, as a second example, a client can makes a request to
   "/.well-known/core" to obtain information about available resources,
   which are returned in a standardized format as described in
   [RFC6690].

   +--------+                               +---------------+
   |        |---(A)-- Token Request ------------->| ------->|               |
   |        |                               | Authorization |
   |        |<--(B)-- Access Token ---------------| ---------|    Server     |
   |        |       + Client Information    |               |
   |        |                               +---------------+
   |        |                                      ^ |
   |        |            Introspection Request & Response  (D)| |(E) |
   | Client |                                      | |
   |        |             Response + Client Token  | |(E)
   |        |                                      | v
   |        |                               +--------------+
   |        |---(C)-- Token + Request ----------->| ----->|              |
   |        |                               |   Resource   |
   |        |<--(F)-- Protected Resource ---------| ---|    Server    |
   |        |                               |              |
   +--------+                               +--------------+

                      Figure 1: Overview of the basic protocol flow Basic Protocol Flow.

   Requesting an Access Token (A):

      The client makes an access token request to the /token endpoint at
      the AS.  This memo framework assumes the use of PoP tokens (see
      Section 3.1 for a short description) wherein the AS binds a key to
      an access token.  The client may include permissions it seeks to
      obtain, and information about the type of credentials it wants to use (i.e., symmetric
      (e.g., symmetric/asymmetric cryptography or
      asymmetric cryptography). a reference to a
      specific credential).

   Access Token Response (B):

      If the AS successfully processes the request from the client, it
      returns an access token.  It also includes returns various parameters,
      which we call
      referred as "Client Information".  In addition to the response
      parameters defined by OAuth 2.0 and the PoP token extension, we
      consider new kinds of
      further response parameters in Section 5, including parameters, such as information on which security protocol profile
      the client should use with the resource server(s) that it has just been authorized to access.
      Communication security between client and RS may be based on pre-
      provisioned keys/security contexts or dynamically established.
      The RS authenticates the client via the PoP token; and the client
      authenticates the RS via the client server(s).  More
      information as described about these parameters can be found in in Section 5.1. 6.4.

   Resource Request (C):

      The client interacts with the RS to request access to the
      protected resource and provides the access token.  The protocol to
      use between the client and the RS is not restricted to CoAP; CoAP.
      HTTP, HTTP/2, QUIC, MQTT, Bluetooth Smart Low Energy, etc., are also possible
      viable candidates.

      Depending on the device limitations and the selected protocol this
      exchange may be split up into two phases: parts:

         (1) the client sends the access token to a newly defined
         authorization endpoint at containing, or
         referencing, the RS (see Section 5.3) , which
         conveys authorization information to the RS RS, that may
         be used by
         the client for subsequent resource requests, requests by the client, and
         (2) the client makes the resource access request, using the
         communication security protocol and other client information
         obtained from the AS.

      The Client and the RS mutually authenticate using the security
      protocol specified in the profile (see step B) and the keys
      obtained in the access token or the client information or the
      client token.  The RS verifies that the token is integrity
      protected by the AS and compares the claims contained in the
      access token with the resource request.  If the RS is online,
      validation can be handed over to the AS using token introspection
      (see messages D and E) over HTTP or CoAP, in which case the
      different parts of step C may be interleaved with introspection.

   Token Introspection Request (D):

      A resource server may be configured to use token introspection to
      interact with introspect the AS access token
      by including it in a request to obtain the most recent claims, such as
      scope, audience, validity etc.  associated with a specific access
      token. /introspect endpoint at that
      AS.  Token introspection over CoAP is defined in
      [I-D.wahlstroem-ace-oauth-introspection] Section 7 and for
      HTTP in
      [I-D.ietf-oauth-introspection]. [RFC7662].

      Note that token introspection is an optional step and can be
      omitted if the token is self-contained and the resource server is
      prepared to perform the token validation on its own.

   Token Introspection Response (E):

      The AS validates the token and returns the claims most recent parameters,
      such as scope, audience, validity etc. associated with it back to
      the RS.  The RS then uses the received claims parameters to process the
      request to either accept or to deny it.  The AS can additionally
      return information that the RS needs to pass on to the client in
      the form of a client token.  The latter is used to establish keys
      for mutual authentication between client and RS, when the client
      has no direct connectivity to the AS.

   Protected Resource (F):

      If the request from the client is authorized, the RS fulfills the
      request and returns a response with the appropriate response code.
      The RS uses the dynamically established keys to protect the
      response, according to used communication security protocol.

5.  OAuth 2.0 Profiling

   This section describes profiles  Framework

   The following sections detail the profiling and extensions of OAuth
   2.0 adjusting it to for constrained environments for use cases where this is necessary.
   Profiling for JSON Web Tokens (JWT) is provided in
   [I-D.wahlstroem-ace-cbor-web-token].

5.1.  Client Information

   OAuth 2.0 using bearer tokens, as described in [RFC6749] and in
   [RFC6750], requires TLS for all communication interactions between
   client, authorization server, and resource server.  This is possible
   in which constitutes the scope where OAuth 2.0 was originally developed: web and mobile
   applications.  In these environments resources like computational
   power and bandwidth are not scarce and operating systems as well as
   browser platforms are pre-provisioned with trust anchors ACE framework.

   Credential Provisioning

      For IoT we cannot generally assume that enable
   clients to authenticate servers based on the Web PKI.  In a more
   heterogeneous IoT environment a wider range client and RS are part
      of use cases needs a common key infrastructure, so the AS provisions credentials
      or associated information to allow mutual authentication.  These
      credentials need to be
   supported.  Therefore, this document suggests extensions provided to OAuth 2.0
   that enables the AS to inform parties before or during
      the client on how to communicate
   securely with a RS authentication protocol is executed, and may be re-used for
      subsequent token requests.

   Proof-of-Possession

      The ACE framework by default implements proof-of-possession for
      access tokens, i.e. that allows the client to indicate
   communication security preferences authenticated token holder is bound
      to the AS.

   In the OAuth memo defining token.  The binding is provided by the "cnf" claim
      indicating what key distribution is used for proof-of-
   possession (PoP) tokens [I-D.ietf-oauth-pop-key-distribution], the
   authors suggest mutual authentication.  If clients
      need to use Uri-query parameters in order update a token, e.g. to submit get additional rights, they can
      request that the
   parameters of AS binds the client's new access token request. to the same
      credential as the previous token.

   ACE Profile Negotiation

      The client or RS may be limited in the encodings or protocols it
      supports.  To avoid large headers if support a variety of different deployment settings,
      specific interactions between client and RS are defined in an ACE
      profile.  The ACE framework supports the negotiation of different
      ACE profiles between client uses CoAP and AS using the "profile" parameter
      in the token request and token response.

   OAuth 2.0 requires the use of TLS both to communicate protect the communication
   between AS and client when requesting an access token and between AS
   and RS for introspection.  In constrained settings TLS is not always
   feasible, or desirable.  Nevertheless it is REQUIRED that the data
   exchanged with the AS, AS is encrypted and integrity protected.  It is
   furthermore REQUIRED that the AS and the endpoint communicating with
   it (client or RS) perform mutual authentication.

   Profiles are expected to specify the details of how this memo specifies is done,
   depending e.g. on the communication protocol and the credentials used
   by the following alternative for submitting client request parameters or the RS.

   In OAuth 2.0 the communication with the Token and the Introspection
   resources at the AS is assumed to be via HTTP and may use Uri-query
   parameters.  This framework RECOMMENDS to use CoAP instead and
   RECOMMENDS the use of the AS: following alternative instead of Uri-query
   parameters: The client sender (client or RS) encodes the parameters of it's its
   request as a CBOR map and submits that map as the payload of the client POST
   request.  The Content-format MUST be application/cbor "application/cbor" in that case.

   The OAuth memo further specifies that the 2.0 AS SHALL use uses a JSON structure in the payload of the response its
   responses both to encode the response
   parameters.  These parameters include the access token, destined for
   the RS and additional information for the client, such as e.g. the
   PoP key.  We call this information "client information".  If the client is using CoAP to communicate with the AS and RS.  This framework RECOMMENDS the AS SHOULD use
   CBOR instead
   of JSON for encoding it's response. CBOR [RFC7049] instead.  The client requesting device can explicitly
   request this encoding by using setting the CoAP Accept option.

   If the channel between client and AS is not secure, the whole
   messages from client to AS and vice-versa MUST be wrapped in JWEs
   [RFC7516] or COSE_Encrypted structures [I-D.ietf-cose-msg].

   The client may be a constrained device and could therefore be limited option in the communication security protocols it supports.  It can
   therefore signal
   request to "application/cbor".

6.  The 'Token' Resource

   In plain OAuth 2.0 the AS which protocols it can support provides the /token resource for
   securing their mutual communication. submitting
   access token requests.  This is done by using framework extends the "csp"
   parameter defined below in functionality of
   the Token Request message sent to /token resource, giving the AS.

   Note that The OAuth key distribution specification
   [I-D.ietf-oauth-pop-key-distribution] describes in section 6 how AS the possibility to help client can request specific types of keys (symmetric vs.  asymmetric) and proof-of-possession algorithms in
   RS to establish shared keys or to exchange their public keys.

   Communication between the PoP token request.

   The client and the RS might not have any prior knowledge about each
   other, therefore token resource at the AS needs to help them to establish a security
   context or at least a key.  The
   MUST be integrity protected and encrypted.  Furthermore AS does and client
   MUST perform mutual authentication.  Profiles of this by indicating framework are
   expected to specify how authentication and communication security protocol ("csp") and additional key parameters
   in the client information.

   The "csp" parameter specifies how client and RS communication is
   going to be secured based on returned keys.  Currently defined values
   are "TLS", "DTLS", "ObjectSecurity" with
   implemented.

   The figures of this section uses CBOR diagnostic notation without the encodings specified in
   Figure 2.  Depending on
   integer abbreviations for the value different additional parameters
   become mandatory.

          /-----------+--------------+-----------------------\
          | Value     | Major Type   | Key                   |
          |-----------+--------------+-----------------------|
          | 0         | 0            | TLS                   |
          | 1         | 0            | DTLS                  |
          | 2         | 0            | ObjectSecurity        |
          \-----------+--------------+-----------------------/

       Figure 2: Table of 'csp' parameter value encodings or their values for Client
                               Information.

   CoAP specifies three security modes of DTLS: PreSharedKey,
   RawPublicKey and Certificate.  The same modes may be used with TLS.
   The client is to infer better
   readability.

6.1.  Client-to-AS Request

   When requesting an access token from the type of key provided, which (D)TLS
   mode AS, the RS supports as follows.

   If PreSharedKey mode is used, client MAY include
   the AS MUST provide following parameters in the client with request in addition to the
   pre-shared key ones
   required or optional according to be used with the RS. OAuth 2.0 specification
   [RFC6749]:

   token_type
      OPTIONAL.  See Section 6.4 for more details.

   alg
      OPTIONAL.  See Section 6.4 for more details.

   profile
      OPTIONAL.  This key MUST be indicates the same as profile that the PoP key (i.e. a symmetric key as in section 4 of
   [I-D.ietf-oauth-pop-key-distribution]).

   The client MUST would like
      to use with the PoP key as DTLS pre-shared key.  The client
   MUST furthermore use RS.  See Section 6.4 for more details on the "kid" parameter provided as part
      formatting of this parameter.  If the JWK/
   COSE_Key as the psk_identity in RS cannot support the DTLS handshake [RFC4279].

   If RawPublicKey mode is used,
      requested profile, the AS MUST provide the client reply with the
   RS's raw an error message.

   cnf
      OPTIONAL.  This field contains information about a public key using the "rpk" parameter defined in the
   following.  This parameter MUST contain a JWK or a COSE_Key.  The
      client MUST provide a raw public key would like to bind to the AS, and the AS MUST use
   this key as PoP key in the access token.  The token MUST thus use asymmetric
   keys for the proof-of-possession.

   In order to get  If the client
      requests an asymmetric proof-of-possession algorithm, but does not
      provide a RS configured to use this
   mode together with PoP tokens MUST require client authentication in public key, the DTLS handshake.  The client AS MUST use respond with an error message.
      See Section 6.4 for more details on the raw public key bound to formatting of the PoP token for client authentication 'cnf'
      parameter.

   These new parameters are optional in DTLS.

   TLS or DTLS with certificates MAY make use the case where the AS has prior
   knowledge of pre-established trust
   anchors or MAY be configured more tightly with additional client
   information parameters, such as x5c, x5t, or x5t#S256.  An overview the capabilities of the client, otherwise these
   parameters is given below.

   For when communication security is based on certificates this
   attribute can be used to define the server certificate or CA
   certificate.  Semantics are required.  This prior knowledge may, for this attribute is defined by [RFC7517] or
   COSE_Key [I-D.ietf-cose-msg].

   For when communication security is based on certificates this
   attribute can example, be used to define the specific server certificate to
   expect or the CA certificate.  Semantics for this attribute is
   defined
   set by JWK/COSE_Key.

   To the use object security (such as OSCOAP and OSCON) requires security
   context to be established, which can be provisioned with PoP token
   and of a dynamic client information, or derived from that information.  Object
   security specifications designed to be used with this registration protocol MUST
   specify the parameters that an AS has to provide to the client in
   order to set up the necessary security context. exchange
   [RFC7591].

   The RS may support following examples illustrate different ways types of receiving the requests for
   proof-of-possession tokens.

   Figure 2 shows a request for a token with a symmetric proof-of-
   possession key.

   Header: POST (Code=0.02)
   Uri-Host: "server.example.com"
   Uri-Path: "token"
   Content-Type: "application/cbor"
   Payload:
   {
     "grant_type" : "client_credentials",
     "aud" : "tempSensor4711",
     "client_id" : "myclient",
     "client_secret" : b64'FWRUVGZUZmZFRkWSRlVGhA',
     "token_type" : "pop",
     "alg" : "HS256",
     "profile" : "coap_dtls"
   }

    Figure 2: Example request for an access token from
   the client (see Section 5.3 and Appendix C).  The AS MAY signal the
   required method bound to a symmetric
                                   key.

   Figure 3 shows a request for a token with an asymmetric proof-of-
   possession key.

   Header: POST (Code=0.02)
   Uri-Host: "server.example.com"
   Uri-Path: "token"
   Content-Type: "application/cbor"
   Payload:
   {
     "grant_type" : "token",
     "aud" : "lockOfDoor0815",
     "client_id" : "myclient",
     "token_type" : "pop",
     "alg" : "ES256",
     "profile" : "coap_oscoap"
     "cnf" : {
       "COSE_Key" : {
         "kty" : "EC",
         "kid" : h'11',
         "crv" : "P-256",
         "x" : b64'usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8',
         "y" : b64'IBOL+C3BttVivg+lSreASjpkttcsz+1rb7btKLv8EX4'
       }
     }
   }

   Figure 3: Example request for an access token transfer in bound to an asymmetric
                                   key.

   Figure 4 shows a request for a token where a previously communicated
   proof-of-possession key is only referenced.

   Header: POST (Code=0.02)
   Uri-Host: "server.example.com"
   Uri-Path: "token"
   Content-Type: "application/cbor"
   Payload:
   {
     "grant_type" : "client_credentials",
     "aud" : "valve424",
     "scope" : "read",
     "client_id" : "myclient",
     "token_type" : "pop",
     "alg" : "ES256",
     "profile" : "coap_oscoap"
     "cnf" : {
       "kid" : b64'6kg0dXJM13U'
     }
   }

       Figure 4: Example request for an access token bound to a key
                                reference.

6.2.  AS-to-Client Response

   If the client information access token request has been successfully verified by using the "tktr" (token transport) parameter using AS
   and the values
   defined in table Figure 3.  If no "tktn" parameter client is present, authorized to obtain a PoP token for the indicated
   audience and scopes (if any), the AS issues an access token.  If
   client MUST use authentication failed or is invalid, the default Authorization Information resource authorization server
   returns an error response as
   specified described in Section 5.3.

          /-----------+--------------+-------------------------\
          | Value     | Major Type   | Key                     |
          |-----------+--------------+-------------------------|
          | 0         | 0            | POST 6.3.

   The following parameters may also be part of a successful response in
   addition to /authz-info     |
          | 1         | 0            | RFC 4680                |
          | 2         | 0            | CoAP option "Ref-Token" |
          \-----------+--------------+-------------------------/

      Figure 3: Table those defined in section 5.1 of 'tktn' parameter value encodings for Client
                               Information.

   Table Figure 4 summarizes [RFC6749]:

   profile
      REQUIRED.  This indicates the additional parameters defined here for
   use by profile that the client or the AS in MUST use
      towards the PoP token request protocol.

      /-----------+--------------+----------------------------------\
      | Parameter | Used by      | Description                      |
      |-----------+--------------+----------------------------------|
      | csp       | client or AS | Communication security protocol  |
      | rpk       | AS           | RS's raw public key              |
      | x5c       | AS           | RS's X.509 certificate chain     |
      | x5t       | AS           | RS's SHA-1 cert thumb print      |
      | x5t#S256  | AS           | RS's SHA-256 cert thumb print    |
      | tktn      | AS           | Mode of token transfer C -> RS   |
      \-----------+--------------+----------------------------------/

       Figure 4: Table of additional parameters defined RS.  See Section 6.4 for the PoP
                                 protocol.

5.2.  CoAP Access-Token Option

   OAuth 2.0 access tokens are usually transferred as authorization
   header.  CoAP has no authorization header equivalence. formatting of this
      parameter.

   cnf
      REQUIRED.  This document
   therefor register field contains information about the option Access-Token.  The Access-Token option
   is an alternative proof-of
      possession key for transferring this access token.  See Section 6.4 for the
      formatting of this parameter.

   Note that the access token when it is
   smaller then 255 bytes.  If can also contains a 'cnf' claim, however,
   these two values are consumed by different parties.  The access token
   is larger created by the 255 bytes lager
   authorization information resources MUST at AS and processed by the RS be user when CoAP.

5.3.  Authorization Information Resource at (and opaque to the Resource Server

   A consequence of allowing
   client) whereas the use of CoAP as web transfer protocol Client Information is
   that we cannot rely on HTTP specific mechanisms, such as transferring
   information elements in HTTP headers since those are not necessarily
   gracefully mapped to CoAP.  In case created by the access token is larger than
   255 bytes it should not be sent as a CoAP option.

   For conveying authorization information to AS and
   processed by the RS a new resource client; it is
   introduced to which the PoP tokens can be sent never forwarded to convey
   authorization information before the first resource request is made
   by the client.  This specification calls this resource "/authz-info";
   the URI may, however, vary in deployments.
   server.

   The RS needs to store the PoP following examples illustrate different types of responses for
   proof-of-possession tokens.

   Figure 5 shows a response containing a token and a 'cnf' parameter
   with a symmetric proof-of-possession key.

   Header: Created (Code=2.01)
   Content-Type: "application/cbor"
   Payload:
   {
     "access_token" : b64'SlAV32hkKG ...
      (remainder of CWT omitted for when later authorizing
   requests from brevity;
      CWT contains COSE_Key in the client.  The RS is not mandated to be able 'cnf' claim)',
     "token_type" : "pop",
     "alg" : "HS256",
     "expires_in" : "3600",
     "profile" : "coap_dtls"
     "cnf" : {
       "COSE_Key" : {
         "kty" : "Symmetric",
         "kid" : b64'39Gqlw',
         "k" : b64'hJtXhkV8FJG+Onbc6mxCcQh'
       }
     }
   }

       Figure 5: Example AS response with an access token bound to
   manage multiple client at once. how the RS manages clients is out of
   scope for this specification.

5.3.1.  Authorization Information Request

   The client makes a POST request
                              symmetric key.

6.3.  Error Response

   The error responses for CoAP-based interactions with the AS are
   equivalent to the authorization information
   resource by sending its PoP token ones for HTTP-based interactions as request data.

   Client MUST send defined in
   section 5.2 of [RFC6749], with the Content-Format option indicate token format

5.3.2.  Authorization Information Response following differences: The RS
   Content-Type MUST resonde to a requests be set to "application/cbor", the authorization information
   resource.  The response payload MUST match be
   encoded in a CBOR map and the CoAP response codes according to
   success or error response section

5.3.2.1.  Success Response

   Successful requests code 4.00 Bad Request
   MUST be answered with 2.01 Created to indicate used unless specified otherwise.

6.4.  New Request and Response Parameters

   This section defines parameters that a "session" can be used in access token
   requests and responses, as well as abbreviations for the PoP Token has been created.  No location
   path is required to more compact
   encoding of existing parameters and common values.

6.4.1.  Grant Type

   The abbreviations in Figure 6 MAY be returned.

             Resource
     Client   Server
       |         |
       |         |
   A:  +-------->| Header: POST (Code=0.02)
       | POST    | Uri-Path: "/authz-info"
       |         | Content-Format: "application/cwt"
       |         | Payload: <PoP Token>
       |         |
   B:  |<--------+ Header: 2.01 Created used in CBOR encodings instead
   of the string values defined in [RFC6749].

             /--------------------+----------+--------------\
             | 2.01 grant_type         | CBOR Key | Major Type   |

       Figure 5: Authorization Information Resource Success Response

5.3.2.2.  Error Response

   The resource server MUST user appropriate CoAP response code to
   convey the error to the Client.  For request that are not valid, e.g.
   unknown Content-Format, 4.00 Bad Request MUST be returned.  If token
   is not valid, e.g. wrong audience, the RS MUST return 4.01
   Unauthorized.

             Resource
     Client   Server
             |--------------------+----------+--------------|
             | password           |    0     |     0 (uint) |
   A:  +-------->| Header: POST (Code=0.02)
             | POST authorization_code | Uri-Path: "/authz-info"    1     |     0        | Content-Format: "application/cwt"
             | client_credentials | Payload: <PoP Token>    2     |     0        |
   B:  |<--------+ Header: 4.01 Unauthorized
             | 2.01 refresh_token      |    3     |     0        |
             \--------------------+----------+--------------/

            Figure 6: Authorization Information Resource Error Response

5.4.  Authorization Information Format

   We introduce a new claim CBOR abbreviations for common grant types

6.4.2.  Token Type and Algorithms

   To allow clients to indicate support for describing access rights with a specific
   format, the "aif" claim.  In this memo we propose token types and
   respective algorithms they need to use the compact
   format provided by AIF [I-D.bormann-core-ace-aif].  Access rights may
   be specified as a list of URIs of resources together interact with allowed
   actions (GET, POST, PUT, PATCH, the AS.  They can
   either provide this information out-of-band or DELETE).  Other formats may be
   mandated by specific applications or requirements (e.g. specifying
   local conditions on access).

5.5.  CBOR Data Formats

   The /token resource (called "endpoint" via the 'token_type'
   and 'alg' parameter in OAuth 2.0), defined the client request.

   The value in
   Section 3.2 of [RFC6749], is the 'alg' parameter together with value from the
   'token_type' parameter allow the client to indicate the supported
   algorithms for a given token type.  The token type refers to the
   specification used by the client to obtain an access
   token.  Requests sent to interact with the /token resource use server
   to demonstrate possession of the HTTP POST method
   and key.  The 'alg' parameter provides
   further information about the payload includes algorithm, such as whether a query component, which symmetric
   or an asymmetric crypto-system is formatted as
   application/x-www-form-urlencoded.  CoAP payloads cannot be formatted
   in the same way which requires the /token resource on the AS to be
   profiled.  Appendix D defines used.  Hence, a CBOR-based format for sending
   parameters client supporting a
   specific token type also knows how to populate the /token resource.

5.6.  Token Expiration

   Depending on values to the capabilities of
   'alg' parameter.

   This document registers the RS, there are various ways in
   which it can verify new value "pop" for the validity of OAuth Access
   Token Types registry, specifying a received access Proof-of-Possession token.  We list  How
   the possibilities here including what functionality they require proof-of-possession is performed is specified by the 'alg'
   parameter.  Profiles of this framework are responsible for defining
   values for the RS.

   o  The token is a CWT/JWT and includes a 'exp' claim and possibly 'alg' parameter together with the
      'nbf' claim. corresponding proof-
   of-possession mechanisms.

   The RS verifies these by comparing them to values
      from its internal clock as defined in [RFC7519].  In this case the
      RS must have 'alg' parameter are case-sensitive.  If the client
   supports more than one algorithm then each individual value MUST be
   separated by a real time chip (RTC) or some other way of reliably
      measuring time.

   o space.

6.4.3.  Profile

   The RS verifies "profile" parameter identifies the validity of communication protocol and the token by performing an
      introspection request as specified in Appendix D.2.  This requires
   communication security protocol between the RS to have a reliable network connection to client and the AS RS.

   An initial set of profile identifiers and to be
      able to handle two secure sessions their CBOR encodings are
   specified in parallel (C to RS and AS Figure 7.  Profiles using other combinations of
   protocols are expected to
      RS).

   o  The RS define their own profile identifiers.

           /--------------------+----------+--------------\
           | Profile identifier | CBOR Key | Major Type   |
           |--------------------+----------+--------------|
           | http_tls           |    0     |     0 (uint) |
           | coap_dtls          |    1     |     0        |
           | coap_oscoap        |    2     |     0        |
           \--------------------+----------+--------------/

           Figure 7: Profile identifiers and the AS both store a sequence number linked to their
      common security association.  The AS increments this number CBOR mappings

   Profiles MAY define additional parameters for
      each access both the token it issues request
   and includes it the client information in the access token,
      which is a CWT/JWT.  The RS keeps track token response in order to
   support negotioation or signalling of profile specific parameters.

6.4.4.  Confirmation

   The "cnf" parameter identifies or provides the most recently
      received sequence number, key used for proof-of-
   possession.  This framework extends the definition of 'cnf' from
   [RFC7800] by defining CBOR/COSE encodings and only accepts tokens as valid, that
      are the use of 'cnf' for
   transporting keys in a certain range around the client information.

   A CBOR encoded payload MAY contain the 'cnf' parameter with the
   following contents:

   COSE_Key  In this number.  This method does only
      require case the RS 'cnf' parameter contains the proof-of-
      possession key to keep track of be used by the sequence number.  The method
      does not provide timely expiration, but it makes sure that older
      tokens cease to be valid after a specified number of newer ones
      got issued.  For client.  An example is shown in
      Figure 8.

   "cnf" : {
     "COSE_Key" : {
       "kty" : "EC",
       "kid" : h'11',
       "crv" : "P-256",
       "x" : b64'usWxHK2PmfnHKwXPS54m0kTcGJ90UiglWiGahtagnv8',
       "y" : b64'IBOL+C3BttVivg+lSreASjpkttcsz+1rb7btKLv8EX4'
     }
   }

         Figure 8: Confirmation parameter containing a constrained RS with no network connectivity and
      no means of reliably measuring time, public key

   COSE_Encrypted  In this is case the best that can be
      achieved.

6.  Deployment Scenarios

   There 'cnf' parameter contains an
      encrypted symmetriic key destined for the client.  The client is a large variety
      assumed to be able to decrypt the cihpertext of IoT deployments, as is indicated in
   Appendix A, and this section highlights common variants.  This
   section parameter.
      The parameter is not normative but illustrates how the framework can be
   applied.

   For each of the deployment variants there are encoded as COSE_Encrypted object wrapping a number
      COSE_Key object.  Figure 9 shows an example of possible
   security setups between clients, resource servers and authorization
   servers. this type of
      encoding.

   "cnf" : {
     "COSE_Encrypted" : {
       993(
         [ h'a1010a' # protected header : {"alg" : "AES-CCM-16-64-128"}
           "iv" : b64'ifUvZaHFgJM7UmGnjA',  # unprotected header
          b64'WXThuZo6TMCaZZqi6ef/8WHTjOdGk8kNzaIhIQ' # ciphertext
         ]
       )
     }
   }

   Figure 9: Confirmation paramter containing an encrypted symmetric key

      The main focus ciphertext here could e.g. contain a symmetric key as in the following subsections is on how
   authorization
      Figure 10.

   {
     "kty" : "Symmetric",
     "kid" : b64'39Gqlw',
     "k" : b64'hJtXhkV8FJG+Onbc6mxCcQh'
   }

        Figure 10: Example plaintext of an encrypted cnf parameter

   Key Identifier  In this case the 'cnf' parameter references a client request for a resource hosted by a RS key
      that is
   performed.  This requires us assumed to also consider how these requests and
   responses between be previously known by the recipient.  This
      allows clients and the resource servers are secured.

   The security protocols between other pairs of nodes in the
   architecture, namely client-to-AS and RS-to-AS, are not detailed in
   these examples.  Different security protocols may be used on
   transport or application layer.

   Note: We use the CBOR diagnostic notation for examples of that perform repeated requests
   and responses.

6.1.  Client and Resource Server are Offline

   In this scenario we consider the case where both the resource server
   and for an access token
      for the client are offline, i.e., they are not connected same audience but e.g. with different scopes to omit key
      transport in the AS at
   the time of the resource request.  This access procedure involves
   steps A, B, C, token, token request and F of token response.
      Figure 1, but assumes that step 11 shows such an example.

   "cnf" : {
     "kid" : b64'39Gqlw'
   }

      Figure 11: A and B have
   been carried out during Confirmation parameter with just a phase when the client had connectivity to
   AS.

   Since the resource server must be able key identifier

6.5.  Mapping parameters to verify the CBOR

   All OAuth parameters in access token
   locally, self-contained access tokens must be used.

   This example shows the interactions between a client, the
   authorization server requests and a temperature sensor acting responses are
   mapped to CBOR types as a resource
   server.  Message exchanges A follows and B are shown in Figure 7.

      A: The client first generates a public-private key pair used for
      communication security with the RS.

      The client sends the POST request to /token at AS.  The request
      contains the public given an integer key of the client and the Audience parameter
      set to "tempSensorInLivingRoom", a value that the temperature
      sensor identifies itself with.  The AS evaluates the request and
      authorizes the client to access the resource.

      B: The AS responds with a PoP token and client information.  The
      PoP token contains the public key of the client, while the client
      information contains the public key of the RS.  For communication
      security this example uses DTLS with raw public keys between the
      client and the RS.

      Note: In this example we assume that the client knows what
      resource it wants to access, and is therefore able to request
      specific audience and
   save space.

           /-------------------+----------+-----------------\
           | Parameter name    | CBOR Key | Major Type      |
           |-------------------+----------+-----------------|
           | client_id         | 1        | 3 (text string) |
           | client_secret     | 2        | 2 (byte string) |
           | response_type     | 3        | 3               |
           | redirect_uri      | 4        | 3               |
           | scope claims for the access token.

            Authorization
     Client    Server             | 5        | 3               |
           |
   A:  +-------->| Header: POST (Code=0.02) state             | POST 6        | Uri-Path:"token" 3               |
           | Payload: <Request-Payload> code              | 7        |
   B:  |<--------+ Header: 2.05 Content 2               |
           | Content-Type: application/cbor error_description | 2.05 8        | Payload: <Response-Payload> 3               |
           | error_uri         | 9        | 3               |
           | grant_type        | 10       | 0 (unit)        |
           | access_token      | 11       | 3               |
           | token_type        | 12       | 0               |
           | expires_in        | 13       | 0               |
           | username          | 14       | 3               |
           | password          | 15       | 3               |
           | refresh_token     | 16       | 3               |
           | alg               | 17       | 3               |
           | cnf               | 18       | 5 (map)         |
           | aud               | 19       | 3               |
           | profile           | 20       | 0               |
           \---------------+--------------+-----------------/

              Figure 7: Token Request and Response Using Client Credentials.

   The information contained 12: CBOR mappings used in token requests

7.  The 'Introspect' Resource

   Token introspection [RFC7662] is used by the Request-Payload RS and potentially the Response-
   Payload is shown in Figure 8.

   Request-Payload :
   {
     "grant_type" : "client_credentials",
     "aud" : "tempSensorInLivingRoom",
     "client_id" : "myclient",
     "client_secret" : "qwerty"
   }

   Response-Payload :
   {
     "access_token" : b64'SlAV32hkKG ...',
     "token_type" : "pop",
     "csp" : "DTLS",
     "key" : b64'eyJhbGciOiJSU0ExXzUi ...'
   }

              Figure 8: Request and Response Payload Details.

   The content of the "key" parameter and
   client to query the access AS for metadata about a given token are shown e.g. validity
   or scope.  Analogous to the protocol defined in
   Figure 9 RFC 7662 [RFC7662]
   for HTTP and Figure 10.

   {
     "kid" : b64'c29tZSBwdWJsaWMga2V5IGlk',
     "kty" : "EC",
     "crv" : "P-256",
     "x"   : b64'MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4',
     "y"   : b64'4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM'
   }

                      Figure 9: Public Key of the RS.

   {
     "aud" : "tempSensorInLivingRoom",
     "iat" : "1360189224",
     "cnf" : {
       "jwk" : {
         "kid" : b64'1Bg8vub9tLe1gHMzV76e8',
         "kty" : "EC",
         "crv" : "P-256",
         "x" : b64'f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU',
         "y" : b64'x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0'
       }
     }
   }

        Figure 10: Access Token including Public Key of the Client.

   Messages C JSON, this section defines adaptations to more
   constrained environments using CoAP and F are shown in Figure 11 - Figure 12.

      C: The client then sends CBOR.

   Communication between the PoP token to RS and the /authz-info introspection resource at the RS.  This is a plain CoAP request, i.e. no DTLS/OSCOAP
      between client and RS, since the token is AS
   MUST be integrity protected
      between and encrypted.  Furthermore AS and RS.  The RS verifies that
   MUST perform mutual authentication.  Finally the PoP token was created
      by a known and trusted AS, is valid, and responds AS SHOULD to verify
   that the client.
      The RS caches has the security context together with authorization right to access introspection information about this client contained in
   the PoP provided token.

      The client  Profiles of this framework are expected to
   specify how authentication and resource server run communication security is implemented.

   The figures of this section uses CBOR diagnostic notation without the DTLS handshake using
   integer abbreviations for the
      raw public keys established in step B and C. parameters or their values for better
   readability.

7.1.  RS-to-AS Request

   The client RS sends the a CoAP POST request GET to /temperature on RS over
      DTLS.  The RS verifies that the request is authorized.

      F: introspection resource at the
   AS, with payload sent as "application/cbor" data.  The RS responds payload is a
   CBOR map with a resource representation over DTLS.

              Resource
    Client     Server
       |         |
   C:  +-------->| Header: POST (Code=0.02)
       | POST    | Uri-Path:"authz-info"
       |         | Payload: SlAV32hkKG ...
       |         |   (access token)
       |         |
       |<--------+ Header: 2.04 Changed
       | 2.04    |
       |         |

                Figure 11: Access Token provisioning to RS

              Resource
    Client     Server
       |         |
       |<=======>| DTLS Connection Establishment
       |         |   using Raw Public Keys
       |         |
       |         |
       +-------->| Header: GET (Code=0.01)
       | GET     | Uri-Path: "temperature"
       |         |
       |         |
       |         |
   F:  |<--------+ Header: 2.05 Content
       | 2.05    | Payload: {"t":"22.7"}
       |         |

        Figure 12: Resource Request and Response protected 'token' parameter containing the access token along
   with optional parameters representing additional context that is
   known by DTLS.

6.2.  Resource Server Offline

   In this deployment scenario we consider the case of an RS that may
   not be able to access aid the AS at the time it receives an access
   request from a client.  We denote this case "RS offline", it involves
   steps A, B, C in its response.

   The same parameters are required and F optional as in section 2.1 of
   RFC 7662 [RFC7662].

   For example, Figure 1.

   If the 13 shows a RS is offline, then it must be possible for calling the RS to locally
   validate token introspection
   resource at the access token.  This requires self-contained tokens AS to be
   used. query about an OAuth 2.0 proof-of-possession
   token.

   Header: POST (Code=0.02)
   Uri-Host: "server.example.com"
   Uri-Path: "introspect"
   Content-Type: "application/cbor"
   Payload:
   {
     "token" : b64'7gj0dXJQ43U',
     "token_type_hint" : "pop"
   }

                 Figure 13: Example introspection request.

7.2.  AS-to-RS Response

   The validity time for the token should always be chosen as short as
   possible to reduce the possibility that AS responds with a token contains out-of-date
   authorization information.  Therefore the value for the Expiration
   Time claim ("exp") should be set only slightly larger than the value
   for the Issuing Time claim ("iss").  A constrained RS CBOR object in "application/cbor" format with means to
   reliably measure time must validate the expiration time of
   the access
   token.

   The following example shows interactions between a client (air-
   conditioning control unit), an offline resource server (temperature
   sensor)and an authorization server.  The message exchanges A same required and B
   are shown optional parameters as in Figure 13.

      A: The client sends section 2.2. of RFC
   7662 [RFC7662] with the request POST to /token at AS.  The request following additions:

   alg
      OPTIONAL.  See Section 6.4 for more details.

   cnf
      OPTIONAL.  This field contains information about the Audience parameter set to "tempSensor109797", a value proof-of-
      possession key that the temperature sensor identifies itself with.  The scope binds the client wants the AS to authorize the access token token.  See
      Section 6.4 for is "owner",
      which means more details on the formatting of the 'cnf'
      parameter.

   profile
      OPTIONAL.  This indicates the profile that the token can be used to both read temperature
      data and upgrade RS MUST use with
      the firmware client.  See Section 6.4 for more details on the RS.  The AS evaluates the
      request and authorizes formatting of
      this parameter.

   client_token
      OPTIONAL.  This parameter contains information that the client RS MUST
      pass on to access the resource.

      B: The client.  See Section 7.4 for more details.

   For example, Figure 14 shows an AS responds with a PoP token and client information.  The
      PoP token is wrapped in a COSE message, object secured content
      from AS to RS.  The client information contains a symmetric key.
      In this case communication security between C and RS is OSCOAP
      with an authenticated encryption algorithm.  The client derives
      two unidirectional security contexts to use with the resource
      request and response messages.  The access token includes the
      claim "aif" with the authorized access that an owner of the
      temperature device can enjoy.  The "aif" claim, issued by the AS,
      informs the RS that the owner of the access token, that can prove
      the possession of a key is authorized to make a GET request
      against the /tempC resource and a POST introspection
   request on the /firmware
      resource.

            Authorization
    Client     Server
       |         |
       |         |
   A:  +-------->| Header: POST (Code=0.02)
       | POST    | Uri-Path: "token"
       |         | Payload: <Request-Payload>
       |         |
   B:  |<--------+ in Figure 13.

   Header: 2.05 Content
       |         | Created Code=2.01)
   Content-Type: application/cbor
       | 2.05    | "application/cbor"
   Payload: <Response-Payload>
       |         |
       |         |

                   Figure 13: Token Request and Response

   The information contained in the Request-Payload and the Response-
   Payload is shown in Figure 14.

   Request-Payload:
   {
     "grant_type" : "client_credentials",
     "client_id" : "myclient",
     "client_secret" : "qwerty",
     "aud"
     "active" : "tempSensor109797", true,
     "scope" : "owner"
   }

   Response-Payload:
   {
     "access_token": b64'SlAV32hkKG ...', "read",
     "token_type" : "pop",
     "csp" : "OSCOAP",
     "key" : b64'eyJhbGciOiJSU0ExXzUi ...'
   }

          Figure 14: Request and Response Payload for RS offline

   Figure 15 shows examples of the key and the access_token parameters
   of the Response-Payload, decoded to CBOR.

   access_token:
   {
     "aud" : "tempSensor109797",
     "exp"
     "alg" : 1311281970,
     "iat" "HS256",
     "profile" : 1311280970,
     "aif" "coap_dtls",
     "client_token" :  [["/tempC", 0], ["/firmware", 2]], b64'2QPhg0OhAQo ...
     (remainder of client token omitted for brevity)',
     "cnf" : {
       "ck":b64'JDLUhTMjU2IiwiY3R5Ijoi ...'
       }
    }

   key:
       "COSE_Key" : {
     "alg"
         "kty" : "AES_128_CCM_8", "Symmetric",
         "kid" : b64'U29tZSBLZXkgSWQ', b64'39Gqlw',
         "k" : b64'ZoRSOrFzN_FzUA5XKMYoVHyzff5oRJxl-IXRtztJ6uE' b64'hJtXhkV8FJG+Onbc6mxCcQh'
       }
     }
   }

                Figure 15: Access Token and symmetric key from the Response-Payload

   Message exchanges C and F are shown in Figure 16 and Figure 17.

      C: 14: Example introspection response.

7.3.  Error Response

   The client then sends error responses for CoAP-based interactions with the PoP token AS are
   equivalent to the /authz-info resource ones for HTTP-based interactions as defined in
   section 2.3 of [RFC7662], with the RS.  This following differences:

   o  If content is a plain CoAP request, i.e. no DTLS/OSCOAP
      between client and RS, since sent, the token is integrity protected
      between AS Content-Type MUST be set to "application/
      cbor", and RS.  The RS verifies that the PoP token was created
      by payload MUST be encoded in a known CBOR map.
   o  If the credentials used by the RS are invalid the AS MUST respond
      with the CoAP response code code 4.01 (Unauthorized) and trusted AS, is valid, use the
      required and responds to optional parameters from section 5.2 in RFC 6749
      [RFC6749].
   o  If the client.
      The RS derives and caches does not have the security contexts together with
      authorization information about right to perform this client contained in introspection
      request, the PoP
      token.

      The client sends AS MUST respond with the CoAP requests GET response code 4.03
      (Forbidden).  In this case no payload is returned.

   Note that a properly formed and authorized query for an inactive or
   otherwise invalid token does not warrant an error response by this
   specification.  In these cases, the authorization server MUST instead
   respond with an introspection response with the "active" field set to
   "false".

7.4.  Client Token

   EDITORIAL NOTE: We have tentatively introduced this concept and would
   specifically like feedback if this is viewed as a useful addition to /tempC on
   the RS using
      OSCOAP.  The RS verifies framework.

   In cases where the request client has limited connectivity and that it is authorized.

      F: The RS responds with requesting
   access to a protected status code previously unknown resource servers, using OSCOAP.  The
      client verifies the response.

              Resource
     Client    Server
       |         |
   C:  +-------->| Header: POST (Code=0.02) a long term
   token, there are situations where it would be beneficial to relay the
   proof-of-possession key and other relevant information from the AS to
   the client through the RS.  The client_token parameter is designed to
   carry such information, and is intended to be used as described in
   Figure 15.

                     Resource       Authorization
    Client            Server           Server
       |                |                |
       |                |                |
   A:  +--------------->|                |
       |  POST          | Uri-Path:"authz-info"                |
       | Payload: <Access Token>  Access Token  |                |
       |            B:  +--------------->|
       |
       |<--------+ Header: 2.04 Changed                | 2.04 Introspection  |
       |                |    Request     |
       |

                Figure 16: Access Token provisioning to RS

               Resource
     Client     Server                |                |
       +-------->| Header: GET (Code=0.01)
       | GET            C:  +<---------------+
       | Object-Security:                | Introspection  |   (<seq>,<cid>,[Uri-Path:"tempC"],<tag>)
       |                |
   F:  |<--------+ Header: 2.05 Content   Response     | 2.05
       | Object-Security:                | + Client Token |
   D:  |<---------------+                |
       |   (<seq>,<cid>,[22.7 C],<tag>)  2.01 Created  |                |
       | + Client Token |

               Figure 17: Resource request and response protected by OSCOAP

   In Figure 17 the GET request contains an Object-Security option and
   an indication of the content 15: Use of the COSE object: client_token parameter.

   The client token is a sequence number
   ("seq", starting from 0), COSE_Encrytped object, containing as payload a context identifier ("cid") indicating the
   security context,
   CBOR map with the ciphertext containing following claims:

   cnf
      REQUIRED.  Contains information about the encrypted CoAP option
   identifying proof-of-possession key
      the resource, and client is to use with its access token.  See Section 6.4.4.

   token_type
      OPTIONAL.  See Section 6.4.2.

   alg
      OPTIONAL.  See Section 6.4.2.

   profile
      REQUIRED.  See Section 6.4.3.

   rs_cnf
      OPTIONAL.  Contains information about the Message Authentication Code ("tag")
   which also covers key that the Code in RS uses to
      authenticate towards the CoAP header.

   The Object-Security ciphertext in client.  If the response [22.7 C] represents an
   encrypted temperature reading.  (The COSE object key is actually carried
   in symmetric then
      this claim MUST NOT be part of the CoAP payload when possible but that is omitted to simplify
   notation.)

6.3.  Token Introspection with an Offline Client

   In Token, since this deployment scenario we assume that a client is not be able to
   access the AS at the time of the access request.  Since
      same key as the RS is,
   however, connected to one specified through the back-end infrastructure it can make use of
   token introspection. 'cnf' claim.  This access procedure involves steps A-F of
   Figure 1, but assumes steps A and B have been carried out during a
   phase when claim
      uses the client had connectivity to AS.

   Since same encoding as the client is assumed to be offline, at least for a certain
   period of time, a pre-provisioned access token has to be long-lived. 'cnf' parameter.  See Section 6.4.3.

   The resource server may use its online connectivity to validate the
   access AS encrypts this token with the authorization server, which is shown in the
   example below.

   In the example we show the interactions between an offline client
   (key fob), using a resource server (online lock), key shared between the AS and an authorization
   server.  We assume the
   client, so that there is a provisioning step where only the client
   has access to the AS.  This corresponds to message exchanges A can decrypt it and B
   which are shown in Figure 18.

      A: The client sends the request using POST access its
   payload.  How this key is established is out of scope of this
   framework.

7.5.  Mapping Introspection parameters to /token at AS. CBOR

   The introspection request contains the Audience parameter set and response parameters are mapped to "lockOfDoor4711", a
      value the that the online door in question identifies itself with.
      The AS generates an access token CBOR
   types as on opaque string, which it can
      match to the specific client, a targeted audience follows and a symmetric are given an integer key security context.

      B: The AS responds with the an access token and client
      information, the latter containing a symmetric key.  Communication
      security between C and RS will be OSCOAP with authenticated
      encryption.

            Authorization
    Client     Server value to save space.

             /----------------+----------+-----------------\
             | Parameter name | CBOR Key | Major Type      |
   A:  +-------->| Header: POST (Code=0.02)
             |----------------+----------+-----------------|
             | POST active         | Uri-Path:"token" 1        | 0 (uint)        | Payload: <Request-Payload>
             | username       |
   B:  |<--------+ Header: 2.05 Content 2        | 3 (text string) | Content-Type: application/cbor
             | 2.05 client_id      | Payload: <Response-Payload> 3        | 3               |
             | scope          | 4        | 3               |
             | token_type     | 5        | 3               |
             | exp            | 6        | 6 tag value 1   |
             | iat            | 7        | 6 tag value 1   |
             | nbf            | 8        | 6 tag value 1   |
             | sub            | 9        | 3               |
             | aud            | 10       | 3               |
             | iss            | 11       | 3               |
             | jti            | 12       | 3               |
             | alg            | 13       | 3               |
             | cnf            | 14       | 5 (map)         |
             | aud            | 15       | 3               |
             | client_token   | 16       | 3               |
             | rs_cnf         | 17       | 5               |
             \----------------+----------+-----------------/

        Figure 18: 16: CBOR Mappings to Token Request and Response using Client Credentials.

   Authorization consent from the resource owner can be pre-configured,
   but it can also be provided via an interactive flow with Introspection Parameters.

8.  The Access Token

   This framework RECOMMENDS the resource
   owner.  An example use of CBOR web token (CWT) as
   specified in [I-D.ietf-ace-cbor-web-token].

   In order to facilitate offline processing of access tokens, this for
   draft specfifies the key fob case could be "scope" claim for access tokens that explicitly
   encodes the
   resource owner has a connected car, he buys scope of a generic key that he
   wants to use with the car.  To authorize given access token.  This claim follows the key fob he connects it
   same encoding rules as defined in section 3.3 of [RFC6749].  The
   meaning of a specific scope value is application specific and
   expected to be known to his computer that then provides the UI for the device.  After RS running that
   OAuth 2.0 implicit flow is used to authorize application.

8.1.  The 'Authorization Information' Resource

   The access token, containing authorization information and
   information of the key for his car at used by the client, is transported to the car manufacturers AS.

   The information contained in RS
   so that the Request-Payload RS can authenticate and authorize the Response-
   Payload is shown in Figure 19.

   Request-Payload:
   {
     "grant_type" : "token",
     "aud" : "lockOfDoor4711",
     "client_id" : "myclient",
   }

   Response-Payload:
   {
     "access_token" : b64'SlAV32hkKG ...'
     "token_type" : "pop",
     "csp" : "OSCOAP",
     "key" : b64'eyJhbGciOiJSU0ExXzUi ...'
   }

           Figure 19: Request and Response Payload client request.
   This section defines a method for C offline

   The transporting the access token in this case is just an opaque string referencing
   the authorization information at to
   the AS.

      C: Next, RS using CoAP that MAY be used.  An ACE profile MAY define other
   methods for token transport.

   This method REQUIRES the RS to implement an /authz-info resource.  A
   client POSTs using this method MUST make a POST request to /authz-info on
   the RS with the access token to the /authz-info
      resource in the RS.  This is a plain CoAP request, i.e. no DTLS/
      OSCOAP between client and RS.  Since payload.  The RS receiving the
   token MUST verify the validity of the token.  If the token is an opaque
      string, valid,
   the RS cannot verify it on its own, and thus defers to MUST respond to the client POST request with a status code until step E and only
      acknowledges on the CoAP message layer (indicated 2.04 (Changed).

   If the token is not valid, the RS MUST respond with a dashed
      line).

               Resource
     Client     Server
       |         |
   C:  +-------->| Header: POST (T=CON, Code=0.02
       | POST    | Token 0x2a12)
       |         | Uri-Path:"authz-info"
       |         | Payload: SlAV32hkKG ...
       |         |   (access token)
       |         |
       |<- - - - + Header: T=ACK
       |         |

                Figure 20: Access Token provisioning to error code 4.01
   (Unauthorized).  If the token is valid but the audience of the token
   does not match the RS, the RS

      D: MUST respond with error code 4.03
   (Forbidden).

   The RS forwards MAY make an introspection request to validate the token before
   responding to the /introspect resource on POST /authz-info request.  If the
      AS.  Introspection assumes introspection
   response contains a secure connection between client token (Section 7.4) then this token SHALL
   be included in the AS and payload of the 2.04 (Changed) response.

8.2.  Token Expiration

   Depending on the capabilities of the RS, e.g. using DTLS or OSCOAP, which is not detailed there are various ways in this
      example.

      E: The AS provides the introspection response containing claims
      about
   which it can verify the validity of a received access token.  This includes  We list
   the confirmation key (cnf) possibilities here including what functionality they require of
   the RS.

   o  The token is a CWT/JWT and includes a 'exp' claim
      that allows and possibly the
      'nbf' claim.  The RS verifies these by comparing them to verify the client's proof of possession values
      from its internal clock as defined in
      step F.

      After receiving message E, [RFC7519].  In this case the
      RS responds to must have a real time chip (RTC) or some other way of reliably
      measuring time.
   o  The RS verifies the client's POST in
      step C with Code 2.04 (Changed), using CoAP Token 0x2a12.  This
      step is not shown in validity of the figures.

   Resource Authorization
    Server     Server
       |          |
   D:  +--------->| Header: POST (Code=0.02)
       |  POST    | Uri-Path: "introspect"
       |          | Payload: <Request-Payload>
       |          |
   E:  |<---------+ Header: 2.05 Content
       |  2.05    | Content-Type: application/cbor)
       |          | Payload: <Response-Payload>
       |          |

               Figure 21: Token Introspection for C offline

      The information contained token by performing an
      introspection request as specified in Section 7.  This requires
      the Request-Payload and RS to have a reliable network connection to the Response-
      Payload is shown AS and to be
      able to handle two secure sessions in Figure 22.

   Request-Payload:
   {
     "token" : b64'SlAV32hkKG...',
     "client_id" : "myRS",
     "client_secret" : "ytrewq"
   }

   Response-Payload:
   {
     "active" : true,
     "aud" : "lockOfDoor4711",
     "scope" : "open, close",
     "iat" : 1311280970,
     "cnf" : {
       "ck" : b64'JDLUhTMjU2IiwiY3R5Ijoi ...'
     }
   }

         Figure 22: Request parallel (C to RS and Response Payload for Introspection

      The client sends the CoAP requests PUT 1 (= "close the lock") AS to
      /lock on
      RS).
   o  The RS using OSCOAP with and the AS both store a sequence number linked to their
      common security context derived from the
      key supplied association.  The AS increments this number for
      each access token it issues and includes it in step B. the access token,
      which is a CWT/JWT.  The RS verifies the request with keeps track of the key
      supplied in step E most recently
      received sequence number, and only accepts tokens as valid, that it is authorized by the token supplied
      are in step C.

      F: The RS responds with a protected status code using OSCOAP.  The
      client verifies certain range around this number.  This method does only
      require the response.

              Resource
     Client    Server
       |         |
       +-------->| Header: PUT (Code=0.03)
       | PUT     | Object-Security:
       |         |    (<seq>,<cid>,[Uri-Path:"lock", 1],<tag>)
       |         |
   F:  |<--------+ Header: 2.04 Changed
       | 2.04    | Object-Security:
       |         |    (<seq>,<cid>,,<tag>)
       |         |

       Figure 23: Resource request and response protected by OSCOAP RS to keep track of the sequence number.  The Object-Security ciphertext [...] method
      does not provide timely expiration, but it makes sure that older
      tokens cease to be valid after a certain number of newer ones got
      issued.  For a constrained RS with no network connectivity and no
      means of reliably measuring time, this is the PUT request contains CoAP
   options best that are encrypted, can be
      achieved.

9.  Security Considerations

   The entire document is about security.  Security considerations
   applicable to authentication and authorization in RESTful
   environments provided in OAuth 2.0 [RFC6749] apply to this work, as
   well as the payload value '1' security considerations from [I-D.ietf-ace-actors].
   Furthermore [RFC6819] provides additional security considerations for
   OAuth which is
   the value of PUT apply to the door lock.

   In this example there is no ciphertext of the PUT response, but "tag"
   contains a MAC which covers the request sequence number IoT deployments as well.  Finally
   [I-D.ietf-oauth-pop-architecture] discusses security and context
   identifier privacy
   threats as well as mitigation measures for Proof-of-Possession
   tokens.

10.  IANA Considerations

   This specification registers new parameters for OAuth and establishes
   registries for mappings to CBOR.

10.1.  OAuth Introspection Response Parameter Registration

   This specification registers the Code which allows following parameters in the Client OAuth
   introspection response parameters

   o  Name: "alg"
   o  Description: Algorithm to verify that use with PoP key, as defined in PoP
      token specification,
   o  Change Controller: IESG
   o  Specification Document(s): this actuator command was well received (door is locked).

6.4.  Always-On Connectivity

   A popular deployment scenario for IoT devices is document

   o  Name: "cnf"
   o  Description: Key to have them always
   be connected use to prove the Internet so that they can be reachable right to receive
   commands.  As a continuation from the previous scenarios we assume
   that both the use an access token,
      as defined in [RFC7800].
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Name: "aud"
   o  Description: reference to intended receiving RS, as defined in PoP
      token specification.
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Name: "profile"
   o  Description: The communication and communication security profile
      used between client and RS, as defined in ACE profiles.
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Name: "client_token"
   o  Description: Information that the RS are online at the time of the access
   request.

   If MUST pass to the client and e.g.
      about the resource server are online then proof-of-possession keys.
   o  Change Controller: IESG
   o  Specification Document(s): this document

10.2.  OAuth Parameter Registration

   This specification registers the AS should
   be configured to issue short-lived access tokens for following parameters in the resource OAuth
   Parameters Registry

   o  Name: "alg"
   o  Description: Algorithm to
   the client.  The resource server must then validate self-contained
   access tokens or otherwise must use with PoP key, as defined in PoP
      token introspection specification,
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "profile"
   o  Parameter usage location: token request, and token response
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Name: "cnf"
   o  Description: Key to obtain the
   up-to-date claim information.  If transmission costs are high or use to prove the
   channel is lossy, right to use an access token,
      as defined in [RFC7800].
   o  Change Controller: IESG
   o  Specification Document(s): this document

10.3.  OAuth Access Token Types

   This specification registers the CWT following new token format
   [I-D.wahlstroem-ace-cbor-web-token] may type in the
   OAuth Access Token Types Registry

   o  Name: "PoP"
   o  Description: A proof-of-possession token.
   o  Change Controller: IESG
   o  Specification Document(s): this document

10.4.  Token Type Mappings

   A new registry will be used instead of a JWT requested from IANA, entitled "Token Type
   Mappings".  The registry is to
   reduce the volume of network traffic.  In terms be created as Expert Review Required.

10.4.1.  Registration Template

   Token Type:
      Name of messaging this
   deployment scenario uses the patterns described token type as registered in the previous sub-
   sections.

   Note that despite the lack of connectivity constraints there may
   still OAuth token type registry
      e.g.  "Bearer".
   Mapped value:
      Integer representation for the token type value.  The key value
      MUST be other restrictions a deployment may face.

6.5.  Token-less Authorization

   In this deployment scenario we consider an integer in the case range of an RS which is
   severely energy constrained, sleeps most 1 to 65536.
   Change Controller:

      For Standards Track RFCs, list the "IESG".  For others, give the
      name of the time and need responsible party.  Other details (e.g., postal
      address, email address, home page URI) may also be included.
   Specification Document(s):
      Reference to have
   a tight messaging budget.  It the document or documents that specify the
      parameter,preferably including URIs that can be used to retrieve
      copies of the documents.  An indication of the relevant sections
      may also be included but is not only infeasible to access required.

10.4.2.  Initial Registry Contents

   o  Parameter name: "Bearer"
   o  Mapped value: 1
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "pop"
   o  Mapped value: 2
   o  Change Controller: IESG
   o  Specification Document(s): this document

10.5.  JSON Web Token Claims

   This specification registers the AS
   at following new claim in the time JSON Web
   Token (JWT) registry.

   o  Claim Name: "scope"
   o  Claim Description: The scope of the an access request, token as defined in the "RS offline" case
   Section 6.2, it must
      [RFC6749].
   o  Change Controller: IESG
   o  Specification Document(s): this document

10.6.  ACE Profile Registry

   A new registry will be offloaded as much message communication as
   possible.

   OAuth 2.0 requested from IANA, entitled "ACE Profile
   Registry".  The registry is already an efficient protocol in terms of message
   exchanges and can to be further optimized by compact encodings created as Expert Review Required.

10.6.1.  Registration Template

   Profile name:
      Name of
   tokens.  The scenario illustrated the profile to be included in this section goes beyond that the profile attribute.
   Profile description:
      Text giving an over view of the profile and removes the access tokens from context it is
      developed for.
   Profile ID:
      Integer value to identify the protocol.  This may profile.  The value MUST be
   considered a degenerate case an
      integer in the range of OAuth 2.0 but it allows us 1 to do two
   things:

   1.  The common case where authorization is performed by means 65536.
   Change Controller:

      For Standards Track RFCs, list the "IESG".  For others, give the
      name of
       authentication fits into the same protocol framework.
       Authentication protocol and key is specified by client
       information, and access token is omitted.

   2.  Authentication, and thereby authorization, responsible party.  Other details (e.g., postal
      address, email address, home page URI) may even also be implicit,
       i.e. anyone with access included.
   Specification Document(s):
      Reference to the right key is authorized document or documents that specify the
      parameter,preferably including URIs that can be used to access retrieve
      copies of the protected resource.

   In case 2., documents.  An indication of the RS does relevant sections
      may also be included but is not need to receive any message required.

10.7.  OAuth Parameter Mappings Registry

   A new registry will be requested from the
   client, and therefore enables offloading recurring resource request
   and response processing IANA, entitled "Token Resource
   CBOR Mappings Registry".  The registry is to a third party, such be created as a Message Broker
   (MB) in a publish-subscribe setting.

   This scenario involves steps A, B, C and F of Figure 1 and four
   parties: a client (subscriber), an offline RS (publisher), a trusted
   AS, and a MB, not necessarily trusted with access Expert
   Review Required.

10.7.1.  Registration Template

   Parameter name:
      OAuth Parameter name, refers to the plain text
   publications.  Message exchange A, B is shown name in Figure 24.

      A: The client sends the request POST to /token at AS.  The request
      contains the Audience OAuth parameter set to "birchPollenSensor301", a
      registry e.g. "client_id".
   CBOR key value:
      Key value that characterizes a certain pollen sensor resource.  The AS
      evaluates the request and authorizes the client to access for the
      resource.

      B: claim.  The AS responds with key value MUST be an empty token and client information with
      a security context integer in the
      range of 1 to 65536.
   Change Controller:
      For Standards Track RFCs, list the "IESG".  For others, give the
      name of the responsible party.  Other details (e.g., postal
      address, email address, home page URI) may also be used by included.
   Specification Document(s):
      Reference to the client.  The empty token
      signifies document or documents that authorization is performed by means specify the
      parameter,preferably including URIs that can be used to retrieve
      copies of
      authentication using the communication security protocol indicated
      with "csp".  In this case it is object security documents.  An indication of content (OSCON)
      i.e. protection of CoAP payload only.  The security context
      contains the symmetric decryption key and a public signature
      verification key of the RS.

           Authorization
     Client   Server
       |         |
       |         |
   A:  +-------->| Header: POST (Code=0.02)
       | POST    | Uri-Path:"token"
       |         | Payload: <Request-Payload>
       |         |
   B:  |<--------+ Header: 2.05 Content
       |         | Content-Type: application/cbor
       | 2.05    | Payload: <Response-Payload>
       |         |
       |         |

                   Figure 24: Token Request and Response

   The information contained in the Request-Payload and the Response-
   Payload relevant sections
      may also be included but is shown in Figure 25.

   Request-Payload :
   {
     "grant_type" : "client_credentials",
     "aud" : "birchPollenSensor301", not required.

10.7.2.  Initial Registry Contents

   o  Parameter name: "client_id" : "myclient",
   o  CBOR key value: 1
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "client_secret" : "qwerty"
   }

   Response-Payload :
   {
     "access_token" : NULL,
     "token_type" : "none",
     "csp" : "OSCON",
     "key" : b64'eyJhbGciOiJSU0ExXzUi ...'
   }

    Figure 25: Request and Response Payload for RS severely constrained

   The content of the "key" parameter is shown in Figure 26.
   o  CBOR key :
   {
     "alg" : "AES_128_CTR_ECDSA",
     "kid" : b64'c29tZSBvdGhlciBrZXkgaWQ';
     "k"   : b64'ZoRSOrFzN_FzUA5XKMYoVHyzff5oRJxl-IXRtztJ6uE',
     "crv" : "P-256",
     "x"   : b64'MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4',
     "y"   : b64'4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM'
   }

                      Figure 26: The 'key' value: 2
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter

   The RS, which sleeps most of the time, occasionally wakes up,
   measures the number birch pollens per cubic meters, publishes the
   measurements to the MB, and then returns to sleep.  See Figure 27.

   In name: "response_type"
   o  CBOR key value: 3
   o  Change Controller: IESG
   o  Specification Document(s): this case the birch pollen count stopped at 270, which is
   encrypted with the symmetric document

   o  Parameter name: "redirect_uri"
   o  CBOR key and signed with the private value: 4
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "scope"
   o  CBOR key of
   the RS.  The MB verifies that the message originates from RS using
   the public value: 5
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "state"
   o  CBOR key of RS, that it is not a replay of an old measurement
   using the sequence number of the OSCON COSE profile, and caches the
   object secured content.  The MB does not have the secret value: 6
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "code"
   o  CBOR key so is
   unable to read the plain text measurement.

   Message exchanges C and F are shown in Figure 27.

      C: Since there is no access token, the client does not address the
      /authz-info resource in the RS.  The client sends the CoAP request
      GET to /birchPollen on MB which is a plain CoAP request.

      F: The MB responds with the cached object secured content.

              Message   Resource
     Client    Broker    Server
       |         |         |
       |         |<--------| Header: PUT (Code=0.02)
       |         |  PUT    | Uri-Path: "birchPollen"
       |         |         | Payload: (<seq>,<cid>,["270"],<tag>)
       |         |         |
       |         |-------->| Header: 2.04 Changed
       |         | 2.04    |
       |         |
       |         |
   C:  +-------->| Header: GET (Code=0.01)
       | GET     | Uri-Path: "birchPollen"
       |         |
       |         |
   F:  |<--------+ Header: 2.05 Content
       | 2.05    | Payload: (<seq>,<cid>,["270"],<tag>)
       |         |

              Figure 27: Sensor measurement protected by COSE

   The payload is a COSE message consisting of sequence number 'seq'
   stepped by the RS for each publication, the context identifier 'cid'
   in value: 7
   o  Change Controller: IESG
   o  Specification Document(s): this case coinciding with the document

   o  Parameter name: "error_description"
   o  CBOR key identifier 'kid' of Figure 26,
   the encrypted measurement and the signature by the RS.

   Note that the same COSE message format may value: 8
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "error_uri"
   o  CBOR key value: 9
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "grant_type"
   o  CBOR key value: 10
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "access_token"
   o  CBOR key value: 11
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "token_type"
   o  CBOR key value: 12
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "expires_in"
   o  CBOR key value: 13
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "username"
   o  CBOR key value: 14
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "password"
   o  CBOR key value: 15
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "refresh_token"
   o  CBOR key value: 16
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "alg"
   o  CBOR key value: 17
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "cnf"
   o  CBOR key value: 18
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "aud"
   o  CBOR key value: 19
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "profile"
   o  CBOR key value: 20
   o  Change Controller: IESG
   o  Specification Document(s): this document

10.8.  Introspection Resource CBOR Mappings Registry

   A new registry will be requested from IANA, entitled "Introspection
   Resource CBOR Mappings Registry".  The registry is to be used created as
   Expert Review Required.

10.8.1.  Registration Template

   Response parameter name:
      Name of the response parameter as defined in OSCOAP but
   that only CoAP payload is protected in this case.

   The authorization step is implicit, so while any client could request
   access the COSE object, only authorized clients have access to "OAuth Token
      Introspection Response" registry e.g. "active".
   CBOR key value:
      Key value for the
   symmetric claim.  The key needed value MUST be an integer in the
      range of 1 to decrypt 65536.
   Change Controller:
      For Standards Track RFCs, list the content.

   Note that in this case "IESG".  For others, give the order
      name of the message exchanges A,B and C,F
   could in principle responsible party.  Other details (e.g., postal
      address, email address, home page URI) may also be interchanged, i.e. the client could first
   request and obtain included.
   Specification Document(s):
      Reference to the protected resource in steps C,F; and after document or documents that request client information containing the keys decrypt and
   verify specify the message.

6.6.  Securing Group Communication

   There are use cases
      parameter,preferably including URIs that require securing communication between a
   (group of) senders and a group of receivers.  One prominent example
   is lighting.  Often, a set of lighting nodes (e.g., luminaires, wall-
   switches, sensors) are grouped together and only authorized members
   of the group must be able read and process messages.  Additionally,
   receivers of group messages must can be able used to verify retrieve
      copies of the integrity documents.  An indication of
   received messages as being generated within the group.

   The requirements for securely communicating in such group use cases
   efficiently relevant sections
      may also be included but is outlined in [I-D.somaraju-ace-multicast] along with an
   architectural description that aligns with the content of not required.

10.8.2.  Initial Registry Contents

   o  Response parameter name: "active"
   o  CBOR key value: 1
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Response parameter name: "username"
   o  CBOR key value: 2
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Response parameter name: "client_id"
   o  CBOR key value: 3
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Response parameter name: "scope"
   o  CBOR key value: 4
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Response parameter name: "token_type"
   o  CBOR key value: 5
   o  Change Controller: IESG
   o  Specification Document(s): this
   document.  The requirements for conveying the necessary identifiers
   to reference groups and also the process of commissioning devices can
   be accomplished using the protocol described in document

   o  Response parameter name: "exp"
   o  CBOR key value: 6
   o  Change Controller: IESG
   o  Specification Document(s): this document.  For
   details about the lighting-unique use case aspects, the architecture,
   as well as other multicast-specific considerations we refer the
   reader to [I-D.somaraju-ace-multicast].

7.  Security Considerations

   The entire document is about security.  Security considerations
   applicable to authentication and authorization in RESTful
   environments provided in OAuth 2.0 [RFC6749] apply to

   o  Response parameter name: "iat"
   o  CBOR key value: 7
   o  Change Controller: IESG
   o  Specification Document(s): this work, as
   well as the security considerations from [I-D.ietf-ace-actors].
   Furthermore [RFC6819] provides additional security considerations for
   OAuth which apply to IoT deployments as well.  Finally
   [I-D.ietf-oauth-pop-architecture] discusses security and privacy
   threats as well as mitigation measures for Proof-of-Possession
   tokens.

8.  IANA Considerations

   TBD

   FIXME: Add registry over 'csp' values from Figure 2

   FIXME: Add registry of 'rpk' document

   o  Response parameter from section 5.1

   FIXME: Add registry of 'tktn' values from Figure 3

8.1. name: "nbf"
   o  CBOR key value: 8
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Response parameter name: "sub"
   o  CBOR key value: 9
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Response parameter name: "aud"
   o  CBOR key value: 10
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Response parameter name: "iss"
   o  CBOR key value: 11
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Response parameter name: "jti"
   o  CBOR key value: 12
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "alg"
   o  CBOR key value: 13
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "cnf"
   o  CBOR key value: 14
   o  Change Controller: IESG
   o  Specification Document(s): this document

   o  Parameter name: "aud"
   o  CBOR key value: 15
   o  Change Controller: IESG
   o  Specification Document(s): this document

10.9.  CoAP Option Number Registration

   This section registers the "Access-Token" CoAP Option Number
   [RFC2046] in the
   "CoRE Parameters" sub-registry "CoAP Option Numbers" in the manner
   described in [RFC7252].

   Name

      Access-Token
   Number

      TBD
   Reference

      [draft-ietf-ace-oauth-authz]

      [This document].
   Meaning in Request

      Contains an Access Token according to [draft-ietf-ace-oauth-authz] [This document] containing
      access permissions of the client.
   Meaning in Response

      Not used in response
   Safe-to-Forward

      TBD
   Format

      Based on the observer the format is perseved perceived differently.  Opaque
      data to the client and CWT or reference token to the RS.
   Length

      Less then 255 bytes

9.

11.  Acknowledgments

   We would like to thank Eve Maler for her contributions to the use of
   OAuth 2.0 and UMA in IoT scenarios, Robert Taylor for his discussion
   input, and Malisa Vucinic for his input on the ACRE proposal
   [I-D.seitz-ace-core-authz] which was one source of inspiration for
   this work.  Finally, we would like to thank the ACE working group in
   general for their feedback.

10.

   Ludwig Seitz and Goeran Selander worked on this document as part of
   the CelticPlus project CyberWI, with funding from Vinnova.

12.  References

10.1.

12.1.  Normative References

   [I-D.bormann-core-ace-aif]
              Bormann, C., "An Authorization Information Format (AIF)
              for ACE", draft-bormann-core-ace-aif-03

   [I-D.ietf-ace-cbor-web-token]
              Wahlstroem, E., Jones, M., and H. Tschofenig, "CBOR Web
              Token (CWT)", draft-ietf-ace-cbor-web-token-00 (work in
              progress), July 2015. May 2016.

   [I-D.ietf-cose-msg]
              Schaad, J., "CBOR Encoded Message Syntax", draft-ietf-
              cose-msg-10
              cose-msg-12 (work in progress), February May 2016.

   [I-D.ietf-oauth-introspection]
              Richer, J., "OAuth 2.0 Token Introspection", draft-ietf-
              oauth-introspection-11 (work in progress), July 2015.

   [I-D.ietf-oauth-pop-architecture]
              Hunt, P., Richer, J., Mills, W., Mishra, P., and H.
              Tschofenig, "OAuth 2.0 Proof-of-Possession (PoP) Security
              Architecture", draft-ietf-oauth-pop-architecture-07 (work
              in progress), December 2015.

   [I-D.ietf-oauth-pop-key-distribution]
              Bradley, J., Hunt, P., Jones, M., and H. Tschofenig,
              "OAuth 2.0 Proof-of-Possession: Authorization Server to
              Client Key Distribution", draft-ietf-oauth-pop-key-
              distribution-02 (work in progress), October 2015.

   [I-D.selander-ace-object-security]
              Selander, G., Mattsson, J., Palombini, F., and L. Seitz,
              "Object Security of CoAP (OSCOAP)", draft-selander-ace-
              object-security-03 (work in progress), October 2015.

   [I-D.wahlstroem-ace-cbor-web-token]
              Wahlstroem, E., Jones, M., and H. Tschofenig, "CBOR Web
              Token (CWT)", draft-wahlstroem-ace-cbor-web-token-00 (work
              in progress), December 2015.

   [I-D.wahlstroem-ace-oauth-introspection]
              Wahlstroem, E., "OAuth 2.0 Introspection over the
              Constrained Application Protocol (CoAP)", draft-
              wahlstroem-ace-oauth-introspection-01
              object-security-04 (work in progress), March 2015. 2016.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <http://www.rfc-editor.org/info/rfc2119>.

   [RFC4279]  Eronen, P., Ed. and H. Tschofenig, Ed., "Pre-Shared Key
              Ciphersuites for Transport Layer Security (TLS)",
              RFC 4279, DOI 10.17487/RFC4279, December 2005,
              <http://www.rfc-editor.org/info/rfc4279>.

   [RFC6347]  Rescorla, E. and N. Modadugu, "Datagram Transport Layer
              Security Version 1.2", RFC 6347, DOI 10.17487/RFC6347,
              January 2012, <http://www.rfc-editor.org/info/rfc6347>.

   [RFC7252]  Shelby, Z., Hartke, K., and C. Bormann, "The Constrained
              Application Protocol (CoAP)", RFC 7252,
              DOI 10.17487/RFC7252, June 2014,
              <http://www.rfc-editor.org/info/rfc7252>.

   [RFC7516]  Jones, M. and J. Hildebrand, "JSON Web Encryption (JWE)",

   [RFC7662]  Richer, J., Ed., "OAuth 2.0 Token Introspection",
              RFC 7516, 7662, DOI 10.17487/RFC7516, May 10.17487/RFC7662, October 2015,
              <http://www.rfc-editor.org/info/rfc7516>.

   [RFC7517]
              <http://www.rfc-editor.org/info/rfc7662>.

   [RFC7800]  Jones, M., "JSON Web Bradley, J., and H. Tschofenig, "Proof-of-
              Possession Key (JWK)", Semantics for JSON Web Tokens (JWTs)",
              RFC 7517, 7800, DOI 10.17487/RFC7517, May 2015,
              <http://www.rfc-editor.org/info/rfc7517>.

10.2. 10.17487/RFC7800, April 2016,
              <http://www.rfc-editor.org/info/rfc7800>.

12.2.  Informative References

   [I-D.ietf-ace-actors]
              Gerdes, S., Seitz, L., Selander, G., and C. Bormann, "An
              architecture for authorization in constrained
              environments", draft-ietf-ace-actors-02 draft-ietf-ace-actors-03 (work in
              progress), October 2015. March 2016.

   [I-D.ietf-core-block]
              Bormann, C. and Z. Shelby, "Block-wise transfers in CoAP",
              draft-ietf-core-block-18
              draft-ietf-core-block-20 (work in progress), April 2016.

   [I-D.ietf-oauth-pop-architecture]
              Hunt, P., Richer, J., Mills, W., Mishra, P., and H.
              Tschofenig, "OAuth 2.0 Proof-of-Possession (PoP) Security
              Architecture", draft-ietf-oauth-pop-architecture-07 (work
              in progress), September December 2015.

   [I-D.seitz-ace-core-authz]
              Seitz, L., Selander, G., and M. Vucinic, "Authorization
              for Constrained RESTful Environments", draft-seitz-ace-
              core-authz-00 (work in progress), June 2015.

   [I-D.somaraju-ace-multicast]
              Somaraju, A., Kumar, S., Tschofenig, H., and W. Werner,
              "Security for Low-Latency Group Communication", draft-
              somaraju-ace-multicast-01 (work in progress), January
              2016.

   [RFC4680]  Santesson, S., "TLS Handshake Message for Supplemental
              Data", RFC 4680, DOI 10.17487/RFC4680, October 2006,
              <http://www.rfc-editor.org/info/rfc4680>.

   [RFC4949]  Shirey, R., "Internet Security Glossary, Version 2",
              FYI 36, RFC 4949, DOI 10.17487/RFC4949, August 2007,
              <http://www.rfc-editor.org/info/rfc4949>.

   [RFC5246]  Dierks, T. and E. Rescorla, "The Transport Layer Security
              (TLS) Protocol Version 1.2", RFC 5246,
              DOI 10.17487/RFC5246, August 2008,
              <http://www.rfc-editor.org/info/rfc5246>.

   [RFC6690]  Shelby, Z., "Constrained RESTful Environments (CoRE) Link
              Format", RFC 6690, DOI 10.17487/RFC6690, August 2012,
              <http://www.rfc-editor.org/info/rfc6690>.

   [RFC6749]  Hardt, D., Ed., "The OAuth 2.0 Authorization Framework",
              RFC 6749, DOI 10.17487/RFC6749, October 2012,
              <http://www.rfc-editor.org/info/rfc6749>.

   [RFC6750]  Jones, M. and D. Hardt, "The OAuth 2.0 Authorization
              Framework: Bearer Token Usage", RFC 6750,
              DOI 10.17487/RFC6750, October 2012,
              <http://www.rfc-editor.org/info/rfc6750>.

   [RFC6819]  Lodderstedt, T., Ed., McGloin, M., and P. Hunt, "OAuth 2.0
              Threat Model and Security Considerations", RFC 6819,
              DOI 10.17487/RFC6819, January 2013,
              <http://www.rfc-editor.org/info/rfc6819>.

   [RFC7049]  Bormann, C. and P. Hoffman, "Concise Binary Object
              Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049,
              October 2013, <http://www.rfc-editor.org/info/rfc7049>.

   [RFC7159]  Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
              Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March
              2014, <http://www.rfc-editor.org/info/rfc7159>.

   [RFC7228]  Bormann, C., Ersue, M., and A. Keranen, "Terminology for
              Constrained-Node Networks", RFC 7228,
              DOI 10.17487/RFC7228, May 2014,
              <http://www.rfc-editor.org/info/rfc7228>.

   [RFC7231]  Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
              Protocol (HTTP/1.1): Semantics and Content", RFC 7231,
              DOI 10.17487/RFC7231, June 2014,
              <http://www.rfc-editor.org/info/rfc7231>.

   [RFC7519]  Jones, M., Bradley, J., Bradley, J., and N. Sakimura, "JSON Web Token
              (JWT)", RFC 7519, DOI 10.17487/RFC7519, May 2015,
              <http://www.rfc-editor.org/info/rfc7519>.

   [RFC7591]  Richer, J., Ed., Jones, M., Bradley, J., Machulak, M., and
              P. Hunt, "OAuth 2.0 Dynamic Client Registration Protocol",
              RFC 7591, DOI 10.17487/RFC7591, July 2015,
              <http://www.rfc-editor.org/info/rfc7591>.

   [RFC7744]  Seitz, L., Ed., Gerdes, S., Ed., Selander, G., Mani, M.,
              and N. Sakimura, "JSON Web Token
              (JWT)", S. Kumar, "Use Cases for Authentication and
              Authorization in Constrained Environments", RFC 7519, 7744,
              DOI 10.17487/RFC7519, May 2015,
              <http://www.rfc-editor.org/info/rfc7519>. 10.17487/RFC7744, January 2016,
              <http://www.rfc-editor.org/info/rfc7744>.

Appendix A.  Design Justification

   This section provides further insight into the design decisions of
   the solution documented in this document.  Section 3 lists several
   building blocks and briefly summarizes their importance.  The
   justification for offering some of those building blocks, as opposed
   to using OAuth 2.0 as is, is given below.

   Common IoT constraints are:

   Low Power Radio:

      Many IoT devices are equipped with a small battery which needs to
      last for a long time.  For many constrained wireless devices the
      highest energy cost is associated to transmitting or receiving
      messages.  It is therefore important to keep the total
      communication overhead low, including minimizing the number and
      size of messages sent and received, which has an impact of choice
      on the message format and protocol.  By using CoAP over UDP, and
      CBOR encoded messages some of these aspects are addressed.
      Security protocols contribute to the communication overhead and
      can in some cases be optimized.  For example authentication and
      key establishment may in certain cases where security requirements
      so allows be replaced by provisioning of security context by a
      trusted third party, using transport or application layer
      security.

   Low CPU Speed:

      Some IoT devices are equipped with processors that are
      significantly slower than those found in most current devices on
      the Internet.  This typically has implications on what timely
      cryptographic operations a device is capable to perform, which in
      turn impacts e.g. protocol latency.  Symmetric key cryptography
      may be used instead of the computationally more expensive public
      key cryptography where the security requirements so allows, but
      this may also require support for trusted third party assisted
      secret key establishment using transport or application layer
      security.

   Small Amount of Memory:

      Microcontrollers embedded in IoT devices are often equipped with
      small amount of RAM and flash memory, which places limitations
      what kind of processing can be performed and how much code can be
      put on those devices.  To reduce code size fewer and smaller
      protocol implementations can be put on the firmware of such a
      device.  In this case, CoAP may be used instead of HTTP, symmetric
      key cryptography instead of public key cryptography, and CBOR
      instead of JSON.  Authentication and key establishment protocol,
      e.g. the DTLS handshake, in comparison with assisted key
      establishment also has an impact on memory and code.

   User Interface Limitations:

      Protecting access to resources is both an important security as
      well as privacy feature.  End users and enterprise customers do
      not want to give access to the data collected by their IoT device
      or to functions it may offer to third parties.  Since the
      classical approach of requesting permissions from end users via a
      rich user interface does not work in many IoT deployment scenarios
      these functions need to be delegated to user controlled devices
      that are better suitable for such tasks, such as smart phones and
      tablets.
   Communication Constraints:

      In certain constrained settings an IoT device may not be able to
      communicate with a given device at all times.  Devices may be
      sleeping, or just disconnected from the Internet because of
      general lack of connectivity in the area, for cost reasons, or for
      security reasons, e.g. to avoid an entry point for Denial-of-
      Service attacks.

      The communication interactions this framework builds upon (as
      shown graphically in Figure 1) may be accomplished using a variety
      of different protocols, and not all parts of the message flow are
      used in all applications due to the communication constraints.
      While we envision deployments to make use of CoAP we explicitly
      want to support HTTP, HTTP/2 or specific protocols, such as
      Bluetooth Smart communication, which does not necessarily use IP.
      The latter raises the need for application layer security over the
      various interfaces.

Appendix B.  Roles and Responsibilites -- a Checklist

   Resource Owner

      *  Make sure that the RS is registered at the AS.
      *  Make sure that clients can discover the AS which is in charge
         of the RS.
      *  Make sure that the AS has the necessary, up-to-date, access
         control policies for the RS.

   Requesting Party

      *  Make sure that the client is provisioned the necessary
         credentials to authenticate to the AS.
      *  Make sure that the client is configured to follow the security
         requirements of the Requesting Party, when issuing requests
         (e.g. minimum communication security requirements, trust
         anchors).
      *  Register the client at the AS.

   Authorization Server

      *  Register RS and manage corresponding security contexts.
      *  Register clients and including authentication credentials.
      *  Allow Resource Onwers Owners to configure and update access control
         policies related to their registered RS'
      *  Expose a service that allows clients to request tokens.
      *  Authenticate clients that wishes to request a token.
      *  Process a token requests against the authorization policies
         configured for the RS.
      *  Expose a service that allows RS's to submit token introspection
         requests.
      *  Authenticate RS's that wishes to get an introspection response.
      *  Process token introspection requests.
      *  Optionally: Handle token revocation.

   Client

      *  Discover the AS in charge of the RS that is to be targeted with
         a request.
      *  Submit the token request (A).

         +  Authenticate towards the AS.
         +  Specify which RS, which resource(s), and which action(s) the
            request(s) will target.
         +  Specify preferences for communication security
         +  If raw public key (rpk) or certificate is used, make sure
            the AS has the right rpk or certificate for this client.
      *  Process the access token and client information (B)

         +  Check that the token has the right format (e.g.  CWT).
         +  Check that the client information provides the necessary
            security parameters (e.g.  PoP key, information on
            communication security protocols supported by the RS).
      *  Send the token and request to the RS (C)

         +  Authenticate towards the RS (this could coincide with the
            proof of possession process).
         +  Transmit the token as specified by the AS (default is to an
            authorization information resource, alternative options are
            as a CoAP option or in the DTLS handshake).
         +  Perform the proof-of-possession procedure as specified for
            the type of used token (this may already have been taken
            care of through through the authentication procedure).
      *  Process the RS response (F) requirements of the Requesting
         Party, when issuing requests (e.g. minimum communication
         security requirements, trust anchors).
      *  Register the client at the AS.

   Resource Server

      *  Expose a way to submit access tokens.
      *  Process an access token.

         +  Verify the token is from the right AS.
         +  Verify that the token applies to this RS.
         +  Check that the token has not expired (if the token provides
            expiration information).
         +  Check the token's integrity.
         +  Store the token so that it can be retrieved in the context
            of a matching request.
      *  Process a request.

         +  Set up communication security with the client.

         +  Authenticate the client.
         +  Match the client against existing tokens.
         +  Check that tokens belonging to the client actually authorize
            the requested action.
         +  Optionally: Check that the matching tokens are still valid
            (if this is possible.
      *  Send a response following the agreed upon communication
         security.

Appendix C.  Deployment Examples

   There is a large variety of IoT deployments, as is indicated in
   Appendix A, and this section highlights a few common variants.  This
   section is not normative but illustrates how the framework can be
   applied.

   For each of the deployment variants there are a number of possible
   security setups between clients, resource servers and authorization
   servers.  The main focus in the following subsections is on how
   authorization of a client request for a resource hosted by a RS is
   performed.  This requires the authentication procedure).

      *  Process the RS response (F) requirements security of the Requesting
         Party, when issuing requests (e.g. minimum communication
         security requirements, trust anchors).

      *  Register and
   responses between the client at clients and the AS.

   Resource Server

      *  Expose a way RS to submit access tokens.

      *  Process an access token.

         +  Verify the token consider.

   Note: CBOR diagnostic notation is from used for examples of requests and
   responses.

C.1.  Local Token Validation

   In this scenario we consider the right AS.

         +  Verify that case where the token applies resource server is
   offline, i.e. it is not connected to this RS.

         +  Check that the token has not expired (if AS at the token provides
            expiration information).

         +  Check time of the token's integrity.

         +  Store access
   request.  This access procedure involves steps A, B, C, and F of
   Figure 1.

   Since the resource server must be able to verify the access token so that it can
   locally, self-contained access tokens must be retrieved in used.

   This example shows the context
            of interactions between a matching request.

      *  Process client, the
   authorization server and a request.

         +  Set up temperature sensor acting as a resource
   server.  Message exchanges A and B are shown in Figure 17.

      A: The client first generates a public-private key pair used for
      communication security with the client.

         +  Authenticate RS.
      The client sends the POST request to /token at the AS.  The
      request contains the public key of the client and the Audience
      parameter set to "tempSensorInLivingRoom", a value that the
      temperature sensor identifies itself with.  The AS evaluates the client.

         +  Match
      request and authorizes the client against existing tokens.

         +  Check that tokens belonging to access the resource.

      B: The AS responds with a PoP token and client actually authorize information.  The
      PoP token contains the requested action.

         +  Optionally: Check that public key of the matching tokens are still valid
            (if client, and the client
      information contains the public key of the RS.  For communication
      security this is possible.

      *  Send example uses DTLS RawPublicKey between the client
      and the RS.  The issued token will have a response following short validity time,
      i.e. 'exp' close to 'iat', to protect the agreed upon communication
         security.

Appendix C.  Optimizations

   This section sketches some potential optimizations RS from replay attacks
      since it, that cannot do introspection to check the presented
   solution.

   Access tokens current
      validity.  The token in DTLS handshake

      In includes the case of CSP=DTLS/TLS, claim "aif" with the authorized
      access token provisioning
      exchange in step C that an owner of the protocol may be embedded in temperature device can enjoy.  The
      'aif' claim, issued by the security
      handshake.  Different solutions are possible, where one
      standardized method would be AS, informs the use RS that the owner of
      the TLS supplemental data
      extension [RFC4680] for transferring token, that can prove the access token.

   Reference token and introspection

      In case possession of introspection it may be beneficial to utilize access
      tokens which are not self-contained (also known as "reference
      tokens") that are used a key is authorized to lookup detailed information about
      make a GET request against the
      authorization.  The RS uses /temperature resource and a POST
      request on the introspection message exchange not
      only for validating token claims, but also for obtaining /firmware resource.
      Note: In this example we assume that the client knows what
      resource it wants to access, and is therefore able to request
      specific audience and scope claims
      that potentially were not known at the time when for the access token
      was issued.

      A reference token can be made much more compact than a self- token.

            Authorization
     Client    Server
       |         |
       |         |
   A:  +-------->| Header: POST (Code=0.02)
       |  POST   | Uri-Path:"token"
       |         | Content-Type: application/cbor
       |         | Payload: <Request-Payload>
       |         |
   B:  |<--------+ Header: 2.05 Content
       |  2.05   | Content-Type: application/cbor
       |         | Payload: <Response-Payload>
       |         |

      Figure 17: Token Request and Response Using Client Credentials.

   The information contained token, since it does not need to contain any of claims
      that it represents.  This could be very useful in particular if the client is constrained Request-Payload and offline most of the time.

   Reference token in CoAP option

      While large access tokens must be sent Response-
   Payload is shown in CoAP payload, if Figure 18.

   Request-Payload :
   {
     "grant_type" : "client_credentials",
     "aud" : "tempSensorInLivingRoom",
     "client_id" : "myclient",
     "client_secret" : "qwerty"
   }

   Response-Payload :
   {
     "access_token" : b64'SlAV32hkKG ...',
     "token_type" : "pop",
     "csp" : "DTLS",
     "cnf" : {
       "COSE_Key" : {
         "kid" : b64'c29tZSBwdWJsaWMga2V5IGlk',
         "kty" : "EC",
         "crv" : "P-256",
         "x"   : b64'MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4',
         "y"   : b64'4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM'
       }
     }
   }

             Figure 18: Request and Response Payload Details.

   The content of the access token is known to be shown in Figure 19.

   {
     "aud" : "tempSensorInLivingRoom",
     "iat" : "1360189224",
     "exp" : "1360289224",
     "aif" :  [["/temperature", 0], ["/firmware", 2]],
     "cnf" : {
       "jwk" : {
         "kid" : b64'1Bg8vub9tLe1gHMzV76e8',
         "kty" : "EC",
         "crv" : "P-256",
         "x" : b64'f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU',
         "y" : b64'x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0'
       }
     }
   }

        Figure 19: Access Token including Public Key of a certain limited size, for example the Client.

   Messages C and F are shown in the case of a reference token, Figure 20 - Figure 21.

      C: The client then it would be favorable to
      combine sends the access PoP token provisioning request with to the /authz-info resource
      request to
      at the RS.

      One way to achieve this  This is to define a new plain CoAP option for
      carrying reference tokens, called "Ref-Token" as shown in request, i.e. no transport or
      application layer security between client and RS, since the
      example token
      is integrity protected between AS and RS.  The RS verifies that
      the PoP token was created by a known and trusted AS, is valid, and
      responds to the client.  The RS caches the security context
      together with authorization information about this client
      contained in Figure 28. the PoP token.

              Resource
    Client     Server
       |         |
   C:  +-------->| Header: PUT POST (Code=0.02)
       | PUT  POST   | Ref-Token:SlAV32hkKG Uri-Path:"authz-info"
       |         | Object-Security: Payload: SlAV32hkKG ...
       |         |    <seq>,<cid>,[Uri-Path:"lock", 1],<tag>)
       |<--------+ Header: 2.01 Created
       |  2.01   |
       .         .
       .         .
       .         .
       |         |

                Figure 20: Access Token provisioning to RS
      The client and the RS runs the DTLS handshake using the raw public
      keys established in step B and C.
      The client sends the CoAP request GET to /temperature on RS over
      DTLS.  The RS verifies that the request is authorized, based on
      previously established security context.
      F:  |<--------+ The RS responds with a resource representation over DTLS.

              Resource
    Client     Server
       |         |
       |<=======>| DTLS Connection Establishment
       |         |   using Raw Public Keys
       |         |
       +-------->| Header: 2.04 Changed GET (Code=0.01)
       | 2.04 GET     | Object-Security: Uri-Path: "temperature"
       |         |    (<seq>,<cid>,,<tag>)
       |         |

                 Figure 28: Reference Token in CoAP Option

Appendix D.  CoAP and CBOR profiles for OAuth 2.0

   Many IoT devices can support OAuth 2.0 without any additional
   extensions, but for certain constrained settings additional profiling
   is needed.
       |         |
   F:  |<--------+ Header: 2.05 Content
       | 2.05    | Payload: <sensor value>
       |         |

        Figure 21: Resource Request and Response protected by DTLS.

C.2.  Introspection Aided Token Validation

   In this appendix deployment scenario we define CoAP resources for assume that a client is not be able to
   access the HTTP
   based AS at the time of the access request.  Since the RS is,
   however, connected to the back-end infrastructure it can make use of
   token introspection.  This access procedure involves steps A-F of
   Figure 1, but assumes steps A and introspection endpoints used in vanilla OAuth 2.0.
   We also define B have been carried out during a CBOR alternative
   phase when the client had connectivity to AS.

   Since the JSON and form based POST
   structures used in HTTP.

D.1.  Profile client is assumed to be offline, at least for Token resource

   The a certain
   period of time, a pre-provisioned access token has to be long-lived.
   The resource is used by the client server may use its online connectivity to obtain an validate the
   access token by
   presenting its with the authorization grant or client credentials to server, which is shown in the
   /token resource
   example below.

   In the AS.

D.1.1.  Token Request

   The example we show the interactions between an offline client makes
   (key fob), a request to the token resource by sending server (online lock), and an authorization
   server.  We assume that there is a CBOR
   structure with provisioning step where the following attributes.

   grant_type:

      REQUIRED.  The grant type, "code", "client_credentials",
      "password" or others.

   client_id:

      OPTIONAL.  The client identifier issued
   has access to the holder of the token
      (client or RS) during AS.  This corresponds to message exchanges A and B
   which are shown in Figure 22.

   Authorization consent from the registration process.

   client_secret:

      OPTIONAL.  The client secret.

   scope:

      OPTIONAL.  The scope of resource owner can be pre-configured,
   but it can also be provided via an interactive flow with the access request as described by
      Section 3.1.

   aud:

      OPTIONAL.  Service-specific string identifier or list resource
   owner.  An example of string
      identifiers representing the intended audience for this token, as
      defined in [I-D.wahlstroem-ace-cbor-web-token].

   alg:

      OPTIONAL.  The value in for the 'alg' parameter together key fob case could be that the
   resource owner has a connected car, he buys a generic key that he
   wants to use with value
      from the 'token_type' parameter allow car.  To authorize the client key fob he connects it
   to indicate his computer that then provides the
      supported algorithms UI for a given token type.

   key:

      OPTIONAL.  This field contains information about the public device.  After that
   OAuth 2.0 implicit flow can used to authorize the key for his car at
   the client would like to bind to the access token in car manufacturers AS.

   Note: In this example the COSE Key
      Structure format.

   The parameters defined above use client does not know the following CBOR major types.

        /-----------+--------------+-----------------------\
        | Value     | Major Type   | Key                   |
        |-----------+--------------+-----------------------|
        | 0         | 0            | grant_type            |
        | 1         | 0            | client_id             |
        | 2         | 0            | client_secret         |
        | 3         | 0            | scope                 |
        | 4         | 0            | aud                   |
        | 5         | 0            | alg                   |
        | 6         | 0            | key                   |
        \-----------+--------------+-----------------------/

              Figure 29: CBOR mappings exact door it will
   be used in token requests

D.1.2.  Token Response

   The AS responds by sending a CBOR structure with the following
   attributes.

   access_token:

      REQUIRED.  The to access token issued by the authorization server.

   token_type:

      REQUIRED.  The type of the token issued. "pop" is recommended.

   key:

      REQUIRED, if symmetric key cryptography is used.  A COSE Key
      Structure containing since the symmetric proof of possession key.  The
      members token request is not send at the time of
   access.  So the structure scope and audience parameters is set quite wide to
   start with and new values different form the original once can be found in section 7.1 of
      [I-D.ietf-cose-msg].

   csp:

      REQUIRED.  Information on what communication protocol
   returned from introspection later on.

      A: The client sends the request using POST to use in /token at AS.  The
      request contains the communication between Audience parameter set to "PACS1337" (PACS,
      Physical Access System), a value the client and that the RS.  Details online door in
      question identifies itself with.  The AS generates an access token
      as on
      possible values opaque string, which it can be found in Section 5.1.

   scope:

      OPTIONAL, if identical match to the scope requested by the client;
      otherwise, REQUIRED.

   alg:

      OPTIONAL. specific client, a
      targeted audience and a symmetric key.
      B: The 'alg' parameter provides further information about AS responds with the algorithm, such as whether an access token and client
      information, the latter containing a symmetric or an asymmetric
      crypto-system is used. key.  Communication
      security between C and RS will be DTLS and PreSharedKey.  The parameters defined above use PoP
      key being used as the following CBOR major types.

         /-----------+--------------+-----------------------\
         | Value     | Major Type   | Key                   |
         |-----------+--------------+-----------------------|
         | 0         | 0            | access_token          |
         | 1         | 0 PreSharedKey.

            Authorization
    Client     Server
       | token_type         |
       | 2         | 0
   A:  +-------->| Header: POST (Code=0.02)
       | key  POST   | Uri-Path:"token"
       | 3         | 0 Content-Type: application/cbor
       | csp         | Payload: <Request-Payload>
       | 4         | 0
   B:  |<--------+ Header: 2.05 Content
       | scope         | Content-Type: application/cbor
       | 5  2.05   | 0 Payload: <Response-Payload>
       | alg         |
         \-----------+--------------+-----------------------/

      Figure 30: CBOR mappings used in token responses

D.2.  CoAP Profile for OAuth Introspection

   This section defines a way 22: Token Request and Response using Client Credentials.

   The information contained in the Request-Payload and the Response-
   Payload is shown in Figure 23.

   Request-Payload:
   {
     "grant_type" : "client_credentials",
     "aud" : "lockOfDoor4711",
     "client_id" : "keyfob",
     "client_secret" : "qwerty"
   }

   Response-Payload:
   {
     "access_token" : b64'SlAV32hkKG ...'
     "token_type" : "pop",
     "csp" : "DTLS",
     "cnf" : {
       "COSE_Key" : {
         "kid" : b64'c29tZSBwdWJsaWMga2V5IGlk',
         "kty" : "oct",
         "alg" : "HS256",
         "k": b64'ZoRSOrFzN_FzUA5XKMYoVHyzff5oRJxl-IXRtztJ6uE'
       }
     }
   }

           Figure 23: Request and Response Payload for a holder of C offline

   The access tokens, mainly
   clients and RS's, to get metadata like validity status, claims and
   scopes found token in access token.  The OAuth Token Introspection
   specification [I-D.ietf-oauth-introspection] defines a way to
   validate this case is just an opaque string referencing
   the authorization information at the AS.

      C: Next, the client POSTs the access token using HTTP POST or HTTP GET.  This document reuses to the work done /authz-info
      resource in the OAuth Token Introspection and defines RS.  This is a mapping
   of plain CoAP request, i.e. no DTLS
      between client and RS.  Since the request token is an opaque string, the
      RS cannot verify it on its own, and response to CoAP [RFC7252] thus defers to be used by
   constrained devices.

D.2.1.  Introspection Request respond the
      client with a status code until after step E.
      D: The RS forwards the token holder makes a request to the Introspection CoAP /introspect resource
   by sending on the
      AS.  Introspection assumes a CBOR structure with secure connection between the following attributes.

   token:

      REQUIRED.  The string value AS and
      the RS, e.g. using transport of application layer security, which
      is not detailed in this example.
      E: The AS provides the introspection response containing
      parameters about the token.

   resource_id:

      OPTIONAL.  A service-specific string identifying  This includes the resource confirmation key
      (cnf) parameter that allows the client doing the introspection is asking about.

   client_id:

      OPTIONAL.  The client identifier issued RS to verify the holder of the token
      (client or RS) during client's proof of
      possession in step F.
      After receiving message E, the registration process.

   client_secret:

      OPTIONAL.  The client secret.

   The parameters defined above use RS responds to the following CBOR major types:

          /-----------+--------------+-----------------------\ client's POST in
      step C with Code 2.01 Created.

              Resource
     Client    Server
       | Value         | Major Type
   C:  +-------->| Header: POST (T=CON, Code=0.02)
       | Key  POST   |
          |-----------+--------------+-----------------------| Uri-Path:"authz-info"
       | 0         | 0 Content-Type: "application/cbor"
       | token         | Payload: b64'SlAV32hkKG ...''
       | 1         | 0
       | resource_id         |     Authorization
       | 2         | 0       Server
       | client_id         |          | 3
   D:  | 0         +--------->| Header: POST (Code=0.02)
       | client_secret         |
          \-----------+--------------+-----------------------/

    Figure 31: CBOR Mappings to Token Introspection Request Parameters.

D.2.2.  Introspection Response

   If the introspection request is valid and authorized, the
   authorization server returns a CoAP message with the response encoded
   as a CBOR structure in the payload of the message.  If the request
   failed client authentication or is invalid, the authorization server
   returns an error response using the CoAP 4.00 'Bad Request' response
   code.

   The JSON structure in the payload response includes the top-level
   members defined in Section 2.2 in the OAuth Token Introspection
   specification [I-D.ietf-oauth-introspection].  It is RECOMMENDED to
   only return the 'active' attribute considering constrained nature of
   CoAP client and server networks.

   Introspection responses in CBOR use the following mappings:

   active:

      REQUIRED.  The active key is an indicator of whether or not the
      presented token is currently active.  The specifics of a token's
      "active" state will vary depending on the implementation of the
      authorization server, and the information it keeps about its
      tokens, but a "true" value return  POST    | Uri-Path: "introspect"
       |         |          | Content-Type: "application/cbor"
       |         |          | Payload: <Request-Payload>
       |         |          |
   E:  |         |<---------+ Header: 2.05 Content
       |         |  2.05    | Content-Type: "application/cbor"
       |         |          | Payload: <Response-Payload>
       |         |          |
       |         |
   C:  |<--------+ Header: 2.01 Created
       |  2.01   |
       |         |

               Figure 24: Token Introspection for C offline
      The information contained in the "active" property will
      generally indicate that a given token has been issued by this
      authorization server, has not been revoked by the resource owner,
      and is within its given time window of validity (e.g., after its
      issuance time Request-Payload and before its expiration time).

   scope:

      OPTIONAL.  A string containing a space-separated list of scopes
      associated with this token, in the format described Response-
      Payload is shown in Section 3.3
      of OAuth 2.0 [RFC6749].

   client_id:

      OPTIONAL.  Client identifier Figure 25.

   Request-Payload:
   {
     "token" : b64'SlAV32hkKG...',
     "client_id" : "FrontDoor",
     "client_secret" : "ytrewq"
   }

   Response-Payload:
   {
     "active" : true,
     "aud" : "lockOfDoor4711",
     "scope" : "open, close",
     "iat" : 1311280970,
     "cnf" : {
       "kid" : b64'JDLUhTMjU2IiwiY3R5Ijoi ...'
     }
   }

         Figure 25: Request and Response Payload for the Introspection

      The client that requested this
      token.

   username:

      OPTIONAL.  Human-readable identifier for the resource owner who
      authorized this token.

   token_type:

      OPTIONAL.  Type of uses the token as defined in Section 5.1 of OAuth
      2.0 [RFC6749] or symmetric PoP token.

   exp:

      OPTIONAL.  Integer timestamp, measured in the number of seconds
      since January 1 1970 UTC, indicating when this token will expire,
      as defined in CWT [I-D.wahlstroem-ace-cbor-web-token].

   iat:

      OPTIONAL.  Integer timestamp, measured in the number of seconds
      since January 1 1970 UTC, indicating when this token will expire,
      as defined in CWT [I-D.wahlstroem-ace-cbor-web-token].

   nbf:

      OPTIONAL.  Integer timestamp, measured in the number of seconds
      since January 1 1970 UTC, indicating when this token will expire,
      as defined in CWT [I-D.wahlstroem-ace-cbor-web-token].

   sub:

      OPTIONAL.  Subject of the token, as defined in CWT
      [I-D.wahlstroem-ace-cbor-web-token].  Usually key to establish a machine-readable
      identifier of the resource owner who authorized this token.

   aud:

      OPTIONAL.  Service-specific string identifier or list of string
      identifiers representing DTLS
      PreSharedKey secure connection to the intended audience for this token, as
      defined in CWT [I-D.wahlstroem-ace-cbor-web-token].

   iss:

      OPTIONAL.  String representing RS.  The CoAP request PUT is
      sent to the issuer uri-path /state on RS changing state of this token, as
      defined in CWT [I-D.wahlstroem-ace-cbor-web-token].

   cti:

      OPTIONAL.  String identifier for the token, as defined in CWT
      [I-D.wahlstroem-ace-cbor-web-token] door to
      locked.
      F: The parameters defined above use RS responds with a appropriate over the following CBOR major types:

   /-----------+--------------+-----------------------\
   | Value     | Major Type   | Key                   |
   |-----------+--------------+-----------------------|
   | 0         | 0            | active                |
   | 1         | 0            | scopes                |
   | 2         | 0            | client_id             |
   | 3         | 0            | username              |
   | 4         | 0            | token_type            |
   | 5         | 0            | exp                   |
   | 6         | 0            | iat                   |
   | 7         | 0            | nbf                   | secure DTLS
      channel.

              Resource
     Client    Server
       | 8         | 0
       |<=======>| DTLS Connection Establishment
       | sub         |   using Pre Shared Key
       | 9         | 0
       +-------->| Header: PUT (Code=0.03)
       | aud PUT     | Uri-Path: "state"
       | 10         | 0 Payload: <new state for the lock>
       | iss         |
   F:  |<--------+ Header: 2.04 Changed
       | 11 2.04    | 0 Payload: <new state for the lock>
       | cti         |
   \-----------+--------------+-----------------------/

       Figure 32: CBOR Mappings to Token Introspection Response Parameters. 26: Resource request and response protected by OSCOAP

Appendix E. D.  Document Updates

E.1.
D.1.  Version -01 to -02

   o  Restructured to remove communication security parts.  These shall
      now be defined in profiles.
   o  Restructured section 5 to create new sections on the OAuth
      endpoints /token, /introspect and /authz-info.
   o  Pulled in material from draft-ietf-oauth-pop-key-distribution in
      order to define proof-of-possession key distribution.
   o  Introduced the 'cnf' parameter as defined in RFC7800 to reference
      or transport keys used for proof of posession.
   o  Introduced the 'client-token' to transport client information from
      the AS to the client via the RS in conjunction with introspection.
   o  Expanded the IANA section to define parameters for token request,
      introspection and CWT claims.
   o  Moved deployment scenarios to the appendix as examples.

D.2.  Version -00 to -01

   o  Changed 5.1. from "Communication Security Protocol" to "Client
      Information".
   o  Major rewrite of 5.1 to clarify the information exchanged between
      C and AS in the PoP token request profile for IoT.

      *  Allow the client to indicate preferences for the communication
         security protocol.
      *  Defined the term "Client Information" for the additional
         information returned to the client in addition to the access
         token.
      *  Require that the messages between AS and client are secured,
         either with (D)TLS or with COSE_Encrypted wrappers.
      *  Removed dependency on OSCoAP and added generic text about
         object security instead.
      *  Defined the "rpk" parameter in the client information to
         transmit the raw public key of the RS from AS to client.
      *  (D)TLS MUST use the PoP key in the handshake (either as PSK or
         as client RPK with client authentication).
      *  Defined the use of x5c, x5t and x5tS256 parameters when a
         client certificate is used for proof of possession.
      *  Defined "tktn" parameter for signaling for how to tranfer transfer the
         access token.
   o  Added 5.2. the CoAP Access-Token option for transfering transferring access
      tokens in messages that do not have payload.
   o  5.3.2.  Defined success and error responses from the RS when
      receiving an access token.
   o  5.6.:Added section giving guidance on how to handle token
      expiration in the absence of reliable time.
   o  Appendix B Added list of roles and responsibilities for C, AS and
      RS.

Authors' Addresses

   Ludwig Seitz
   SICS
   Scheelevaegen 17
   Lund  223 70
   SWEDEN

   Email: ludwig@sics.se

   Goeran Selander
   Ericsson
   Faroegatan 6
   Kista  164 80
   SWEDEN

   Email: goran.selander@ericsson.com

   Erik Wahlstroem
   Nexus Technology
   Telefonvagen 26
   Hagersten  126 26
   Sweden

   Email: erik.wahlstrom@nexusgroup.com

   Samuel Erdtman
   Nexus Technology
   Telefonvagen 26
   Hagersten  126 26
   Spotify AB
   Birger Jarlsgatan 61, 4tr
   Stockholm  113 56
   Sweden

   Email: samuel.erdtman@nexusgroup.com erdtman@spotify.com

   Hannes Tschofenig
   ARM Ltd.
   Hall in Tirol  6060
   Austria

   Email: Hannes.Tschofenig@arm.com