<?xml version="1.0" encoding="US-ASCII"?>
<?xml-stylesheet type='text/xsl' href='http://xml2rfc.tools.ietf.org/authoring/rfc2629.xslt' ?>
<!DOCTYPE rfc PUBLIC "-//IETF//DTD RFC 2629//EN"
        "http://xml2rfc.tools.ietf.org/authoring/rfc2629.dtd">
<!--
  NOTE:  This XML file is input used to produce the authoritative copy of an
  OpenID Foundation specification.  The authoritative copy is the HTML output.
  This XML source file is not authoritative.  The statement ipr="none" is
  present only to satisfy the document compilation tool and is not indicative
  of the IPR status of this specification.  The IPR for this specification is
  described in the "Notices" section.  This is a public OpenID Foundation
  document and not a private document, as the private="..." declaration could
  be taken to indicate.
-->
<rfc category="std" docName="openid-connect-federation-1_0" ipr="none">

  <?rfc toc="yes" ?>
  <?rfc tocdepth="5" ?>
  <?rfc symrefs="yes" ?>
  <?rfc sortrefs="yes"?>
  <?rfc strict="yes" ?>
  <?rfc iprnotified="no" ?>
  <?rfc private="Draft" ?>

  <front>
    <title abbrev="OpenID Connect Federation">OpenID Connect Federation 1.0 -
      draft 08
    </title>

    <author fullname="Roland Hedberg" initials="R." role="editor"
            surname="Hedberg">
      <organization>independent</organization>

      <address>
        <email>roland@catalogix.se</email>
      </address>
    </author>

    <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
      <organization abbrev="Microsoft">Microsoft</organization>

      <address>
        <email>mbj@microsoft.com</email>

        <uri>http://self-issued.info/</uri>
      </address>
    </author>

    <author fullname="Andreas &Aring;kre Solberg" initials="A.&Aring;."
            surname="Solberg">
      <organization abbrev="Uninett">Uninett AS</organization>

      <address>
        <email>andreas.solberg@uninett.no</email>

        <uri>https://www.linkedin.com/in/andreassolberg/</uri>
      </address>
    </author>

    <author fullname="Samuel Gulliksson" initials="S." surname="Gulliksson">
      <organization abbrev="Schibsted">Schibsted Media Group</organization>

      <address>
        <email>samuel.gulliksson@gmail.com</email>
      </address>
    </author>

    <author fullname="John Bradley" initials="J." surname="Bradley">
      <organization abbrev="Yubico">Yubico</organization>

      <address>
        <email>ve7jtb@ve7jtb.com</email>

        <uri>http://www.thread-safe.com/</uri>
      </address>
    </author>

    <date day="25" month="June" year="2019"/>

    <workgroup>OpenID Connect Working Group</workgroup>

    <keyword>OpenID</keyword>
    <keyword>Connect</keyword>
    <keyword>Federation</keyword>

    <abstract>
      <t>
	The OpenID Connect standard specifies how a Relying Party (RP)
        can discover metadata about an OpenID Provider (OP), and then
        register to obtain RP credentials. The discovery and
        registration process does not involve any mechanisms of
        dynamically establishing trust in the exchanged information, but
        instead rely on out-of-band trust establishment.
      </t>
      <t>
	In an identity federation context, this is not sufficient. The
        participants of the federation must be able to trust information
        provided about other participants in the federation. OpenID
        Connect Federations specifies how trust can be dynamically
        obtained by resolving trust from a common trusted third party.
      </t>
      <t>
	While this specification is primarily targeting OpenID Connect,
        it is designed to allow for re-use by other
        protocols and in other use cases.
      </t>
    </abstract>
  </front>

  <middle>
    <section anchor="Introduction" title="Introduction">
      <t>
	This specification describes how two entities that would like to
        interact can dynamically fetch and resolve trust and metadata for a
        given protocol through the use of third-party trust issuers. A trust
        issuer is an entity whose main purpose is to issue statements
        about entities, such as OpenID Connect Relying Parties, OpenID Providers,
	and participating organizations.
	An identity
        federation can be realized using this specification using one or
        more levels of trust issuers. This specification does not mandate a
        specific way or restrict how a federation may be built. Instead, the
        specification provides the basic technical trust infrastructure building
        blocks needed to build a dynamic and distributed trust network such as a
        federation.
      </t>
      <t>
	All entities in an OpenID Connect federation MUST have a globally
        unique identifier.
      </t>
      <t>
	Note that a company, as with any real-world organization, may be
        represented by more than one entity in a federation.
      </t>
      <t>
	OpenID Connect Federation trust chains rely on
        cryptographically signed <xref target="RFC7519">JSON Web Token (JWT)</xref> documents, and the trust chain does not at
        all rely on TLS <xref target="RFC8446"/> in order to establish trust.
      </t>

      <section title="Requirements Language">
        <t>
	  The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
          "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
          document are to be interpreted as described in <xref target="RFC2119">RFC 2119</xref>.
        </t>
      </section>
      <section title="Terminology">
        <t>
          This specification uses the terms
          "Claim Name", "Claim Value", "JSON Web Token (JWT)",
          defined by <xref target="RFC7519">JSON Web Token (JWT)</xref>
	  and the terms "OpenID Provider (OP)" and "Relying Party (RP)" defined by
          <xref target="OpenID.Core">OpenID Connect Core 1.0</xref>.
        </t>
        <t>
          This specification also defines the following terms:
          <list style="hanging">
            <t hangText="Entity">
	      <vspace/>
              Something that has a separate and distinct existence and that can
              be identified in a context.
            </t>
            <t hangText="Entity statement">
	      <vspace/>
              An entity statement is
              issued by an entity, which pertains to a subject entity and leaf
              entities. An entity statement is always a signed JWT.
            </t>
            <t hangText="Intermediate entity">
	      <vspace/>
              An entity that issues
              an entity statement that appears somewhere in between those
              issued by the trust anchor and the leaf entity in a trust chain.
            </t>
            <t hangText="Leaf Entity">
	      <vspace/>
              An entity defined by a certain protocol,
	      e.g., OpenID Connect Relying Party or Provider.
            </t>
            <t hangText="Trust Anchor">
	      <vspace/>
              An entity that represents a trusted third party.
            </t>
            <t hangText="Trust Chain">
	      <vspace/>
              A sequence of entity statements that represents a trusted chain
              starting at a leaf entity and ending in a trust anchor.
            </t>
          </list>
        </t>
      </section>
    </section>
    <section title="Components" anchor="components">
      <section anchor="entity-statement" title="Entity Statement ">
        <t>
	  An entity statement is
          issued by an entity and concerns a subject entity and leaf entities
          in a federation. An entity statement is always a signed JWT.
          All entities in a federation MUST be prepared to publish an entity
          statement about themselves.
        </t>
        <t>
          An entity statement is composed of the following claims:
        </t>
        <t>
          <list style="hanging">
            <t hangText="iss">
	      <vspace/>
	      REQUIRED. The entity identifier of the issuer of
              the statement. If the <spanx style="verb">iss</spanx> and
              the <spanx style="verb">sub</spanx> are identical, the
              issuer is making a statement about itself.
            </t>
            <t hangText="sub">
	      <vspace/>
	      REQUIRED. The entity identifier of the subject
	    </t>
            <t hangText="iat">
	      <vspace/>
	      REQUIRED. The time the statement was issued.
              Its value is a JSON number representing the number of seconds from
              1970-01-01T0:0:0Z as measured in UTC until the date/time.
              See <xref target="RFC3339">RFC 3339</xref> for
              details regarding date/times in general and UTC in particular.
            </t>
            <t hangText="exp">
	      <vspace/>
	      REQUIRED.
              Expiration time on or after which the statement MUST NOT be
              accepted for processing. Its value is a JSON number representing
              the number of seconds from 1970-01-01T0:0:0Z as measured in UTC
              until the date/time.
            </t>
            <t hangText="jwks">
	      <vspace/>
	      REQUIRED. A <xref target="RFC7517">JSON Web Key Set (JWKS)</xref>
	      representing the public part of the subject
              entity's signing keys. The corresponding private key is
              used by leaf entities to sign entity statements about themselves,
              and intermediate entities to sign statements about other entities.
              The keys that can be found here are primarily intended to sign
              entity statements and should not be used in other protocols.
            </t>
            <t hangText="aud">
	      <vspace/>
	      OPTIONAL.
              The entity statement may be specifically created for a entity.
              The entity identifier for that entity should appear in this claim.
            </t>
            <t hangText="authority_hints">
	      <vspace/>
	      OPTIONAL. A JSON object where the keys
              are the entity IDs of the intermediate entities that may issue an
              entity statement about the issuer entity. The value MUST be a
              JSON array of entities that are further up in the trust chain.
              The array may be an empty list.
              The JSON array can be used to simplify the selection of trust
              chains without the need for following all possible trust chains.
	      <spanx style="verb">authority_hints</spanx> values
	      may be multiple hops up the chain.
	      These values will typically be trust anchors.
            </t>
            <t hangText="metadata">
	      <vspace/>
	      OPTIONAL. JSON object including protocol
              specific metadata claims that represent the entity's metadata.
              Each key of the JSON object represents a metadata type
              identifier, and each value MUST be a JSON object representing
              the metadata according to the metadata schema of that metadata
              type. An entity statement may contain multiple
              metadata statements, but only one for each metadata type.
            </t>
            <t hangText="metadata_policy">
	      <vspace/>
	      OPTIONAL. JSON object that describes
              a metadata policy.
              Each key of the JSON object represents a metadata type
              identifier, and each value MUST be a JSON object representing
              the metadata policy according to the metadata schema of that metadata
              type. An entity statement may contain multiple
              metadata policy statements, but only one for each metadata type.
              If the metadata type identifier is
              <spanx style="verb">federation_entity</spanx>, then the policy
              MUST be applied to the immediate subordinate in the trust chain
              unless that is a leaf entity.
	      If the metadata type identifier is not
              <spanx style="verb">federation_entity</spanx>, then the policy
	      MUST be applied to all subordinate nodes of that type in the trust chain.
	      Only non-leaf entities contain a <spanx style="verb">metadata_policy</spanx> field.
            </t>
            <t hangText="crit">
	      <vspace/>
	      OPTIONAL.
	      The <spanx style="verb">crit</spanx> (critical) entity statement claim
	      indicates that extensions to entity statement claims defined by this specification
	      are being used that MUST be understood and processed.
	      It is used in the same way that <spanx style="verb">crit</spanx>
	      is used for extension JWS header parameters that MUST be understood and processed.
	      Its value is an array listing the entity statement claims
	      present in the entity statement that use those extensions.
	      If any of the listed extension entity statement claims are not
	      understood and supported by the recipient, then the entity statement is invalid.
	      Producers MUST NOT include entity statement claim names defined by this specification or
	      names that do not occur as entity statement claim names in the entity statement
	      in the <spanx style="verb">crit</spanx> list.
	      Producers MUST NOT use the empty list <spanx style="verb">[]</spanx>
	      as the <spanx style="verb">crit</spanx> value.
	    </t>
            <t hangText="policy_language_crit">
	      <vspace/>
	      OPTIONAL.
	      The <spanx style="verb">policy_language_crit</spanx> (critical) entity statement claim
	      indicates that extensions to the policy language defined by this specification
	      are being used that MUST be understood and processed.
	      It is used in the same way that <spanx style="verb">crit</spanx>
	      is used for extension JWS header parameters that MUST be understood and processed.
	      Its value is an array listing the policy language extensions
	      present in the policy language statements that use those extensions.
	      If any of the listed extension policy language extensions are not
	      understood and supported by the recipient, then the entity statement is invalid.
	      Producers MUST NOT include policy language names defined by this specification or
	      names that do not occur in policy language statements in the entity statement
	      in the <spanx style="verb">policy_language_crit</spanx> list.
	      Producers MUST NOT use the empty list <spanx style="verb">[]</spanx>
	      as the <spanx style="verb">policy_language_crit</spanx> value.
	    </t>
          </list>
        </t>

        <t>
	  The entity statement is signed using the private key of the issuer
          entity, in the form of a <xref target="RFC7515">JSON Web Signature (JWS)</xref>.
        </t>

        <figure>
          <preamble>
	    The following is a non-normative example of an entity statement, before
            serialization and adding a signature.  The example contains
            a critical extension <spanx style="verb">jti</spanx> (JWT ID) to the
            entity statement and one critical extension to the policy language
            <spanx style="verb">regexp</spanx> (Regular expression).
          </preamble>

          <artwork><![CDATA[
{
  "iss": "https://feide.no",
  "sub": "https://ntnu.no",
  "iat": 1516239022,
  "exp": 1516298022,
  "crit": ["jti"],
  "jti": "7l2lncFdY6SlhNia",
  "policy_language_crit": [regexp"],
  "metadata_policy": {
    "openid_provider": {
      "issuer": {"value": "https://ntnu.no"},
      "organization_name": {"value": "NTNU"},
      "id_token_signing_alg_values_supported":
        {"subset_of": ["RS256", "RS384", "RS512"]},
      "op_policy_uri": {
        "regexp": "^https:\/\/[\w-]+\.example\.com\/[\w-]+\.html"}
    },
    "openid_relying_party": {
      "organization_name": {"value": "NTNU"},
      "grant_types_supported": {
        "subset_of": ["authorization_code", "implicit"]},
      "scopes": {
        "subset_of": ["openid", "profile", "email", "phone"]}
    }
  },
  "jwks": {
    "keys": [
      {
        "alg": "RS256",
        "e": "AQAB",
        "ext": true,
        "key_ops": ["verify"],
        "kid": "key1",
        "kty": "RSA",
        "n": "pnXBOusEANuug6ewezb9J_...",
        "use": "sig"
      }
    ]
  },
  "authority_hints": {
    "https://edugain.org/federation": [
      "https://edugain.org/federation"
    ]
  }
}
]]></artwork>

        </figure>
      </section>

      <section title="Trust Chain" anchor="trust_chain">
        <t>
          In an OpenID Connect Identity Federation, entities that together build a
          trust chain can be categorized as:
          <list style="hanging">
            <t hangText="Trust anchor">
	      <vspace/>
	      An entity that represents a trusted
              third party
            </t>
            <t hangText="Leaf">
	      <vspace/>
	      In an OpenID Connect Identity Federation, an RP or an OP
            </t>
            <t hangText="Intermediate">
	      <vspace/>
	      Neither a leaf nor a trust anchor
	    </t>
          </list>
	</t>
	<t>
          A trust chain begins with a leaf entity's self-signed entity
          statement, has zero or more entity statements
          issued by intermediates about subordinates, and ends with an
          entity statement issued by the trust anchor about the top-most
          intermediate (if there are intermediates) or the leaf entity
          (if there are no intermediates)
          and finally a self-signed entity statement about the trust anchor.
        </t>
        <t>
	  A simple example: If we have an RP that belongs to organization A
          that is a member of federation F, the trust chain for such a setup
          will contain the following entity statements:
          <list style="numbers">
            <t>
              A self-signed entity statement about the RP published by the RP
            </t>
            <t>
              An entity statement about the RP published by Organization A
            </t>
            <t>
              An entity statement about Organization A published by Federation
              F
            </t>
            <t>
              A self-signed entity statement about Federation F published
              by Federation F.
            </t>
          </list>
        </t>
        <t>
          A trust chain MUST always be possible to order such that:
          If we name the entity statements ES[0] (the leaf entity's
          self-signed entity statement) to ES[i] (the trust anchors
          self-signed entity statement), i>0 then:
          <list style="symbols">
            <t>
              The <spanx style="verb">iss</spanx> entity in one entity statement is always the <spanx style="verb">sub</spanx>
              entity in the next.
              ES[j]['iss'] == ES[j+1]['sub'], j=0,...,i-1
            </t>
            <t>
              There MUST always be a signing key carried in the
              <spanx style="verb">jwks</spanx> claim in
              ES[j] that can be used to verify the signature of ES[j-1],
              j=i,...,1 .
            </t>
          </list>
        </t>
        <t>
          The signing key that MUST be used to verify ES[i] is distributed
          from the trust anchors to the leaf entities in
          some secure out-of-band's way not described in this document.
        </t>
      </section>
    </section>
    <section anchor="metadata" title="Metadata">
      <t>
	This specification does allow new metadata
        types to be defined, to support use cases outside OpenID Connect federations.
	The metadata type identifier will uniquely identify which metadata
        specification to utilize.
      </t>
      <t>
	The metadata document MUST be a JSON document. Beyond that there is
        no restriction.
      </t>
      <t>
	Metadata used in federations typically re-uses existing metadata standards.
	If needed, the metadata schema is extended
        with additional properties relevant in a federated context.
	For instance, for OpenID Connect Federations, this specification uses
	metadata values from
	<xref target="OpenID.Discovery">OpenID Connect Discovery 1.0</xref> and
	<xref target="OpenID.Registration">OpenID Connect Dynamic Client Registration 1.0</xref>
	and adds additional values used for federations.
      </t>

      <section title="RP Metadata" anchor="RP_metadata">
        <t>
	  The metadata type identifier is
	  <spanx style="verb">openid_relying_party</spanx>.
        </t>
        <t>
	  All parameters defined in Section 2 of
	  <xref target="OpenID.Registration">OpenID Connect Dynamic Client Registration 1.0</xref>
	  are allowed in a metadata statement.
        </t>
        <t>
	  To that list is added:
          <list style="hanging">
	    <t hangText="federation_type">
	      <vspace/>
	      REQUIRED.  String specifying the federation type being used.
	      Values defined by this specification are
	      <spanx style="verb">automatic</spanx> and <spanx style="verb">explicit</spanx>.
	    </t>
            <t hangText="organization_name">
	      <vspace/>
	      OPTIONAL. A human readable
              name representing the organization owning the RP.
            </t>
          </list>
        </t>
      </section>

      <section title="OP Metadata" anchor="OP_metadata">
        <t>
	  The metadata type identifier is
	  <spanx style="verb">openid_provider</spanx>.
        </t>
        <t>
	  All parameters defined in Section 3 of
          <xref target="OpenID.Discovery">OpenID Connect Discovery 1.0</xref>
	  are applicable.
        </t>
        <t>
	  In addition, the following parameters are defined by this specification:
	</t>
        <t>
          <list style="hanging">
	    <t hangText="federation_types_supported">
	      <vspace/>
	      REQUIRED.  Array specifying the federation types supported.
	      Federation type values defined by this specification are
	      <spanx style="verb">automatic</spanx> and <spanx style="verb">explicit</spanx>.
	    </t>
            <t hangText="organization_name">
	      <vspace/>
	      OPTIONAL. A human readable
              name representing the organization owning the OP. It is
              intended to be used in the user interface, being recognized by
              the end users that would be using the OP to authenticate.
            </t>
            <t hangText="federation_registration_endpoint">
	      <vspace/>
	      OPTIONAL.
              URL of the OP's Federation specific Dynamic Client Registration
              Endpoint. If the OP supports explicit client
              registration as described in <xref target="explicit"/>,
	      then this claim is REQUIRED.
            </t>
          </list>
        </t>
      </section>

      <section title="OAuth Authorization Server">
        <t>
	  The metadata type identifier is
          <spanx style="verb">oauth_authorization_server</spanx>.
        </t>
        <t>
	  All parameters defined in Section 2 of
          <xref target="RFC8414">RFC 8414</xref>
	  are applicable.
        </t>
      </section>

      <section title="OAuth Client">
        <t>
	  The metadata type identifier is
	  <spanx style="verb">oauth_client</spanx>.
        </t>
        <t>
	  All parameters defined in Section 2 of
          <xref target="RFC7591">RFC 7591</xref>
        </t>
      </section>

      <section title="OAuth Protected Resource">
        <t>
	  The metadata type identifier is
          <spanx style="verb">oauth_resource</spanx>.
        </t>
      </section>
      <section title="Federation Entity">
        <t>
	  The metadata type identifier is
          <spanx style="verb">federation_entity</spanx>.
        </t>
        <t>
	  Intermediates in a trust chain are of this type.
	</t>
        <t>
          Note that the information carried here is not bound to any
          specific protocol but of a general nature.
        </t>
        <t>
          The following properties are allowed:
          <list style="hanging">
            <t hangText="name">
	      <vspace/>
	      OPTIONAL. String. The human readable name
              describing the subject entity. This may be, for example, the
              name of an organization.
            </t>
            <t hangText="contacts">
	      <vspace/>
	      OPTIONAL. JSON array with one or more
              strings. Contact persons at the entity.
	      These may contain names, e-mail addresses, descriptions, phone numbers, etc.
            </t>
            <t hangText="policy_uri">
	      <vspace/>
	      OPTIONAL. URL to documentation of
              conditions and policies relevant to this entity.
            </t>
            <t hangText="homepage_uri">
	      <vspace/>
	      OPTIONAL. URL to a generic home page
              representing this entity.
            </t>
          </list>
        </t>
      </section>
    </section>
    <section title="Applying Policy to Metadata">
      <t>
	The metadata for a specific entity can be constructed by starting
        with the information in leaf entity's entity statement and then
        applying the polices defined by the trust anchor and possible
        intermediates starting with the trust anchor.
      </t>

      <section title="Policy Language" anchor="PolicyLanguage">
        <t>
          Policies are expressed using a JSON object.
        </t>
        <t>
          The following keywords represent different
          actions/checks that MUST be applied to the metadata.
        </t>

	<section title="subset_of" anchor="subset_of">
	  <t>
	    The resulting value of the claim will be the intersection of the
	    values specified here and the values of the claim. For
	    instance, the claim policy:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "response_types": {
    "subset_of": ["code", "code token", "code id_token"]}
]]></artwork>
	  </figure>
	  <t>
	    if applied to a metadata statement with:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "response_types": ["code", "code id_token token", "code id_token"]
]]></artwork>
	  </figure>
	  <t>
	    will update the claim in the metadata statement to be:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "response_types": ["code", "code id_token"]
]]></artwork>
	  </figure>
	</section>

	<section title="one_of" anchor="one_of">
	  <t>
	    The value of the claim MUST be one of the ones listed here.
	    As an example, if the claim policy:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "request_object_signing_alg": {
    "one_of": ["ES256", "ES384", "ES512"]}
]]></artwork>
	  </figure>
	  <t>
	    is applied to the metadata statement
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "request_object_signing_alg": "ES384"
]]></artwork>
	  </figure>
	  <t>
	    the resulting claim statement will be:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "request_object_signing_alg": "ES384"
]]></artwork>
	  </figure>
	</section>

	<section title="add" anchor="add">
	  <t>
	    Adds the value or values specified to the list of values for the
	    metadata statement claim.
	    If the specified value is already present in the list,
	    this operation has no effect.
	    As an example, if the claim policy:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "contacts": {
    "add": "support@federation.example.com"}
]]></artwork>
	  </figure>
	  <t>
	    is applied to the following claim in the metadata statement:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "contacts": "support@org.example.com"
]]></artwork>
	  </figure>
	  <t>
	    the end result will be the claim:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "contacts": ["support@org.example.com",
               "support@federation.example.com"]
]]></artwork>
	  </figure>
	</section>

	<section title="value" anchor="value">
	  <t>
	    Disregarding what value the claim had,
	    if any, the claims value will be set to what is specified here.
	    As an example, if the claim policy:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "require_auth_time": {
    "value": true}
]]></artwork>
	  </figure>
	  <t>
	    is applied to a metadata statement with no such claim
	    the result will be that the metadata statement after applying the
	    policy contains the claim:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "require_auth_time": true
]]></artwork>
	  </figure>
	</section>

	<section title="default" anchor="default">
	  <t>
	    If no value is assigned to this claim, then the claim's value
	    will be set to what is specified here.
	    As an example, if the claim policy:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "require_auth_time": {
    "default": true }
]]></artwork>
	  </figure>
	  <t>
	    is applied to a metadata statement with the claim
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "require_auth_time": false
]]></artwork>
	  </figure>
	  <t>
	    then the metadata statement will afterwards contain:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "require_auth_time": false
]]></artwork>
	  </figure>
	  <t>
	    if on the other hand the metadata statement did not contain a
	    <spanx style="verb">require_auth_time</spanx> claim then the
	    following claim statement would be added to the metadata
	    statement:
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "require_auth_time": true
]]></artwork>
	  </figure>
	</section>

	<section title="essential" anchor="essential">
	  <t>
	    If 'true' then claim MUST have a value. <spanx style="verb">essential</spanx> can be
	    combined with all the other types.
	  </t>
	  <figure>
	    <artwork><![CDATA[
  "tos_uri": {
    "essential": true}
]]></artwork>
	  </figure>
	  <t>
	    The upshot of applying this policy to a metadata statement
	    is that the metadata statement MUST contain such a claim
	    otherwise the metadata statement is incorrect.
	  </t>
	</section>

      </section>
      <section title="Policy Type Combinations">
        <t>
          Some policy types can be combined with others.
          <list style="hanging">
            <t hangText="default">
              <vspace/>
              Can be combined with <spanx style="verb">one_of</spanx> and
              <spanx style="verb">subset_of</spanx>.
            </t>
            <t hangText="essential">
              <vspace/>
              Can be combined with all the others. If
              <spanx style="verb">essential</spanx> is not present that is
              the same as stating essential=true.
            </t>
          </list>
        </t>
      </section>
      <section title="Combining Policies">
        <t>
          If there is more than one metadata policy in a trust chain, then
          the policies MUST be combined before they are applied to the
          metadata statement.
        </t>
        <t>
	  Using the notation we have previously defined metadata policies
          are combined starting with ES[i] and then adding the policies from
          ES[j] j=i-1,..,1 before applying the combined policy to the entity's
          metadata
        </t>
        <t>
          These are the policy types that can be combined when combining 2
          policies:
          <list style="hanging">
            <t hangText="subset_of">
              <vspace/>
              The result of combining 2 <spanx style="verb">subset_of</spanx> policies is the intersection of
              the values.
            </t>
            <t hangText="one_of">
              <vspace/>
              The result of combining 2 <spanx style="verb">one_of</spanx> policies is the intersection of
              the values.
            </t>
            <t hangText="add">
              <vspace/>
              The result of combining 2 <spanx style="verb">add</spanx> policies is the union of the
              values.
            </t>
          </list>
	</t>
	<t>
          All the other policy types can NOT be combined. Which means that
          whatever a superior specifies are what goes.
        </t>
        <section title="Policy Combination Example">
	  <figure>
	    <preamble>
	      A federations policy for RPs:
	    </preamble>
	    <artwork><![CDATA[
{
  "scopes": {
    "subset_of": ["openid", "eduperson", "phone"],
    "default": ["openid", "eduperson"]},
  "id_token_signed_response_alg": {
    "one_of": ["ES256", "ES384", "ES512"],
    "default": "ES256"},
  "contacts: {
    "add": "helpdesk@federation.example.org"},
   "application_type": {
    "value": "web"}
}
]]></artwork>
          </figure>
	  <figure>
	    <preamble>
	      An organization's policy for RPs:
	    </preamble>
	    <artwork><![CDATA[
{
  "scopes": {
    "subset_of": ["openid", "eduperson", "address"],
    "default": ["openid", "eduperson"]},
  "id_token_signed_response_alg": {
    "one_of": ["ES256", "ES384"],
    "default": "ES256"},
  "contacts: {
    "add": "helpdesk@org.example.org"},
  "application_type": {
    "one_of": ["web", "native"]}
}
]]></artwork>
          </figure>
	  <figure>
	    <preamble>
	      The combined metadata policy then becomes:
	    </preamble>
	    <artwork><![CDATA[
{
  "scopes": {
    "subset_of": ["openid", "eduperson"],
    "default": ["openid", "eduperson"]},
  "id_token_signed_response_alg": {
    "one_of": ["ES256", "ES384"],
    "default": "ES256"},
  "contacts: {
    "add": ["helpdesk@federation.example.org"],
            "helpdesk@org.example.org"]},
  "application_type": {
    "value": "web"}
}
]]></artwork>
          </figure>
          <t>
            If after combining a <spanx style="verb">default</spanx> value for a claim policy,
	    the result is not a
            subset of a <spanx style="verb">subset_of</spanx> policy or a
            <spanx style="verb">one_of</spanx> defined for that claim, then an
            error MUST be raised and the trust chain NOT used.
          </t>
        </section>
      </section>
      <section title="Enforcing Policy">
        <t>
          If applying a policy to a metadata statement results in some claims
          having all their values removed and it is essential that a
          claim has a value, then such a metadata statement MUST
          be regarded as broken and MUST NOT be used.
        </t>
      </section>
      <section title="Extending the Policy Language">
        <t>
          There might be parties that wants to extend the policy language
          defined here. If that happens then the rule is that if
          software compliant with this specification
          encounters a keyword it doesn't understand it MUST ignore it
	  unless it is listed in a <spanx style="verb">policy_language_crit</spanx> list,
	  as is done for JWS header parameters with the <spanx style="verb">crit</spanx> parameter.
	  If the policy language extension keyword
	  is listed in the <spanx style="verb">policy_language_crit</spanx> list
	  and not understood, then the metadata MUST be rejected.
        </t>
      </section>
      <section title="Policy Example">
        <t>
          The following is a non-normative example of a set of policies being
          applied to an RP's metadata.
	</t>
	<figure>
	  <preamble>
	    The RP's metadata:
	  </preamble>
	  <artwork><![CDATA[
{
  "contacts": ["rp_admins@cs.example.com"],
  "redirect_uris": ["https://cs.example.com/rp1"],
  "response_types: ["code"]
}
]]></artwork>
	</figure>
	<figure>
	  <preamble>
	    The federations policy for RPs:
	  </preamble>
	  <artwork><![CDATA[
{
  "scopes": {
    "subset_of": ["openid", "eduperson"]},
  "response_types": {
    "subset_of": ["code", "code id_token"]}
}
]]></artwork>
	</figure>
	<figure>
	  <preamble>
	    The organization's policy for RPs:
	  </preamble>
	  <artwork><![CDATA[
{
  "contacts": {
    "add": "helpdesk@example.com"},
  "logo_uri": {
    "one_of": ["https://example.com/logo_small.jpg",
               "https://example.com/logo_big.jpg"],
    "default": "https://example.com/logo_small.jpg"
  },
  "policy_uri": {
    "value": "https://example.com/policy.html"},
  "tos_uri": {
    "value": "https://example.com/tos.html"}
}
]]></artwork>
	</figure>
	<t>
          The metadata for the entity in question after applying the policies
          above, would then become:
	</t>
	<figure>
	  <artwork><![CDATA[{
  "contacts": ["rp_admins@cs.example.com", "helpdesk@example.com"],
  "logo_uri": "https://example.com/logo_small.jpg",
  "policy_uri": "https://example.com/policy.html",
  "tos_uri": "https://example.com/tos.html"
  "scopes": ["openid", "eduperson"],
  "response_types": ["code"],
  "redirect_uris": ["https://cs.example.com/rp1"],
}
]]></artwork>
	</figure>
      </section>
    </section>

    <section title="The Federation API">
      <t>
	All entities that are expected
        to publish entity statements about themselves or other entities, MUST
        expose a Federation API endpoint.
      </t>
      <t>
	The federation API endpoint of an entity is resolved from the entity
        identifier. The Federation API endpoint is found using the
	<xref target="RFC5785">Well-Known URIs</xref> specification, with the suffix
        <spanx style="verb">openid-federation</spanx>. The scheme, host and port
        is taken directly from the entity identifier combined with the following
        path: <spanx style="verb">/.well-known/openid-federation</spanx>.
      </t>
      <t>
	If the entity identifier contains a path, it is concatenated after
	<spanx style="verb">/.well-known/openid-federation</spanx> in the same manner
	that path components are concatenated to the well-known identifier in
	the OAuth 2.0 Authorization Server Metadata <xref target="RFC8414"/> specification.
	Of course, in real multi-tenant deployments, in which the entity ID might be of the form
	<spanx style="verb">https://multi-teanant-service.example.com/my-tenant-identifier</spanx>
	the tenant is very likely to not have control over the path
	<spanx style="verb">https://multi-teanant-service.example.com/.well-known/openid-federation/my-tenant-identifier</spanx>
	whereas it is very likely to have control over the path 
	<spanx style="verb">https://multi-teanant-service.example.com/my-tenant-identifier/.well-known/openid-federation</spanx>.
	Therefore, if using the Federation API at the URL with the tenant path after the well-known part fails,
	it is RECOMMENDED that callers retry at the URL with the tenant path before the well-known part
	(even though this violates <xref target="RFC5785"/>).
      </t>
      <t>
	The Federation API is an HTTPS API that may support multiple
        operations. Fetching entity statements is one of the operations, and the
        only one
        that all Federation API endpoints are REQUIRED to support. All the
        other operations are OPTIONAL. The list of defined operations may be
        extended in a future.
      </t>
      <t>
	While all operations in the specification make use of a GET request,
        other operations may choose to use other HTTP methods. If the
	<spanx style="verb">operation</spanx>
	parameter is left out, it is treated as a
        fetch entity statements request. Unless otherwise mentioned or agreed
        upon, requests to the federation API does not need to be
        authenticated.
      </t>

      <section title="Fetching Entity Statement (REQUIRED)">
        <t>
	  Fetching entity statement is used to collect entity statements
          one by one in order to gather trust chains.
        </t>
        <t>
	  In order to fetch an entity statement, an entity needs to know the
          identifier of the entity to ask (the issuer), and the identifier of
          the entity that you want the statement to be about (the subject).
        </t>

        <section title="Fetch Entity Statements Request"
                 anchor="fetch_statement">
          <t>
	    The request MUST be an HTTP request using the GET method and
            the https scheme to a resolved federation API endpoint with the
            following query string parameters:
          </t>
          <t>
            <list style="hanging">
              <t hangText="operation">
		<vspace/>
		OPTIONAL. If not present, MUST be treated as
                <spanx style="verb">fetch</spanx>.
              </t>
              <t hangText="iss">
		<vspace/>
		REQUIRED. The entity identifier of the issuer
                from which you want an entity statement issued. Because of the
                normalization of the URL, multiple issuers may resolve to a
                shared federation API. This parameter makes it explicit exactly
                which issuer we want entity statements from.
              </t>
              <t hangText="sub">
		<vspace/>
		OPTIONAL. The entity identifier of the subject
                for which you would like an entity statement issued. If this
                parameter is left out, it is considered to be the same as the
                issuer and would indicate a request for a self-issued
                statement.
              </t>
              <t hangText="aud">
		<vspace/>
		OPTIONAL. The entity identifier of the
                requester. The issuing entity may choose to include this
                parameter to form the entity statement specifically for this
                target, in which the <spanx style="verb">aud</spanx> claim also
                SHOULD be present in the entity statement self.
              </t>
            </list>
          </t>

          <figure>
            <preamble>
	      The following is a non-normative example of an API
              request for an entity statement:
            </preamble>
            <artwork><![CDATA[
GET /.well-known/openid-federation?
iss=https%3A%2F%2Fopenid.sunet.se%2Ffederation HTTP/1.1
Host: openid.sunet.se
]]></artwork>
          </figure>
        </section>

        <section title="Fetch Entity Statements Response">
          <t>
	    A positive response is a signed entity statement where
            the content type MUST be set to <spanx style="verb">application/jose</spanx>.
            If it is negative response it will be a JSON object and the
            content type MUST be set to
            <spanx style="verb">application/json</spanx>.
            See more about error responses in <xref target="error_response"/>.
          </t>
          <figure>
            <preamble>
	      The following is a non-normative example of a response:
	    </preamble>
            <artwork><![CDATA[
200 OK
Last-Modified: Mon, 17 Dec 2018 11:15:56 GMT
Content-Type: application/jose

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJodHRwczovL3Nlc...
]]></artwork>
            <postamble>(the signed JWT is truncated)</postamble>
          </figure>
        </section>
      </section>

      <section title="Trust Negotiation (OPTIONAL)">
        <t>
	  An entity may use the trust negotiation operation in order to fetch
          resolved metadata about itself as seen/trusted by a remote peer.
          The result may, for instance, tell an RP what operations, scopes and
          claims an OP would allow the RP to use if a specific trust anchor
          was used.
        </t>

        <section title="Trust Negotiation Request">
          <t>
	    The request MUST be an HTTP request using the GET method and
            the https scheme to a resolved federation API endpoint with the
            following query string parameters:
          </t>
          <t>
            <list style="hanging">
              <t hangText="operation">
		<vspace/>
		REQUIRED. MUST be set to <spanx style="verb">resolve_metadata</spanx>.
              </t>
              <t hangText="respondent">
		<vspace/>
		REQUIRED. The entity identifier of the
                entity whose metadata are requested. Because of the
                normalization of the URL, multiple entity identifiers may
                resolve to a shared federation API. This parameter makes it
                explicit exactly which entity is expected.
              </t>
              <t hangText="peer">
		<vspace/>
		REQUIRED. The entity identifier of the entity
                the information is requested for. This must be a leaf entity.
              </t>
              <t hangText="type">
		<vspace/>
		REQUIRED. The metadata type to resolve.
                In this document, we use the metadata types listed in
                <xref target="metadata"/>.
              </t>
              <t hangText="anchor">
		<vspace/>
		REQUIRED. The trust anchor the remote peer
                MUST use when resolving the metadata.
              </t>
            </list>
          </t>
	  <figure>
	    <preamble>
	      The following is a non-normative example of an API
	      request for trust negotiation:
	    </preamble>
	    <artwork><![CDATA[
GET /.well-known/openid-federation?
op=resolve_metadata&
respondent=https%3A%2F%2Fopenid.sunet.se%2Ffederation&
type=openid_provider&
anchor=https%3A%2F%2Fswamid.se&
peer=https%3A%2F%2Fidp.umu.se%2Fopenid HTTP/1.1
Host: openid.sunet.se
]]></artwork>
	  </figure>
        </section>

        <section title="Trust Negotiation Response">
          <t>
	    The response is a metadata statement that is the result of
            applying the metadata polices in the trust chain on the entity's
            metadata.
          </t>
          <figure>
            <preamble>
	      The following is a non-normative example of a response:
	    </preamble>
            <artwork><![CDATA[
200 OK
Last-Modified: Wed, 22 Jul 2018 19:15:56 GMT
Content-Type: application/json

{
  "organization": "University of Ume?",
  "contacts": ["legal@umu.se", "technical@umu.se"],
  "logo_uri":
    "https://www.umu.se/SRWStatic/img/umu-logo-left-neg-SE.svg",
  "policy_uri":
    "https://www.umu.se/en/about-the-website/legal-information/",
  "authorization_endpoint":
    "https://idp.umu.se/openid/authorization",
  "token_endpoint": "https://idp.umu.se/openid/token",
  "response_types_supported": ["code", "code id_token", "token"],
  "grant_types_supported": [
    "authorization_code",
    "implicit",
    "urn:ietf:params:oauth:grant-type:jwt-bearer"
  ],
  "subject_types_supported": ["pairwise"],
  "id_token_signing_alg_values_supported": ["RS256"]
}
]]></artwork>
          </figure>
        </section>
      </section>

      <section title="Entity Listings (OPTIONAL)">
        <t>
	  An entity may query another entity for a list of all the
          entities immediately subordinate to that entity
	  that that entity is prepared to issue statements about.
	  (In some cases, this may be a very large list.)
        </t>

        <section title="Entity Listings Request">
          <t>
	    The request MUST be an HTTP request using the GET method and
            the https scheme to a resolved federation API endpoint with the
            following query string parameters:
          </t>
          <t>
            <list style="hanging">
              <t hangText="operation">
		<vspace/>
		REQUIRED. MUST be set to
                <spanx style="verb">listing</spanx>.
              </t>
              <t hangText="iss">
		<vspace/>
		REQUIRED. The entity identifier of the entity
                from which an entity listing is requested. Because of the
                normalization of the URL, multiple entity identifiers may
                resolve to a shared federation API. This parameter makes it
                explicit exactly which entity is expected.
              </t>
              <t hangText="is_leaf">
		<vspace/>
		OPTIONAL. If left out, result should
                include both leaf entities and intermediate nodes. If set to
                <spanx style="verb">true</spanx>,
                the response should contain only leaf entities. If set to
                <spanx style="verb">false</spanx>, the
                response should contain only intermediate nodes.
              </t>
            </list>
          </t>
	  <figure>
	    <preamble>
	      The following is a non-normative example of an API
	      request for trust negotiation:
	    </preamble>
	    <artwork><![CDATA[
GET /.well-known/openid-federation?
op=listing&
iss=https%3A%2F%2Fopenid.sunet.se%2Ffederation&
type=openid_relying_party HTTP/1.1
Host: openid.sunet.se
]]></artwork>
	  </figure>
        </section>

        <section title="Entity Listing Response">
          <t>
	    The response MUST contain an JSON list with the known entity
            identifiers.
          </t>
          <figure>
            <preamble>
	      The following is a non-normative example of a response:
	    </preamble>
            <artwork><![CDATA[
200 OK
Last-Modified: Wed, 22 Jul 2018 19:15:56 GMT
Content-Type: application/json

[
  "https://ntnu.andreas.labs.uninett.no/",
  "https://blackboard.ntnu.no/openid/callback",
  "https://serviceprovider.andreas.labs.uninett.no/application17"
]
]]></artwork>
          </figure>
        </section>
      </section>

      <section title="Generic Error Response" anchor="error_response">
        <t>
	  If the request was malformed, or some error occurred during
          processing of the request, the following standardized error format
          should be used regardless of the operation specified.
        </t>
        <t>
	  The HTTP response code MUST be something in 400/500-range, giving an
          indication of the type of error. The response body MUST be a JSON
          object containing the claims below and the content type MUST
          be set to <spanx style="verb">application/json</spanx>.
        </t>
        <t>
          <list style="hanging">
            <t hangText="operation">
	      <vspace/>
	      REQUIRED. The operation of the request.
            </t>
            <t hangText="error">
	      <vspace/>
	      REQUIRED. The error code.
	    </t>
            <t hangText="error_description">
	      <vspace/>
	      REQUIRED. A human readable short
              text describing the error.
            </t>
          </list>
        </t>

        <figure>
          <preamble>
	    The following is a non-normative example of an error response:
	  </preamble>
          <artwork><![CDATA[
400 Bad request
Last-Modified: Wed, 22 Jul 2018 19:15:56 GMT
Content-Type: application/json

{
  "operation": "fetch",
  "error": "invalid_request",
  "error_description":
    "Required request parameter [iss] was missing."
}
]]></artwork>
        </figure>
      </section>
    </section>

    <section anchor="resolving_trust" title="Resolving Trust Chain and Metadata">
      <t>
	An entity (e.g., the Consumer) that wants to establish trust with a
        remote
        peer, must have the remote peer's entity identifier and a list of
        entity IDs of trusted trust anchors together with the public version
        of their signing keys. The Consumer will first have to fetch
        sufficient entity statements to establish at least one chain of trust
        from the remote peer to one or more of the configured trust anchors.
        After that the entity MUST validate the trust chains independently,
        and -- if there are multiple valid trust chains and if the
        application demands it -- choose one.
      </t>

      <section anchor="fetching-es" title="Fetching Entity Statements to Establish a Trust Chain">
        <t>
	  Depending on the circumstances, the Consumer may either be
          handed the remote peer's self-issued entity statement, or it may
          have to fetch it by itself. If it needs to fetch it, it will use the
          process described in <xref target="fetch_statement"/>
	  with both <spanx style="verb">iss</spanx> and <spanx style="verb">sub</spanx> set to the entity ID
          of the remote peer.
        </t>
        <t>
	  The next step is to iterate through the list of
          intermediates listed in
          <spanx style="verb">authority_hints</spanx>, ignoring the authority
          hints that end in an unknown trust anchor, requesting an entity
          statement about the remote peer from each of the intermediates.
          If the received entity statement contains an authority hint this
          process is repeated. This time with the <spanx style="verb">iss</spanx> set to the
          intermediates entity ID and the <spanx style="verb">sub</spanx> to be the <spanx style="verb">iss</spanx> of the previous
          query.
          The Consumer should never attempt to fetch
          entity statements it already has fetched during this
          process (loop prevention).
        </t>
        <t>
	  Once the Consumer has found a trust anchor it wants to use it MUST
          complete the trust chain by fetching the trust anchor's self-signed
          entity statement.
        </t>
        <t>
	  A successful operation will return one or more lists of
          entity statements. Each of the lists terminating in a self-signed
          entity statement issued by a trust anchor.
        </t>
        <t>
          If there is no path from the remote peer to at least one of the
          trusted trust anchors, then the list will be empty and there is no
          way of establishing trust in the remote peer's information. How the
          Consumer deals with this is out of scope for this specification.
        </t>
      </section>

      <section title="Validating the Trust Chains" anchor="trust_chain_validation">
        <t>
	  As described in <xref target="trust_chain"/>,
          a trust chain consists of an ordered list of entity
          statements. So whichever way the Consumer has acquired the set of
          entity statements, it must now verify that it is a proper trust chain
          using the rules laid out in that section.
        </t>
        <t>
          To validate the chain, the following must be done:
	</t>
	<t>
          <list style="symbols">
            <t>
              For each entity statement ES[j] j=i,..,0:
              <list style="symbols">
                <t>
                  Verify that the statement contains all the required claims.
                </t>
                <t>
                  Verify that <spanx style="verb">iat</spanx> has a value in the past
                </t>
                <t>
                  Verify that <spanx style="verb">exp</spanx> has a value that is in the future.
                </t>
              </list>
            </t>
            <t>
              For j=0,i verify that <spanx style="verb">iss</spanx> == <spanx style="verb">sub</spanx>.
            </t>
            <t>
              For j=1,...,i-1: Verify that ES[j]['iss'] == ES[j+1]['sub']
            </t>
            <t>
              For j=0,...,i-1: Verify the signature of ES[j] using the public
              key carried in ES[j+1]['jwks'].
            </t>
            <t>
              For j == i: verify the signature with the configured public
              key of the trust anchor.
            </t>
          </list>
        </t>
        <t>
	  Verifying the signature is a much more expensive
          operation then verifying the correctness of the statement and the
          timestamps. An implementer MAY therefor chose to not verify the
          signature until all the other checks have been done.
        </t>
        <t>
          No information in the chain of statements should be used
          before the signature chain has been validated.
        </t>
      </section>

      <section title="Choosing One of the Valid Trust Chains">
        <t>
	  If multiple valid trust chains are found, the Consumer will
          need to decide on which one to use.
        </t>
        <t>
          One simple rule would be to prefer a shorter chain over a longer
          one.
        </t>
      </section>

      <section anchor="trust_lifetime" title="Calculating the Lifetime of a Trust Chain">
        <t>
          Each entity statement in a trust chain is signed and MUST have a
          expiration time (exp) set. The expiration time of the whole trust
          chain is set to the minimum value of exp within the chain.
        </t>
      </section>
    </section>

    <section title="Updating Metadata, Key Rollover, and Revocation">
      <t>
	This specification allows for a smooth process of updating metadata
        and public keys.
      </t>
      <t>
	As described above in <xref target="trust_lifetime"/>,
        each trust chain has an expiration time.
        A consumer of metadata using this specification MUST support
        refreshing a trust chain when it expires.
        How often a consumer SHOULD re-evaluate the trust chain depends on
        how quickly the consumer wants to find out that something has changed
        in the trust chain.
      </t>

      <section title="Protocol Key Rollover">
        <t>
	  If a leaf entity publishes its public keys in the metadata part
          using <spanx style="verb">jwks</spanx>, setting an expiration time on the self-signed entity
          statement can be used to control how often the remote party is
          fetching an updated version of the public key.
        </t>
        <t>
	  If a leaf entity uses <spanx style="verb">jwks_uri</spanx>, the remote party will in the normal
          OpenID Connect way fetch the keys anew from the <spanx style="verb">jwks_uri</spanx> URI when it
          discovers that the entity uses a key it has never seen before.
        </t>
      </section>

      <section title="Key Rollover for a Trust Anchor">
        <t>
	  A trust anchor must publish a self-signed entity statement about
          itself. As described above in <xref target="trust_chain"/>,
	  it should be at the end of the trust chain.
          The trust anchor SHOULD set a reasonable expiration
          time on that statement, such that the consumers will re-fetch the
          entity statement at reasonable intervals. If the trust root wants to
          roll over its signing keys it would have to:
	</t>
	<t>
          <list style="numbers">
            <t>
              Add the new keys to the <spanx style="verb">jwks</spanx> representing the trust
              anchors signing keys.
            </t>
            <t>
              Keep signing the entity statement using
              the old keys for a long enough time period to allow all
              subordinates to have gotten access to the new keys.
            </t>
            <t>
              Switch to signing with the new keys.
            </t>
            <t>
              After a reasonable time period remove the old keys. What is
              regarded as a reasonable time is dependent on the security profile
              and risk assessment of the trust anchor.
            </t>
          </list>
        </t>
        <t>
	  It must be taken into consideration that clients may have
          manually configured pubic keys as part of their configuration.
        </t>
      </section>

      <section title="Revocation">
        <t>
          Since the consumers are expected to check the trust chain at regular,
          reasonably frequent times, this specification does not specify a
          standard revocation process. Specific federations may make a
          different choice and will then have to add such a process.
        </t>
      </section>
    </section>

    <section title="OpenID Connect Communication">
      <t>
	This section describes how the trust framework in this specification
        is used to establish trust between an RP and an OP
        that has no explicit configuration or registration in advance.
      </t>
      <t>
	There are two alternative approaches to establish trust between an
        RP and an OP, which we call automatic and explicit
        registration. Members of a federation or a community
        should agree upon which one to use. While implementations should
        support both methods, deployments may choose to disable the use of one
        of them.
      </t>

      <section title="Automatic Registration" anchor="automatic">
        <figure>
          <preamble>
	    The trust between the entities is established using the
            above described extensions in the first two steps of the
            communication between an RP and an OP. How the RP found the OP in
            the first place is out of scope for this document.
          </preamble>
          <artwork><![CDATA[
------                                       ------
|    | <--- 1) Discovery ------------------> |    |
| RP | ---- 2) Authentication request -----> | OP |
|    |                                       |    |
------                                       ------     
]]></artwork>
        </figure>
        <t>
	  The <spanx style="verb">client_id</spanx> of the RP
	  MUST be set identically to the RP entity identifier.
        </t>
        <t>
	  Without a registration process, the RP does not have a
          client_secret. Instead the automatic registration model requires the RP
          to make use of asymmetric cryptography.
        </t>
        <t>
	  The RP MUST host a Federation API that allows the OP to fetch the
          entity statements.
        </t>

        <section title="The Authentication Request">
          <t>
	    The authentication request is as specified in OpenID Connect
            Core.
          </t>
          <t>
	    The RP MUST authenticate at the authentication endpoint
            using the private_key_jwt method described in the client
            authentication section of
            <xref target="OpenID.Core">OpenID Connect Core 1.0</xref>.
          </t>
	  <figure>
	    <preamble>
	      An authorization request example:
	    </preamble>
	    <artwork><![CDATA[
GET /authorization?
  redirect_uri=https%3A%2F%2Fexample.com%2Fauthz_cb
  &scope=openid+profile+email+address+phone
  &response_type=code
  &nonce=4LX0mFMxdBjkGmtx7a8WIOnB&state=JpRTpu9eGXiP4thsK ...
  &state=YmX8PM9I7WbNoMnnieKKBiptVW0sP2OZ
  &client_id=https%3A%2F%2Flocalhost%3A8090%2Firp
  &client_assertion=eyJhbGciOiJSUzI1NiIs ... qx7xHcvPOdIhnpg
  &client_assertion_type=
    urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
  HTTP/1.1
Host: https://example.org
]]></artwork>
	  </figure>
        </section>

        <section title="Processing the Authentication Request">
          <t>
	    When the OP receives an incoming authentication request,
            the OP supports OpenID Connect Federation and the incoming client_id
            is a valid URL, the OP should try to resolve and fetch trust
            chains starting with the RP's entity
            statement as described in <xref target="fetching-es"/>.
          </t>
          <t>
	    The OP should validate the possible trust chains, as described in
            <xref target="trust_chain_validation"/>,
            and resolve the RP metadata with type
            <spanx style="verb">openid_relying_party</spanx>.
          </t>
          <t>
	    The OP should consider the resolved metadata of the RP, and
            verify that it complies with the client metadata specification in
            <xref target="OpenID.Registration">OpenID Connect Dynamic Client Registration 1.0</xref>.
          </t>
          <t>
            Once the OP has the RP's metadata, it can verify the client authentication.
          </t>
        </section>

        <section title="Authentication Error Response">
          <t>
	    If the OP fails to establish trust with the RP, it should use the
            <spanx style="verb">invalid_request</spanx>
            error code, and an
            <spanx style="verb">error_description</spanx>
            that aids the RP to understand what is wrong.
          </t>
        </section>
      </section>

      <section title="Explicit Registration" anchor="explicit">
        <t>
	  This method involves performing an explicit registration of a new
          client the first time a RP interacts with an OP
          using something that basically follows the steps in
          <xref target="OpenID.Registration">OpenID Connect Dynamic Client Registration 1.0</xref>
          but where the client registration request
          is a signed entity statement.
        </t>

        <section title="Provider Discovery">
          <t>
	    The RP will start by gathering the OP's metadata using the
            process specified in <xref target="resolving_trust"/> above.
          </t>
        </section>

        <section anchor="Clireg" title="Client Registration">
          <section anchor="Cliregreq" title="Client Registration Request">
            <t>
	      The OP MUST support OpenID Dynamic Client Registration as extended by this specification.
	      This is signaled by having the claim
              <spanx style="verb">federation_registration_endpoint</spanx>
              in the OP's metadata.
            </t>
            <t>
	      Given that the OP supports explicit registration, the RP
              progresses as follows:
	    </t>
	    <t>
              <list style="numbers">
                <t>
		  Once it has the list of acceptable trust chains for the OP
                  it MUST choose the subset it wants to progress with. The
                  subset can be as small as one trust chain, but it can also
                  contain more than one.
                </t>
                <t>
		  Based on the trust anchors referenced in the subset of
                  trust chains, the RP will choose a set of <spanx style="verb">authority_hints</spanx> from
                  its own set that terminates in those trust anchors.
                </t>
                <t>
		  The RP will now construct a self-signed entity statement
                  where the metadata statement chosen is influenced by the OPs
                  metadata and the <spanx style="verb">authority_hints</spanx> included are picked by the
                  process described above.
                </t>
                <t>
		  The entity statement is sent to the
                  <spanx style="verb">federation_registration_endpoint</spanx>
                  defined in this document.
                </t>
              </list>
            </t>
          </section>

          <section anchor="cliregresp" title="Client Registration Response">
            <section title="The OP Constructing Response">
              <t>
                <list style="numbers">
                  <t>
		    After the OP receives the request, it collects and
                    evaluates
                    the trust chains starting with the <spanx style="verb">authority_hints</spanx> in the
                    registration request.
                    After it has verified at least one trust chain it
                    can verify that the signature on the received registration
                    request is correct.
                  </t>
                  <t>
		    If it finds more than one acceptable trust chain, it MUST
                    choose one trust anchor from those chains as the one it will
                    proceed with.
                  </t>
                  <t>
		    At this point, if there already exists a client
                    registration under the same entity ID then that registration
                    MUST be regarded as invalid. <spanx style="verb">Note</spanx> that key material from
                    the
                    previous registration MUST be kept to make key rollover
                    possible.
                  </t>
                  <t>
		    The OP will now construct a metadata policy that, if
                    applied to the RP's metadata statement, will result in
                    metadata that the OP finds acceptable.
                    <spanx style="verb">Note</spanx> that the client_id the OP chooses does not have to be
                    the same as the entity ID of the RP.
                    To the entity statement it will add one or more
                    <spanx style="verb">authority_hints</spanx>, from its collection, that terminate in the
                    trust anchor chosen above.
                  </t>
                  <t>
		    It will sign and return the registration response (a signed
                    entity statement) to the RP.
                  </t>
                </list>
              </t>
            </section>

            <section title="The RP Parsing the Response">
              <t>
                <list style="numbers">
                  <t>
		    The RP verifies the correctness of the received entity
                    statement, making sure that the trust chains starting at the
                    <spanx style="verb">authority_hints</spanx> terminates in trust anchors that were
                    referenced in the entity statement it sent to the OP.
                  </t>
                  <t>
		    The RP MUST NOT apply metadata policies from the trust
                    chains that the OP provides because those are not valid for
                    the RP's metadata.
                    The RP MUST apply policies to the metadata using one of its
                    own trust chains that ends in the trust anchor that the OP chose.
		    Once it has applied those policies it can the apply
                    the policy returned from the OP.
                    When it has applied all the metadata policies to its
                    metadata statement, it then stores
                    the result and can continue communicating with the OP
                    using the agreed-upon metadata.
                  </t>
                  <t>
		    At this point the RP also knows which trust chain it should
                    use when evaluating the OP's metadata. It can therefore
                    apply the metadata policies on the OP's metadata using the
                    relevant trust chain and store the result as the OPs
                    metadata.
                  </t>
                  <t>
		    If the RP was not OK, for some reason, with the received
                    entity statement then it has the choice to restart the
                    registration process or to give up.
                  </t>
                </list>
              </t>
            </section>
          </section>
        </section>

        <section title="After client registration">
          <t>
	    A client registration using this specification is not expected to
            be valid forever. The entity statements exchanged all have
            expiration times, which means that the registration will eventually
            time out. An OP can also for administrative reasons decide that a
            client registration is not valid anymore. An example of this could
            be that the OP leaves the federation in use.
          </t>

          <section title="What the RP MUST Do">
            <t>
	      At regular intervals the RP MUST:
	    </t>
	    <t>
              <list style="numbers">
                <t>
		  Starting with the OP's entity statement, resolve and verify
                  the trust chains it chooses to use when constructing the
                  registration request. If those trust chains do not exist
                  anymore or do not verify, then the registration should be
                  regarded as invalid and a new registration process should be
                  started.
                </t>
                <t>
		  If the OP's entity statement was properly formed the RP must
                  now verify that the entity statement it received about itself
                  from the OP is still valid.
                  Again, if that is not the case the registration
                  should be regarded as invalid and a new registration process
                  should be started.
                </t>
              </list>
            </t>
            <t>
              What is regarded as reasonable intervals will depend on
              federation policies and risk assessment by the maintainer of
              the RP.
            </t>
          </section>

          <section title="What the OP MUST Do">
            <t>
	      At regular intervals the OP MUST:
	    </t>
	    <t>
              <list style="numbers">
                <t>
                  If the signature on the registration request has expired it
                  MUST mark the registration as invalid and demand that the
                  RP MUST re-register. Else
                </t>
                <t>
                  starting with the RP's client registration request, the OP MUST
                  verify that there still is a valid trust chain terminating in
                  the trust anchor the OP chose during the registration process.
                </t>
              </list>
            </t>
          </section>
        </section>

        <section title="Expiration Times">
          <t>
	    An OP MUST NOT assign an expiration time
            to a RP's registration that is later then the trust
            chains expiration time.
          </t>
        </section>
      </section>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <t>
	TBD Register federation_types_supported for OP metadata with initial values automatic, explicit.
      </t>
      <t>
	TBD Register federation_type for RP registration metadata.
      </t>
      <t>
	TBD Register federation_registration_endpoint for the OP metadata.
      </t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>
	TBD
      </t>
    </section>
  </middle>

  <back>

    <references title="Normative References">
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3339.xml"?>
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5785.xml"?>
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6749.xml"?>
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7515.xml"?>
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7517.xml"?>
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7519.xml"?>
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7591.xml"?>
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8414.xml"?>

      <reference anchor="OpenID.Core"
                 target="http://openid.net/specs/openid-connect-core-1_0.html">
        <front>
          <title>OpenID Connect Discovery 1.0</title>

          <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
            <organization abbrev="NRI">Nomura Research Institute,
              Ltd.
            </organization>
          </author>

          <author fullname="John Bradley" initials="J." surname="Bradley">
            <organization abbrev="Ping Identity">Ping Identity</organization>
          </author>

          <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
            <organization abbrev="Microsoft">Microsoft</organization>
          </author>

          <author fullname="Breno de Medeiros" initials="B."
                  surname="de Medeiros">
            <organization abbrev="Google">Google</organization>
          </author>

          <author fullname="Chuck Mortimore" initials="C." surname="Mortimore">
            <organization abbrev="Salesforce">Salesforce</organization>
          </author>

          <date day="3" month="August" year="2015"/>
        </front>
      </reference>

      <reference anchor="OpenID.Discovery"
                 target="http://openid.net/specs/openid-connect-discovery-1_0.html">
        <front>
          <title>OpenID Connect Discovery 1.0</title>

          <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
            <organization abbrev="NRI">Nomura Research Institute,
              Ltd.
            </organization>
          </author>

          <author fullname="John Bradley" initials="J." surname="Bradley">
            <organization abbrev="Ping Identity">Ping Identity</organization>
          </author>

          <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
            <organization abbrev="Microsoft">Microsoft</organization>
          </author>

          <author fullname="Edmund Jay" initials="E." surname="Jay">
            <organization abbrev="Illumila">Illumila</organization>
          </author>

          <date day="3" month="August" year="2015"/>
        </front>
      </reference>

      <reference anchor="OpenID.Registration"
                 target="http://openid.net/specs/openid-connect-registration-1_0.html">
        <front>
          <title>OpenID Connect Dynamic Client Registration 1.0</title>

          <author fullname="Nat Sakimura" initials="N." surname="Sakimura">
            <organization abbrev="NRI">Nomura Research Institute,
              Ltd.
            </organization>
          </author>

          <author fullname="John Bradley" initials="J." surname="Bradley">
            <organization abbrev="Ping Identity">Ping Identity</organization>
          </author>

          <author fullname="Michael B. Jones" initials="M.B." surname="Jones">
            <organization abbrev="Microsoft">Microsoft</organization>
          </author>

          <date day="3" month="August" year="2015"/>
        </front>
      </reference>
    </references>

    <references title="Informative References">
      <?rfc include="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8446.xml"?>
    </references>

    <section title="Illustrative Example of OpenID Connect Flow Using Automatic Client Registration">
      <t>
	A service Foodle would like to offer its services to all OPs in
        eduGAIN. Foodle is managed and registered by the university
        NTNU. NTNU is part of the Norwegian Feide federation. Foodle is also
        directly trusted in the Swedish SWAMID federation. Both Feide and SWAMID
        are part of the international eduGAIN federation.
      </t>

      <section title="Initial Setup of Foodle">
        <t>
	  The Foodle service chooses to use the entity identifier
	  <spanx style="verb">https://foodl.org/</spanx>.
	  And upon deployment, Foodle
          is setup with an RSA key pair, with the following public key:
        </t>
        <figure>
          <artwork><![CDATA[
{
  "kid": "key1",
  "use": "sig",
  "kty": "RSA",
  "alg": "RS256",
  "n": "pnXBOusEANuug6ewezb9J_XbxbSGEISyA75wBGkerPNg6WTXmmxJ-DV1U4sCu
RqhSdo3Uncmw6-01bZKCtAyRHT_TOZN2TMfNPRsfLkOstVofyfxg5oIWViLX9IDG_iZVd
q6_T6yOuufOIvqpaeBMwSKuDXHNa_DU0aUu_3kOAc5_2hD4Dq-XXtum-oix2EPkNSbFfP
qFIp5n4gS1XrzGzuNQiDw82k-H6mWN0wlVWfqLxJA9DZikAX7x9feipn36wxDH-XUlzDD
Ui3nfnC8GSkT-CYII3oZPsIgMV527iQGVsehIV9KqTF2FnaP83cqV9YgvMfhs1wrx4L3Z
-3B8Q",
  "e": "AQAB",
  "key_ops": ["verify"],
  "ext": true
}
]]></artwork>
        </figure>
        <t>
	  Foodle offers a WebFinger interface and a metadata API according to
          this specification, with the ability to issue entity statements about
          itself.
        </t>
      </section>

      <section title="Federation Setup">
        <t>
	  How trust is established and how entities become part of a federation
          is out of scope of this specification. It could involve some kind
          of non-technical contract, agreement or term of use that is
          established, followed by a federation or trust issuer that registers
          an entity identifier, public key and a set of metadata that restricts
          the delegated trust that is represented in the entity statement about
          the joining party.
        </t>
        <t>
	  The following example, assumes the following trust relations are
          established, and the following entities are able to issue entity
          statements:
        </t>
        <t>
          <list style="symbols">
            <t>
	      Foodle issues an entity statement about itself
	    </t>
            <t>
	      NTNU issues an entity statement about Foodle
	    </t>
            <t>
	      SWAMID issues an entity statement about Foodle
	    </t>
            <t>
	      Feide issues an entity statement about NTNU
	    </t>
            <t>
	      eduGAIN issues an entity statement about Feide
	    </t>
            <t>
	      eduGAIN issues an entity statement about SWAMID
	    </t>
            <t>
          eudGAIN issues an entity statement about itself
        </t>
            <t>
	      SWAMID issues an entity statement about the university of Umea
              - an OP for employees and students at the university of Umea
            </t>
            <t>
                SWAMID issues an entity statement about itself
            </t>
          </list>
	</t>
	<t>
          Foodle has a local trust root configuration that contains public
          signing keys for known federations:
        </t>
        <figure>
          <preamble>
	    "https://www.sunet.se/swamid"
	  </preamble>
          <artwork><![CDATA[
{
  "keys": [
    {
      "kty": "RSA",
      "alg": "RS256",
      "n": "v6xydqciFKGfvQaqYGmk9A7etbfvNY...",
      "e": "AQAB",
      "key_ops": ["verify"],
      "ext": true,
      "kid": "9Gx7-Kkz_18DhpQ...",
      "use": "sig"
    }
  ]
}
]]></artwork>
        </figure>
      </section>

      <section title="User Chooses to Login at Foodle">
        <t>
	  Let us assume a student from Ume&aring; would like to login at
          Foodle. Some sort of discovery process involves the end user choosing
          an OP. OpenID Discovery using the e-mail address is one
          option. Foodle presenting a list of available OPs for the user
          to choose from is another.
        </t>
        <t>
	  After the discovery process, Foodle knows that the user would like
          to login using the OP with entity identifier
	  <spanx style="verb">https://www.umu.se/openid</spanx>.
        </t>
      </section>

      <section title="Foodle Discovers the OP">
        <t>
	  Foodle
          performs a request to fetch the self-issued entity statement using the
          Federation API of the OP.
        </t>
        <figure>
          <artwork><![CDATA[
GET /.well-known/openid-federation/openid?
iss=https%3A%2F%2Fumu.se%2Fopenid HTTP/1.1
Host: www.umu.se
]]></artwork>
        </figure>
	<t>
	  Yielding this response:
	</t>
        <figure>
          <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/json
