<?xml version="1.0" encoding="utf-8"?>
<?xml-model href="rfc7991bis.rnc"?>
<!DOCTYPE rfc [
    <!ENTITY nbsp    "&#160;">
    <!ENTITY zwsp   "&#8203;">
    <!ENTITY nbhy   "&#8209;">
    <!ENTITY wj     "&#8288;">
    ]>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude"
     ipr="trust200902" submissionType="IETF" category="std" version="3" consensus="true"
     docName="draft-blahaj-grow-rpki-oauth-00">
  <front>
    <title abbrev="RPKI Attested OIDC">Attesting the Identities of Parties in OpenID Connect (OIDC) using the Resource
      Public Key Infrastructure (RPKI)
    </title>
    <seriesInfo name="Internet-Draft" status="standard"
                value="draft-blahaj-grow-rpki-oauth-00"/>
    <author fullname="Q Misell" initials="Q" surname="Misell">
      <organization abbrev="AS207960">AS207960 Cyfyngedig</organization>
      <address>
        <postal>
          <street>13 Pen-y-lan Terrace</street>
          <city>Caerdydd</city>
          <code>CF23 9EU</code>
          <country>United Kingdom</country>
        </postal>
        <email>q@as207960.net</email>
        <email>q@magicalcodewit.ch</email>
        <uri>https://magicalcodewit.ch</uri>
      </address>
    </author>
    <area>rtg</area>
    <workgroup>grow</workgroup>
    <abstract>
      <t>The Peering API currently under discussion in the GROW Working Group does not provide a standardised
        mechanism to authenticate parties engaged in the Peering API. This document specifies a method to attest
        as to the identities of parties in an OpenID Connect (OIDC) exchange, binding the authentication flow
        to agents of ASNs.
      </t>
    </abstract>

    <note removeInRFC="true">
      <name>Discussion</name>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.molgen.mpg.de/q/rpki-peering-api-discovery"/>.
      </t>
    </note>
  </front>

  <middle>
    <section>
      <name>Introduction</name>
      <t>An API allowing programmatic configuration of BGP peering sessions is defined in
        <xref target="I-D.ramseyer-grow-peering-api"/>. The API defined in that document does not provide a standardised
        mechanism to authenticate parties engaged in the Peering API. To this end, this documents defines
        extensions to OpenID Connect to allow verifying an AS's Identity Provider (IdP), its Relying Parties (RP),
        and agents thereof.
      </t>

      <section>
        <name>Requirements Language</name>
        <t>The key words <bcp14>MUST</bcp14>, <bcp14>MUST NOT</bcp14>, <bcp14>REQUIRED</bcp14>,
          <bcp14>SHALL</bcp14>, <bcp14>SHALL NOT</bcp14>, <bcp14>SHOULD</bcp14>, <bcp14>SHOULD NOT</bcp14>,
          <bcp14>RECOMMENDED</bcp14>, <bcp14>NOT RECOMMENDED</bcp14>, <bcp14>MAY</bcp14>, and
          <bcp14>OPTIONAL</bcp14>
          in this document are to be interpreted as described in
          <xref target="BCP14"/>
          when, and only when, they appear in all capitals, as shown here.
        </t>
      </section>
    </section>

    <section>
      <name>Problem statement</name>
      <t>The Peering API currently under discussion at the Global Routing Operations Working Group
        <xref target="I-D.ramseyer-grow-peering-api"/>is in need of a way to authenticate parties involved in
        such API exchanges. The draft, as it is currently conceived, relies on the OAuth service provided
        by PeeringDB to authenticate Autonomous Systems and their agents. It is undesirable, in the scope of an IETF
        document to rely on such external parties as a core part of the specification. We therefore set out to
        define an alternative OAuth federation mechanism based on the RPKI<xref target="RFC6480"/>, one that
        is not tied to one entity, and is usable by anyone within the Internet ecosystem.
      </t>

      <t>The reasons for adapting OAuth and not defining a new authentication mechanism are twofold;
        firstly, OAuth is a familiar protocol for authentication in application development, and many libraries
        exist that support it, secondly, and perhaps more crucially, is the large extant deployment of corporate IdPs
        using OAuth. From discussions from the proponents of the Peering API, the need to identify not only the
        Autonomous System from which the request originates, but in addition <em>which agent</em> of the AS has made
        the request. That is, it would be beneficial be able to say not only that AS64496 submitted a peering request,
        but that John of AS64496 did so.
      </t>

      <t>Given the prevalence of corporate IdPs, specifically those that support OAuth, it seems fitting to extend
        this to also provide authentication to a peering API. OAuth already provides the dynamic client registration,
        and token introspection, required to integrate a third party service with a corporate IdP. This document
        serves to build upon this by creating a tie between resources attested in the RPKI and their IdPs and RPs.
      </t>

      <t>In addition to the peering API, there likely will be other APIs one may wish to establish between ASNs,
        and this OAuth extensions provides a natual basis for them.
      </t>
    </section>

    <section>
      <name>Terminology</name>
      <t>For brevity, within this document the following terminology is used</t>
      <dl>
        <dt>Service Provider</dt>
        <dd>An AS offering a (e.g. REST API) service to other ASes.</dd>
        <dt>Consumer</dt>
        <dd>An AS consuming the service provided by the Service Provider.</dd>
      </dl>
    </section>

    <section>
      <name>Endpoint Discovery</name>
      <t>All endpoints required for this protocol to function not defined herein, are to be discovered
        via OpenID Connect Discovery
        <xref target="OpenID.Discovery"/>
      </t>
    </section>

    <section>
      <name>Extensions to IdP Metadata</name>
      <t>An RP must be able to verify that an IdP is allowed to issue authorization tokens for resources. To this end,
        the JWK Key Set presented in the OpenID Connect Discovery <tt>jwks_url</tt>
        <bcp14>MUST</bcp14> be an
        RPKI Attested JWK Set. That is, the JWK used to sign the JWTs used in an OAuth exchange is itself signed
        using the RPKI, attesting that this IdP is authoritative for Internet resources. An IdP is considered
        authoritative for all resources in the EE Certificate contained in the RSM used to attest the JWK Key Set.
      </t>
      <t>An RP <bcp14>SHOULD</bcp14> regularly check for updates to the JWK Key Set, and its associated attestation,
        and <bcp14>MUST</bcp14> not cache the attestation and its attested resources beyond the end of the
        validity of the RSM.
      </t>
    </section>

    <section>
      <name>Extensions to Dynamic Client Registration</name>
      <t>Once the RP of a Service Provider is aware which IdP will be used by the Consumer to authenticate to it,
        it must register with that IdP, if it hasn't done so already. This allows it to be issued an authentication
        token scoped to it, and to engage in Token Introspection
        <xref target="OpenID.Core"/>
        to verify tokens given
        in API requests.
      </t>
      <t>The manner in which the base URL of an IdP is communicated to an RP is out of the scope of this document,
        and is intended to be defined in subservient documents.
      </t>
      <t>The RP submits an OIDC Dynamic Client Registration request to the Consumer's IdP
        <xref target="OpenID.Registration"/>, containing any well-known scopes as defined in subservient specifications
        required for which services the RP provides. Updates to these scopes in future may be made via the Client
        Configuration Endpoint.
      </t>
      <t>Such that the Idp can validate the identity of the RP making the registration request, the request
        <bcp14>MUST</bcp14>
        be signed using HTTP signatures<xref target="RFC9421"/>.
        The signature <tt>keyid</tt> parameter <bcp14>MUST</bcp14> be URL to an RPKI Attested JWK Set.
        The fragment of such a URL is used to identify the exact <tt>kid</tt> used to sign the request.
      </t>
      <t>This signature <bcp14>MUST</bcp14> be over at least the following components:
      </t>
      <ul>
        <li>@method</li>
        <li>@target-uri</li>
        <li>content-digest</li>
      </ul>
      <t>The body of the HTTP request <bcp14>MUST</bcp14> be included in the signature by the use of a HTTP Digest
        <xref target="RFC9530"/>.
      </t>
      <t>This signature <bcp14>MUST</bcp14> contain at least the following parameters:
      </t>
      <ul>
        <li>@created</li>
        <li>@nonce</li>
        <li>@keyid</li>
      </ul>
      <t>The response to such a registration request need not be signed, as the identity of the IdP is validated via
        its TLS domain identity and its attested discovery metadata.
      </t>
    </section>

    <section>
      <name>RPKI Attested JWK Set</name>
      <t>An RPKI Attested JWK Set is as a normal JWK Set<xref target="RFC7517"/>, that <bcp14>MUST</bcp14> contain an
        <tt>rpki_attestation</tt>
        parameter. The construction of such a parameter is the base64url encoding
        <xref target="RFC7515"/>
        of an RPKI
        Signed Message over the JWK Set without the <tt>rpki_attestation</tt> parameter, using the JWK Thumbprint
        JSON hash input calculation algorithm<xref target="RFC7638"/>.
      </t>
      <t>The audience field for such an RSM <bcp14>MUST</bcp14> be the Global Audience (<tt>1.3.6.1.5.5.TBD.0.0</tt>).
      </t>
      <t>The purpose field for such an RSM <bcp14>MUST</bcp14> be the OAuth Attestation Audience (<tt>
        1.3.6.1.5.5.TBD.1.1</tt>).
      </t>
    </section>

    <section>
      <name>Security Considerations</name>
      <t>The security considerations of this protocol have been left until the protocol proper is further refined.</t>
    </section>

    <section anchor="iana">
      <name>IANA Considerations</name>
      <section>
        <name>RPKI Signed Message well-known purposes</name>
        <t>The IANA is requested to allocate a new OID under the
          "RPKI Signed Message well-known purposes" registry:
        </t>
        <table>
          <thead>
            <tr>
              <th>Decimal</th>
              <th>Description</th>
              <th>References</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>1</td>
              <td>OAuth Attestation</td>
              <td>This document</td>
            </tr>
          </tbody>
        </table>
      </section>
    </section>
  </middle>

  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>

        <referencegroup anchor="BCP14" target="https://www.rfc-editor.org/info/bcp14">
          <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.2119.xml"/>
          <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.8174.xml"/>
        </referencegroup>

        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.6480.xml"/>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.7517.xml"/>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.7515.xml"/>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.7638.xml"/>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.9421.xml"/>
        <xi:include href="https://www.rfc-editor.org/refs/bibxml/reference.RFC.9530.xml"/>

        <xi:include href="https://datatracker.ietf.org/doc/bibxml3/draft-ramseyer-grow-peering-api-05.xml"/>

        <reference anchor="OpenID.Core" target="https://openid.net/specs/openid-connect-core-1_0.html">
          <front>
            <title>OpenID Connect Core 1.0 incorporating errata set 2</title>
            <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
              <organization showOnFrontPage="true">NAT.Consulting</organization>
            </author>
            <author fullname="John Bradley" initials="J." surname="Bradley">
              <organization showOnFrontPage="true">Yubico</organization>
            </author>
            <author fullname="Mike Jones" initials="M." surname="Jones">
              <organization showOnFrontPage="true">Self-Issued Consulting</organization>
            </author>
            <author fullname="Breno de Medeiros" initials="B." surname="de Medeiros">
              <organization showOnFrontPage="true">Google</organization>
            </author>
            <author fullname="Chuck Mortimore" initials="C." surname="Mortimore">
              <organization showOnFrontPage="true">Disney</organization>
            </author>
            <date year="2023" month="Dec" day="15"/>
          </front>
          <refcontent>The OpenID Foundation</refcontent>
        </reference>
        <reference anchor="OpenID.Discovery" target="https://openid.net/specs/openid-connect-discovery-1_0.html">
          <front>
            <title>OpenID Connect Discovery 1.0 incorporating errata set 2</title>
            <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
              <organization showOnFrontPage="true">NAT.Consulting</organization>
            </author>
            <author fullname="John Bradley" initials="J." surname="Bradley">
              <organization showOnFrontPage="true">Yubico</organization>
            </author>
            <author fullname="Mike Jones" initials="M." surname="Jones">
              <organization showOnFrontPage="true">Self-Issued Consulting</organization>
            </author>
            <author fullname="Edmund Jay" initials="E." surname="Jay">
              <organization showOnFrontPage="true">Illumila</organization>
            </author>
            <date year="2023" month="Dec" day="15"/>
          </front>
          <refcontent>The OpenID Foundation</refcontent>
        </reference>
        <reference anchor="OpenID.Registration" target="https://openid.net/specs/openid-connect-registration-1_0.html">
          <front>
            <title>OpenID Connect Dynamic Client Registration 1.0 incorporating errata set 2</title>
            <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
              <organization showOnFrontPage="true">NAT.Consulting</organization>
            </author>
            <author fullname="John Bradley" initials="J." surname="Bradley">
              <organization showOnFrontPage="true">Yubico</organization>
            </author>
            <author fullname="Mike Jones" initials="M." surname="Jones">
              <organization showOnFrontPage="true">Self-Issued Consulting</organization>
            </author>
            <date year="2023" month="Dec" day="15"/>
          </front>
          <refcontent>The OpenID Foundation</refcontent>
        </reference>
      </references>
    </references>
  </back>
</rfc>