"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6InVtdSJ9.eyJpYXQi..."
]]></artwork>
        </figure>

        <t>
	  The API endpoint returns a signed entity statement. In
          this case we looked for a self-issued statement from the Ume&aring;
          university. We then decode and inspect the content:
        </t>
        <figure>
          <artwork><![CDATA[
{
  "iat": 1539174048,
  "exp": 1539177648,
  "iss": "https://umu.se/openid",
  "sub": "https://umu.se/openid",
  "metadata": {
    "openid_provider": {
      "federation_types_supported": ["automatic", "explicit"],
      "authorization_endpoint":
        "https://idp.umu.se/openid/authorization",
      "token_endpoint": "https://idp.umu.se/openid/token",
      "response_types_supported": ["code", "code id_token", "token"],
      "grant_types_supported": [
        "authorization_code",
        "implicit",
        "urn:ietf:params:oauth:grant-type:jwt-bearer"
      ],
      "subject_types_supported": ["pairwise", "public"],
      "id_token_signing_alg_values_supported": ["RS256"],
      "logo_uri":
        "https://www.umu.se/img/umu-logo-left-neg-SE.svg",
      "policy_uri":
        "https://www.umu.se/en/website/legal-information/"
    }
  },
  "authority_hints": {
    "https://www.sunet.se/swamid": ["https://edugain.org/oidc"],
    "https://kalmar2.org/openid": []
  },
  "jwks": {
    "keys": [
      {
        "kty": "RSA",
        "alg": "RS256",
        "n": "z1V1kyi6qwmXfKsfhVqKUMmQH3AixN...",
        "e": "AQAB",
        "key_ops": ["verify"],
        "ext": true,
        "kid": "8S9-dy4GN8_-z...",
        "use": "sig"
      }
    ]
  }
}
]]></artwork>
        </figure>
      </section>

      <section title="Resolving the OP's Trust Chain">
        <t>
	  In order to establish trust with this OP, the Foodle RP
          would need to fetch sufficient entity statements to represent
          a complete chain from the self-issued statement to the locally
          configured trust root, which contains SWAMID.
        </t>
        <t>
	  The information found in the <spanx style="verb">authority_hints</spanx> is critical in order
          to dynamically discover the trust chain. If such hints are not
          present, the RP may fall back to fixed configured trust roots
          to ask for entity statements.
        </t>
        <t>
	  In this example, Foodle now fetches an entity statement from SWAMID
          using the Federation API endpoint of SWAMID, discovered in the
          <spanx style="verb">authority_hints</spanx> claim.
        </t>
        <figure>
          <artwork><![CDATA[
GET /.well-known/openid-federation?
iss=https%3A%2F%2Fwww.sunet.se%2Fswamid&
sub=https%3A%2F%2Fumu.se%2Fopenid HTTP/1.1
Host: www.sunet.se
]]></artwork>
        </figure>
	<t>
	  Yielding this response:
	</t>
        <figure>
          <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/json
"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImZlaWRlIn0.eyJpY..."
]]></artwork>
        </figure>

        <t>
	  The decoded version of the entity statement is:
	</t>
        <figure>
          <artwork><![CDATA[
{
  "iat": 1539174048,
  "exp": 1539177648,
  "metadata_policy": {
    "openid_provider": {
      "subject_types_supported": {
        "value": ["pairwise"]},
      "id_token_signing_alg_values_supported":{
          "subset_of": ["RS256", "RS512"],
          "default": ["RS256", "RS512"]
        }
      "organization": {
        "value": "University of Ume&aring;"},
      "contacts": {
        "add": ["legal@umu.se", "technical@umu.se"]}
    },
    "openid_relying_party": {}
  },
  "iss": "https://www.sunet.se/swamid",
  "sub": "https://umu.se/openid",
  "jwks": {
    "keys": [
      {
        "kty": "RSA",
        "alg": "RS256",
        "n": "v6xydqciFKGfvQaqYGmk9A7etbfvNY...",
        "e": "AQAB",
        "key_ops": ["verify"],
        "ext": true,
        "kid": "9Gx7-Kkz_18DhpQ...",
        "use": "sig"
      }
    ]
  },
  "authority_hints": {
    "https://www.sunet.se/swamid": ["https://www.sunet.se/swamid"]
  }
}
]]></artwork>
        </figure>
        <t>
	  Notice that the entity statement about University of Ume&aring;
          also contains an entry for openid_relying_party metadata. This metadata policy indicates that
          SWAMID expresses this university to be trusted to issue its own OpenID Relying Parties
	  and OpenID Providers without the need for registering these directly in SWAMID.
        </t>
          <t>
         	  The last step then is that Foodle now fetches an entity statement
              from SWAMID about SWAMID using the Federation API endpoint of
              SWAMID, discovered in the <spanx style="verb">authority_hints</spanx> claim.
          </t>
                  <figure>
          <artwork><![CDATA[
GET /.well-known/openid-federation?
iss=https%3A%2F%2Fwww.sunet.se%2Fswamid&
sub=https%3A%2F%2Fwww.sunet.se%2Fswamid HTTP/1.1
Host: www.sunet.se
]]></artwork>
        </figure>
	<t>
	  Yielding this response:
	</t>
        <figure>
          <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/json
"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImZlaWRlIn0.eyJpY..."
]]></artwork>
        </figure>

                  <t>
	  The decoded version of the entity statement is:
	</t>
        <figure>
          <artwork><![CDATA[
{
  "iat": 1539174050,
  "exp": 1539177650,
  "metadata": {
    "federation_entity": {
        "name": "SWAMID",
        "homepage_uri": "https://swamid.se/index.html"
    },
  },
  "iss": "https://www.sunet.se/swamid",
  "sub": "https://www.sunet.se/swamid",
  "jwks": {
    "keys": [
      {
        "e": "AQAB",
        "kid": "SnJJSVFodkFXOX...",
        "kty": "RSA",
        "n": "5uGR_-KKce9ycV6...",
        "use": "sig"
      }
    ]
  }
}
]]></artwork>
        </figure>
        <t>
	  These three entity statements are sufficient to establish a path from
          the locally configured trust anchor which trust SWAMID, to the
          self-issued statement from the University of Ume&aring;.
          Here are the steps performed to validate the trust chain:
        </t>
        <t>
          <list style="symbols">
            <t>
	      Find the trusted public keys for SWAMID in the local trust
              configuration.
            </t>
            <t>
	      Use these keys to validate the signature of the signed entity
              statement issued by SWAMID about SWAMID.
            </t>
              <t>
                  Extract the <spanx style="verb">jwks</spanx> entry from this entity statement.
                  These are the signing keys of SWAMID. If there are keys in this
                  field that do not appear in the local trust configuration,
                  add them to the local trust configuration.
                  This is a necessary step to allow SWAMID, in this case, to rotate their signing keys.
              </t>
            <t>
	      Use the SWAMID keys to validate the signature of the signed entity
              statement issued by SWAMID about the University of Ume&aring;.
            </t>
            <t>
	      Check that the <spanx style="verb">sub</spanx> from the trust configuration matches the <spanx style="verb">iss</spanx>
              value of the first entity statement.
            </t>
            <t>
	      Extract the <spanx style="verb">jwks</spanx> entry from this entity statement. These are
              the signing keys of the University of Ume&aring;.
            </t>
            <t>
	      Validate the self-signed statement from University of
              Ume&aring; using the keys found above.
            </t>
            <t>
	      Check that the <spanx style="verb">sub</spanx> from the previous statement matches the <spanx style="verb">iss</spanx>
              of the self-issued statement.
            </t>
            <t>
	      Check that the self-issued statement has the same values for
	      <spanx style="verb">iss</spanx> and <spanx style="verb">sub</spanx>.
            </t>
          </list>
        </t>
      </section>

      <section title="Extracting the OP metadata" anchor="extracting_op_metadata">
        <t>
	  The output from the trust chain validation is an ordered list of
          entity statements. In order to extract the needed metadata, we need to
          look at the metadata type relevant in the given context. In this case,
          we are establishing trust with an OP, and we take the
          <spanx style="verb">openid_provider</spanx>
          metadata object from the
          entity statement published by the OP and the policy statements from
          the other entities in the trust chain:
        </t>
	<figure>
	  <preamble>
	    SWAMID's metadata policy for an openid_provider:
	  </preamble>
	  <artwork><![CDATA[
{}
]]></artwork>
	</figure>
	<figure>
	  <preamble>
	    UMU's metadata policy for an openid_provider:
	  </preamble>
	  <artwork><![CDATA[
{
  "subject_types_supported": {"value": ["pairwise"]},
  "id_token_signing_alg_values_supported":
    {
      "subset_of": ["RS256", "RS512"],
      "default": ["RS256", "RS512"]
    }
  "organization": {"value": "University of Ume&aring;"},
  "contacts": {"add": ["legal@umu.se", "technical@umu.se"]}
}
]]></artwork>
	</figure>
	<t>
          and finally
	</t>
	<figure>
	  <preamble>
	    The OP's metadata statement:
	  </preamble>
	  <artwork><![CDATA[
{
  "authorization_endpoint":
    "https://idp.umu.se/openid/authorization",
  "token_endpoint": "https://idp.umu.se/openid/token",
  "response_types_supported": ["code", "code id_token", "token"],
  "grant_types_supported": [
    "authorization_code",
    "implicit",
    "urn:ietf:params:oauth:grant-type:jwt-bearer"
  ],
  "subject_types_supported": ["pairwise", "public"],
  "id_token_signing_alg_values_supported": ["RS256"],
  "logo_uri":
      "https://www.umu.se/SRWStatic/img/umu-logo-left-neg-SE.svg",
  "policy_uri":
      "https://www.umu.se/en/about-the-website/legal-information/"
}
]]></artwork>
	</figure>
        <t>
	  Applying the metadata policies to the metadata
          produces the following result:
        </t>
	<figure>
	  <artwork><![CDATA[
{
  "organization": "University of Ume&aring;",
  "contacts": ["legal@umu.se", "technical@umu.se"],
  "logo_uri":
    "https://www.umu.se/SRWStatic/img/umu-logo-left-neg-SE.svg",
  "policy_uri":
    "https://www.umu.se/en/about-the-website/legal-information/",
  "authorization_endpoint":
    "https://idp.umu.se/openid/authorization",
  "token_endpoint": "https://idp.umu.se/openid/token",
  "response_types_supported": ["code", "code id_token", "token"],
  "grant_types_supported": [
    "authorization_code",
    "implicit",
    "urn:ietf:params:oauth:grant-type:jwt-bearer"
  ],
  "subject_types_supported": ["pairwise"],
  "id_token_signing_alg_values_supported": ["RS256"]
}
]]></artwork>
	</figure>
      </section>

      <section title="RP Sends Authentication Request (Automatic Registration)">
        <t>
	  Foodle after establishing trust with the University of
          Ume&aring;
          and extracted metadata and a set of metadata policies, will send an
          authentication request to the OP.
	  This example uses automatic registration.
        </t>
        <t>
	  Here is an example of an authentication request:
	</t>
	<figure>
            <artwork><![CDATA[
GET /authorize?
  response_type=code
  &scope=openid%20profile%20email
  &client_id=https%3A%2F%2Ffoodl.org%2F
  &state=2ff7e589-3848-46da-a3d2-949e1235e671
  &redirect_uri=https%3A%2F%2Ffoodl.org%2Fopenid%2Fcallback
  &client_assertion=eyJhbGciOiJSUzI1NiIs ... qx7xHcvPOdIhnpg
  &client_assertion_type=
    urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
  HTTP/1.1
Host: idp.umu.se
]]></artwork>
	</figure>
        <t>
	  The OP receiving this authentication request will, unless the
          RP is cached or statically configured, start to dynamically fetch and
          establish trust with the RP.
        </t>
      </section>

      <section title="OP Fetches Entity Statements">
        <t>
	  The OP needs to establish a trust chain for the RP from which an
          authentication was received. The OP in this example are configured
          with public key of 2 federations:
        </t>
	<figure>
	  <preamble>
	    "https://edugain.org/oidc"
	  </preamble>
	  <artwork><![CDATA[
 {
  "keys": [
    {
      "kty": "RSA",
      "use": "sig",
      "alg": "RS256",
      "n": "qnd5_krrHKzuJzb5_YEt4sP-YOGSbf...",
      "e": "AQAB",
      "key_ops": ["verify"],
      "ext": true,
      "kid": "SX7_-Q0heLZq6T..."
    }
  ]
}
]]></artwork>
	</figure>
	<!-- TBD Consider adding a second key to some of the examples. -->
	<t>
          and
	</t>
	<figure>
	  <preamble>
	    "https://www.sunet.se/swamid"
	  </preamble>
	  <artwork><![CDATA[
{
  "keys": [
    {
      "kty": "RSA",
      "alg": "RS256",
      "n": "v6xydqciFKGfvQaqYGmk9A7etbfvNY...",
      "e": "AQAB",
      "key_ops": ["verify"],
      "ext": true,
      "kid": "9Gx7-Kkz_18DhpQ...",
      "use": "sig"
    }
  ]
}
]]></artwork>
	</figure>
      </section>

      <section title="RP Fetches Entity Statements">
        <t>
	  The RP starts to resolve metadata for the client identifier
          https://foodl.org/ by fetching the self-issued entity statement using
          the Federation API, as described in <xref target="fetching-es"/>.
        </t>
        <t>
	  In this case, there are two possible trust chains:
	</t>
        <t>
          <list style="symbols">
            <t>
	      eduGAIN -&gt; Feide -&gt; NTNU -&gt; Foodle
	    </t>
            <t>
	      SWAMID -&gt; Foodle
	    </t>
          </list>
        </t>
      </section>
    </section>

    <section title="Illustrative Example of OpenID Connect Flow Using Explicit Client Registration">
      <t>
        A research project has pooled resources and bought an extremely rare
        and expensive equipment (EREE) that MUST be accessible by all project
        participants disregarding which university/research
        organization/company they belong for.
        To that end, the research project has created its own federation (EREE)
        and is expecting the participants to get their organization's OPs to
        register with the EREE federation.
        These OPs are, of course, expected to be members in one or more other
        federations.
        Therefore, we have to an EREE service and an EREE federation.
        Since the EREE equipment is located in Sweden, the EREE service is also
        member of the SWAMID federation.
      </t>

      <section title="Initial Setup of the EREE Service">
        <t>
	  The EREE service choose to use the entity identifier
	  <spanx style="verb">https://srv.eree.example.org/</spanx>. And upon
          deployment, EREE is setup with an elliptic curve key pair, with the
          following public key:
        </t>
	<figure>
	  <artwork><![CDATA[
{
  "keys": [
    {
      "kty": "EC",
      "use": "sig",
      "kid":
        "bmRkVmk0QUY3UUdnM3NDekI4VGptRUIxVk5lRXIyVE9rRUZpMUpNbGJ...",
      "crv": "P-256",
      "x": "ypFDCBLLT7lRP8UPo12ycnIkyFjeL1yco_Iu7VZoeDk",
      "y": "1sO4UIY1Iil0_PYobPKhuhs5ocQqVWYCujXcfo47epg"
    }
  ]
}
]]></artwork>
	</figure>
        <t>
          The EREE service is provided files containing <spanx style="verb">authority_hints</spanx> by its
          superiors. From the EREE federation it gets:
	</t>
	<figure>
	  <artwork><![CDATA[
{"https://eree.example.org":["https://eree.example.org"]}
]]></artwork>
	</figure>
        <t>
          from SWAMID:
	</t>
	<figure>
	  <artwork><![CDATA[
{"https://swamid.se":["https://swamid.se"]}
]]></artwork>
	</figure>
        <t>
          and from UNINETT:
	</t>
	<figure>
	  <artwork><![CDATA[
{"https://uninett.no":["https://uninett.no"]}
]]></artwork>
	</figure>
        <t>
	  and so on...
	</t>
        <t>
          On the federations side:
	</t>
	<t>
          <list style="symbols">
            <t>
	      SWAMID is prepared to issue an entity statement about the EREE
              service.
            </t>
            <t>
	      The EREE federation is prepared to issue an entity statement
              about the EREE service.
            </t>
            <t>
	      UNINETT is prepared to issue an entity statement about the EREE
              service.
            </t>
          </list>
        </t>
        <t>
	  And finally, from the federations the EREE service also receives the
          public part of the federations signing keys.
        </t>
      </section>

      <section title="Researcher Wants to Start a Job at the EREE Service">
        <t>
	  A researcher from Ume&aring; wants to access the EREE service.
          The EREE service provides a discovery service which allows the
          researcher to choose which OP to use. In this case,
          <spanx style="verb">https://op.umu.se/</spanx>.
        </t>
      </section>

      <section title="The EREE RP Discovers and Initiates Explicit Registration">
        <section title="The EREE RP Discovers the OpenID Provider">
          <t>
            Using the entity ID (issuer ID) of the OP the service
            performs a fetch entity statement request as described in
            <xref target="fetch_statement"/>.
          </t>
	  <figure>
	    <artwork><![CDATA[
 GET
 /.well-known/openid-federation?iss=https%3A%2F%2Fop.umu.se
 HTTP/1.1
 Host: op.umu.se
]]></artwork>
	  </figure>
	  <figure>
	    <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/json

eyJhbGciOiJFUzI1NiIsImtpZCI6IlFVOUxUbkpzTjJ4VVRYQkZSM040T1Z...
]]></artwork>
	  </figure>
          <t>
	    The decoded version of the entity statement is:
	  </t>
	  <figure>
	    <artwork><![CDATA[
{
  "authority_hints": {
    "https://eree.example.org": [
      "https://eree.example.org"
    ],
    "https://swamid.se": [
      "https://swamid.se"
    ]
  },
  "exp": 1543851936,
  "iat": 1543247136,
  "iss": "https://op.umu.se",
  "sub": "https://op.umu.se",
  "jwks": {
    "keys": [
      {
        "crv": "P-256",
        "kid":
          "QU9LTnJsN2xUTXBFR3N4OVZOeTlyejFrWWthYWlaTllYMDR...",
        "kty": "EC",
        "use": "sig",
        "x": "DU6e1SjvW3Gqcd7up-n8s1N6Zlm2cNlZjYqL3O36v1A",
        "y": "pEtk0_fSKN56V-2hDnzFUbaw8-v0QBjNoT2KaZ7pqIc"
      }
    ]
  },
  "metadata": {
    "openid_provider": {
      "federation_types_supported": ["explicit"],
      "authorization_endpoint":
        "https://op.umu.se/authorization",
      "federation_registration_endpoint":
        "https://op.umu.se/fedreg",
      "grant_types_supported": [
        "authorization_code",
        "implicit",
        "urn:ietf:params:oauth:grant-type:jwt-bearer"
      ],
      "id_token_signing_alg_values_supported": [
        "RS256"
      ],
      "logo_uri":
        "https://www.umu.se/img/umu-logo-left-neg-SE.svg",
      "policy_uri":
        "https://www.umu.se/en/website/legal-information/",
      "response_types_supported": [
        "code",
        "code id_token",
        "token"
      ],
      "subject_types_supported": [
        "pairwise",
        "public"
      ],
      "token_endpoint": "https://op.umu.se/token",
      "userinfo_endpoint": "https://op.umu.se/user"
    }
  }
}
]]></artwork>
	  </figure>
        </section>

        <section title="Resolving the OP's Trust Chain">
          <t>
            In order to establish trust with this OP, the EREE service
            provider would need to fetch sufficient entity statements to
            represent a complete chain from the self-issued statement to the
            trust anchor that represents the EREE federations.
          </t>
          <t>
            The <spanx style="verb">authority_hints</spanx> in the self-signed entity statement points to
            2 trust anchors "https://eree.example.org" and "https://swamid.se"
            of these only the <spanx style="verb">EREE</spanx> one is interesting.
	    The RP therefore chooses
            to only follow that trust path. The next step being to fetch an
            entity statement about "https://op.umu.se" signed by the EREE
            federation. This is done by doing a fetch entity statement:
	  </t>
	  <figure>
	    <artwork><![CDATA[
GET
/.well-known/openid-federation?
iss=https%3A%2F%2Feree.example.org&
sub=https%3A%2F%2Fop.umu.se HTTP/1.1
Host: eree.example.org
]]></artwork>
	  </figure>
	  <figure>
	    <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/json

eyJhbGciOiJFUzI1NiIsImtpZCI6IlFuRlJWMEZ6YjE5NVdW...
]]></artwork>
	  </figure>
          <t>
	    The decoded version of the returned entity statement is:
	  </t>
	  <figure>
	    <artwork><![CDATA[
{
  "exp": 1543852816,
  "iat": 1543248016,
  "iss": "https://eree.example.org/",
  "jwks": {
    "keys": [
      {
        "crv": "P-256",
        "kid":
        "QU9LTnJsN2xUTXBFR3N4OVZOeTlyejFrWWthYWlaTllYMDRXSk",
        "kty": "EC",
        "use": "sig",
        "x": "DU6e1SjvW3Gqcd7up-n8s1N6Zlm2cNlZjYqL3O36v1A",
        "y": "pEtk0_fSKN56V-2hDnzFUbaw8-v0QBjNoT2KaZ7pqIc"
      }
    ]
  },
  "metadata_policy": {
    "openid_provider": {}
  },
  "sub": "https://op.umu.se",
  "authority_hints": {
    "https://eree.example.org": [
      "https://eree.example.org"
    ]
  }
}
]]></artwork>
	  </figure>
                      <t>
            A thing worth noting about the response:
	  </t>
	  <t>
            <list style="symbols">
              <t>
                The federation does not have any restrictions on what the OP can
                be configured to do. This means that there are no metadata
                policies to apply to the metadata statement of the OP.
              </t>
            </list>
          </t>
            <t>
                The final step is to get the federation's view of itself:
            </t>
	  <figure>
	    <artwork><![CDATA[
GET
/.well-known/openid-federation?
iss=https%3A%2F%2Feree.example.org&
sub=https%3A%2F%2Feree.example.org HTTP/1.1
Host: eree.example.org
]]></artwork>
	  </figure>
            <t>With the response:</t>
	  <figure>
	    <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/json

eyJhbGciOiJFUzI1NiIsImtpZCI6IlFuRlJWMEZ6YjE5NVdW...
]]></artwork>
	  </figure>
          <t>
	    The decoded version of the returned entity statement is:
	  </t>
	  <figure>
	    <artwork><![CDATA[
{
  "exp": 1543852820,
  "iat": 1543248020,
  "iss": "https://eree.example.org/",
  "sub": "https://eree.example.org/",
  "jwks": {
    "keys": [
      {
        "crv": "P-256",
        "kid": "QnRSZUlvUWJ6UHdoU0V0VmFoOWs0d...",
        "kty": "EC",
        "x": "Dy8Va4JFw419muNj1gEYb3cF9xNonrY1PfpEEyqKH6A",
        "y": "lbLVj3opCTspgrySmBVvSPwgxRTCAJUfqZMcN3b0Wvk"
        "use": "sig",
      }
    ]
  },
  "metadata": {
    "federation_entity": {
        "name": "Extremely rare and expensive equipment",
        "homepage_uri": "https://www.eree.org/index.html"
    },
  }
}
]]></artwork>
	  </figure>

          <t>
            A thing worth noting about the response:
	  </t>
	  <t>
            <list style="symbols">
              <t>
		There is no <spanx style="verb">authority_hints</spanx> entry,
		which means this entity statement describes a trust anchor.
	      </t>
            </list>
          </t>
        </section>

        <section title="Validating the Trust Chain">
          <t>
	    These three entity statements are sufficient to establish a path from
            the locally configured trust anchor that trusts the EREE federation,
            to the self-issued statement from the OP at the
            University
            of Ume&aring;. Here are the steps performed to validate the trust
            chain, as described in <xref target="trust_chain_validation"/>.
            We start with the signed entity statement issued by EREE about
              itself.
	  </t>
	  <t>
            <list style="numbers">
              <t>
		Verify that the <spanx style="verb">sub</spanx> in the entity statement is the EREE's entity
                ID.
              </t>
                <t>
                    Extract the <spanx style="verb">jwks</spanx> from the entity statement
                    and add possible extra keys in it to the trusted public keys for the EREE federation.
                </t>
              <t>
                  Move on to the entity statement issued by EREE about the OP.
		Verify that the <spanx style="verb">sub</spanx> in the entity statement is the OP's entity
                ID.
              </t>
              <t>
		Use the trusted public keys for the EREE federation to validate the signature of the signed entity
                statement.
              </t>
              <t>
                  Extract the <spanx style="verb">jwks</spanx> from the entity statement.
              </t>
            </list>
	  </t>
	  <t>
            Now we can work on the self-signed entity statement published by
            the OP at UmU.
	  </t>
	  <t>
            <list style="numbers">
              <t>
		Verify that the <spanx style="verb">sub</spanx> and the <spanx style="verb">iss</spanx> in the entity statement is
                the OP's entity ID.
              </t>
              <t>
		Using the keys extracted above, verify the signature of the
                signed entity statement.
              </t>
            </list>
          </t>
        </section>

        <section title="Extracting the OP's Metadata">
          <t>
            The output from the trust chain validation is an ordered list of
            entity statements. In order to extract the needed metadata, we need
            to look at the metadata type relevant in the given context. In this
            case, we are establishing trust with an OP, and we use
            the <spanx style="verb">openid_provider</spanx> metadata and
	    <spanx style="verb">metadata_policy</spanx> objects
            of the trust chain.
	  </t>
	  <figure>
	    <preamble>
	      Metadata polices:
	    </preamble>
	    <artwork><![CDATA[
  {}
]]></artwork>
	  </figure>

	  <figure>
	    <preamble>
	      Metadata statement:
	    </preamble>
	    <artwork><![CDATA[
  {
    "authorization_endpoint":
    "https://op.umu.se/authorization",
    "federation_registration_endpoint":
      "https://op.umu.se/fedreg",
    "grant_types_supported": [
      "authorization_code",
      "implicit",
      "urn:ietf:params:oauth:grant-type:jwt-bearer"
    ],
    "id_token_signing_alg_values_supported": [
      "RS256"
    ],
    "logo_uri":
      "https://www.umu.se/img/umu-logo-left-neg-SE.svg",
    "policy_uri":
      "https://www.umu.se/en/website/legal-information/",
    "response_types_supported": [
      "code",
      "code id_token",
      "token"
    ],
    "subject_types_supported": [
      "pairwise",
      "public"
    ],
    "token_endpoint": "https://op.umu.se/token",
    "userinfo_endpoint": "https://op.umu.se/user"
  }
]]></artwork>
	  </figure>
          <t>
            Since there is no metadata policy defined earlier in the trust chain,
	    the response will just be the metadata statement as it is.
          </t>
        </section>

        <section title="EREE RP Does Federated Client Registration">
          <t>
            Now when the RP has trusted information about the OP it can do a
            dynamic client registration. To that end it collects information
            about
            itself that it wants to register. This should be no different from
            what a normal OpenID Connect RP using dynamic client registration does.
	    To this it adds "federation_type"="explicit", the RP
            federation signing keys, the <spanx style="verb">sub</spanx> and <spanx style="verb">authority_hints</spanx>.
            Ones it has all that information it
            creates an entity statement. The result of all this work may look
            something like this:
	  </t>
	  <figure>
	    <artwork><![CDATA[
{
  "authority_hints": {
    "https://eree.example.org": [
      "https://eree.example.org"
    ]
  },
  "jwks": {
    "keys": [
      {
        "crv": "P-256",
        "kid":
          "bmRkVmk0QUY3UUdnM3NDekI4VGptRUIxVk5lRXIyVE9rRUZpMUpNb...",
        "kty": "EC",
        "use": "sig",
        "x": "ypFDCBLLT7lRP8UPo12ycnIkyFjeL1yco_Iu7VZoeDk",
        "y": "1sO4UIY1Iil0_PYobPKhuhs5ocQqVWYCujXcfo47epg"
      }
    ]
  },
  "metadata": {
    "openid_relying_party": {
      "federation_type": "explicit",
      "application_type": "web",
      "request_object_signing_alg": "ES256",
      "response_types": [
        "code"
      ],
      "scope": [
        "openid",
        "email"
      ],
      "token_endpoint_auth_method": "private_key_jwt",
      "token_endpoint_auth_signing_alg": "ES256",
      "userinfo_signed_response_alg": "ES256"
    }
  },
  "iss": "https://rp.eree.example.org",
  "sub": "https://rp.eree.example.org"
}
]]></artwork>
	  </figure>
          <t>
	    Next, it self-signs this statement and sends it as a client
            registration request to the <spanx style="verb">federation_registration_endpoint</spanx> of
            the OP.
          </t>
        </section>
      </section>

      <section title="The OP Processes a Client Registration Request">
        <section title="The OP Gathers the RP's Trust Chains">
          <t>
            To collect the trust chains, the OP uses the <spanx style="verb">authority_hints</spanx> in the
            self-signed entity statement it received from the RP (the client
            registration request).
          </t>
          <t>
            In this case, there is only one, which points to
            <spanx style="verb">https://eree.example.org</spanx>.
	    Therefore, the OP fetches the entity
            statement that the EREE federation publishes on the EREE RP.
	  </t>
	  <figure>
	    <artwork><![CDATA[
GET
/.well-known/openid-federation?
iss=https%3A%2F%2Feree.example.org&
sub=https%3A%2F%2Frp.eree.example.org HTTP/1.1
Host: eree.example.org
]]></artwork>
	  </figure>
          <t>
            With the response:
	  </t>
	  <figure>
	    <artwork><![CDATA[
HTTP/1.1 200 OK
Content-Type: application/json

eyJhbGciOiJFUzI1NiIsImtpZCI6IlFuRlJWMEZ6YjE5NVd...
]]></artwork>
	  </figure>
          <t>
            Unpacked this becomes:
          </t>
	  <figure>
	    <artwork><![CDATA[
{
  "exp": 1543865440,
  "iat": 1543260640,
  "iss": "https://eree.example.org",
  "jwks": {
    "keys": [
      {
        "crv": "P-256",
        "kid":
          "bmRkVmk0QUY3UUdnM3NDekI4VGptRUIxVk5lRXIyVE9rRUZpM...",
        "kty": "EC",
        "use": "sig",
        "x": "ypFDCBLLT7lRP8UPo12ycnIkyFjeL1yco_Iu7VZoeDk",
        "y": "1sO4UIY1Iil0_PYobPKhuhs5ocQqVWYCujXcfo47epg"
      }
    ]
  },
  "metadata_policy": {
    "openid_relying_party": {
      "federation_type": "explicit",
      "application_type": {"value": "web"},
      "request_object_signing_alg": {"value":"ES256"},
      "response_types": {"subset_of":["code"]},
      "scope": {"subset_of":["openid","email"]},
      "token_endpoint_auth_method":
        {"value": "private_key_jwt"},
      "token_endpoint_auth_signing_alg":
        {"value":"ES256"},
      "userinfo_signed_response_alg":
        {"value": "ES256"}
    }
  },
  "sub": "https://rp.eree.example.org"
}
]]></artwork>
	  </figure>
        </section>

        <section title="Validating the Trust Chain">
          <t>
            The process here is the one described in
            <xref target="trust_chain_validation"/>.
          </t>
        </section>

        <section title="Extracting RP Metadata">
          <t>
            The OP applies the metadata policies on the leaf entity's
            metadata, all from the trust chain and comes up with:
	  </t>
	  <figure>
	    <artwork><![CDATA[
{
  "application_type": "web",
  "application_name": "EREE",
  "contacts": ["ops@eree.example.org"],
  "jwks_uri": "https://rp.eree.example.org/static/jwks.json",
  "redirect_uris": [
    "https://rp.eree.example.org/authz_cb"
  ],
  "request_object_signing_alg": "ES256",
  "response_types": [
    "code"
  ],
  "scope": [
    "openid",
    "email"
  ],
  "token_endpoint_auth_method": "private_key_jwt",
  "token_endpoint_auth_signing_alg": "ES256",
  "userinfo_signed_response_alg": "ES256"
}
]]></artwork>
	  </figure>
        </section>

        <section title="Constructing the Registration Response">
          <t>
            Happy with the information in the client registration request the
            OP constructs its metadata policy and creates an entity statement by
            adding <spanx style="verb">sub</spanx> and <spanx style="verb">authority_hints</spanx>:
	  </t>
	  <figure>
	    <artwork><![CDATA[
{
  "authority_hints": {
    "https://eree.example.org": [
      "https://eree.example.org"
    ]
  },
  "exp": 1543931097,
  "iat": 1543326297,
  "iss": "https://op.umu.se",
  "metadata_policy": {
    "openid_relying_party": {
      "client_id": {"value": "FjeL1yco_Iu7VZoeDk"}
    }
  },
  "sub": "https://rp.eree.example.org"
}
]]></artwork>
	  </figure>
        </section>
      </section>

      <section title="The RP Processes the Registration Response">
        <t>
          The RP MUST collect the trust chain ending in the EREE trust anchor
          using the process described in <xref target="resolving_trust"/>,
          but refrain from processing
          the metadata. This since the entity statement issued by the EREE
          federation about the UmU OP are only valid for that entity and not
          for the EREE RP. The trust chain should only be used to verify that
          the entity statement actually comes from the expected OP.
        </t>
        <t>
          If the RP is OK with what the OP decided on regarding the RP's
          metadata, then it will store this to be used in the following OpenID Connect
          protocol exchange with the OP.
        </t>
        <t>
          In this example, the RP decided on one specific trust anchor before
          sending the registration request. If that was not the case but the
          RP had chosen to send a registration request with more than one
          authority hint, then this by time the RP could not apply any
          metadata polices to the metadata statement, since it would not know
          which to use.
        </t>
      </section>
    </section>

    <section anchor="Notices" title="Notices">
      <t>
	Copyright (c) 2019 The OpenID Foundation.
      </t>
      <t>
	The OpenID Foundation (OIDF) grants to any Contributor, developer,
        implementer, or other interested party a non-exclusive, royalty free,
        worldwide copyright license to reproduce, prepare derivative works from,
        distribute, perform and display, this Implementers Draft or Final
        Specification solely for the purposes of (i) developing specifications,
        and (ii) implementing Implementers Drafts and Final Specifications based
        on such documents, provided that attribution be made to the OIDF as the
        source of the material, but that such attribution does not indicate an
        endorsement by the OIDF.
      </t>
      <t>
	The technology described in this specification was made available
        from contributions from various sources, including members of the OpenID
        Foundation and others. Although the OpenID Foundation has taken steps to
        help ensure that the technology is available for distribution, it takes
        no position regarding the validity or scope of any intellectual property
        or other rights that might be claimed to pertain to the implementation
        or use of the technology described in this specification or the extent
        to which any license under such rights might or might not be available;
        neither does it represent that it has made any independent effort to
        identify any such rights. The OpenID Foundation and the contributors to
        this specification make no (and hereby expressly disclaim any)
        warranties (express, implied, or otherwise), including implied
        warranties of merchantability, non-infringement, fitness for a
        particular purpose, or title, related to this specification, and the
        entire risk as to implementing this specification is assumed by the
        implementer. The OpenID Intellectual Property Rights policy requires
        contributors to offer a patent promise not to assert certain patent
        claims against other contributors and against implementers. The OpenID
        Foundation invites any interested party to bring to its attention any
        copyrights, patents, patent applications, or other proprietary rights
        that may cover technology that may be required to practice this
        specification.
      </t>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>
	The authors wish to acknowledge the contributions of the following individuals and organizations to this specification:
	Heather Flanagan,
	Misha Salle,
	Peter Schober,
	Michael Schwartz,
	and
	the JRA3T3 task force of GEANT4-2.
      </t>
    </section>

    <section anchor="TBD" title="Open Issues">
      <t>
	The following open issues remain to be addressed in this specification.
      </t>
      <t>
	<list style="symbols">
	  <t>
	    The representation for RPs that are native applications needs to be defined.
	  </t>
	  <t>
	    How are federation operator keys retrieved?
	  </t>
          <t>
	    A mechanism is needed for key rotation of federation operator keys
	    for long-term security and maintainability of federations.
	  </t>
	  <t>
	    A mechanism may be needed for bounding key lifetimes.
	  </t>
	  <t>
	    Discuss that key IDs may be chosen as the JWK Thumbprint [RFC 7638] of the key.
	  </t>
	  <t>
	    Discuss localization of human-readable strings.
	  </t>
	  <t>
	    SAML2 as used in Research and Education federations uses post-/prefix
	    matching on metadata in some cases. We might need something
	    similar or just use regular expressions.
	  </t>
	  <t>
	    Define the relationship between trust roots and Federation Operators,
	    as people will expect to find the Federation Operator term in the specification.
	  </t>
	  <t>
	    Add a diagram showing the relationships between FOs, orgs, sub-orgs, and leaf entities.
	  </t>
        </list>
      </t>
    </section>

    <section anchor="History" title="Document History">
      <t>[[ To be removed from the final specification ]]</t>

      <t>
	-08
        <list style="symbols">
          <t>
	    Incorporated review feedback from Michael B. Jones.
	    Major changes were as follows.
	  </t>
	  <t>
	    Deleted <spanx style="verb">sub_is_leaf</spanx> entity statement since it was redundant.
	  </t>
	  <t>
	    Added <spanx style="verb">federation_type</spanx> RP registration metadata value
	    and <spanx style="verb">federation_types_supported</spanx> OP metadata value.
	  </t>
	  <t>
	    Deleted <spanx style="verb">openid_discovery</spanx> metadata type identifier
	    since its purpose is already served by <spanx style="verb">openid_provider</spanx>.
	  </t>
	  <t>
	    Entity identifier paths are now included when using the Federation API,
	    enabling use in multi-tenant deployments sharing a common domain name.
	  </t>
	  <t>
	    Renamed <spanx style="verb">sub_is_leaf</spanx> to <spanx style="verb">is_leaf</spanx>
	    in the Entity Listings Request operation parameters.
	  </t>
	  <t>
	    Added <spanx style="verb">crit</spanx> and <spanx style="verb">policy_language_crit</spanx>,
	    enabling control over which entity statement and policy language extensions
	    MUST be understood and processed.
	  </t>
	  <t>
	    Renamed <spanx style="verb">openid_client</spanx> to <spanx style="verb">openid_relying_party</spanx>.
	  </t>
	  <t>
	    Renamed <spanx style="verb">oauth_service</spanx> to <spanx style="verb">oauth_authorization_server</spanx>.
	  </t>
	  <t>
	    Renamed <spanx style="verb">implicit</spanx> registration to <spanx style="verb">automatic</spanx> registration
	    to avoid naming confusion with the implicit grant type.
	  </t>
	  <t>
	    Renamed <spanx style="verb">op</spanx> to <spanx style="verb">operation</spanx>
	    to avoid naming confusion with the use of "OP" as an acronym for "OpenID Provider".
	  </t>
	  <t>
	    Renamed <spanx style="verb">url</spanx> to <spanx style="verb">uri</spanx> in several identifiers.
	  </t>
	  <t>
	    Restored Open Issues appendix.
	  </t>
	  <t>
	    Corrected document formatting issues.
	  </t>
        </list>
      </t>
      <t>
	-07
        <list style="symbols">
          <t>
	    Split metadata into metadata and metadata_policy
	  </t>
          <t>
	    Updated example
	  </t>
        </list>
      </t>
      <t>
	-06
        <list style="symbols">
          <t>
	    Some rewrites
	  </t>
          <t>
	    Added example of explicit client registration
	  </t>
        </list>
      </t>
      <t>
	-05
        <list style="symbols">
          <t>
	    A major rewrite.
	  </t>
        </list>
      </t>
      <t>
	-04
        <list style="symbols">
          <t>
	    Changed client metadata names
            <spanx style="verb">scopes</spanx>
            to <spanx style="verb">rp_scopes</spanx> and
            <spanx style="verb">claims</spanx>
            to <spanx style="verb">rp_claims</spanx>.
          </t>
          <t>
	    Added Open Issues appendix.
	  </t>
          <t>
	    Added additional references.
	  </t>
          <t>
	    Editorial improvements.
	  </t>
          <t>
	    Added standard Notices section, which is present in all OpenID
            specifications.
          </t>
        </list>
      </t>
    </section>
  </back>
</rfc>
