<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='http://xml.resource.org/authoring/rfc2629.xslt' ?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="std" docName="draft-hunt-scim-mv-filtering-00" ipr="trust200902">
  <front>
    <title abbrev="draft-hunt-scim-mv-filtering">SCIM Protocol: Multi-Value Filtering Extension</title>

    <author fullname="Phil Hunt" initials="P." role="editor" surname="Hunt">
      <organization abbrev="IndependentId">Independent Identity Inc.</organization>

      <address>
        <email>phil.hunt@independentid.com</email>
      </address>
    </author>

      <date month="October" year="2021"/>

    <keyword>SCIM</keyword>

    <abstract>
      <t>The System for Cross-Domain Identity Management (SCIM) specifications
          define a profile of HTTP protocol and a schema that enable managing
          identities in cross-domain scenarios. This specification extends SCIM
          protocol resource retrieval and query functions to enable paging and filtering
          of multi-valued attributes in a SCIM service provider resource.</t>

    </abstract>
  </front>

  <middle>
    <section anchor="intro" title="Introduction and Overview" toc="default">
        <t>SCIM Protocol <xref target="RFC7644"/> is an application-level, HTTP
            protocol for provisioning and managing identity data on the web and
            in cross-domain environments such as enterprise to cloud, or
            inter-cloud scenarios. The protocol supports creation, modification,
            retrieval, and discovery of core identity resources such as Users
            and Groups, as well as custom resources and resource extensions.</t>

        <t>The definition of resources, attributes, and overall schema are
            defined in the SCIM Core Schema document (see <xref target="RFC7643"/>).</t>

        <t> This specification extends SCIM resource retrieval and query
            functions to enable filtering and paging of mulit-valued attributes.
            For example, attributes that may contain
            large numbers of values such as a SCIM Group.</t>

      <section title="Intended Audience" toc="default">
        <t>This document is intended as a guide to extend SCIM protocol usage
            for
        both SCIM HTTP service providers and HTTP clients who may provision
        information to service providers or retrieve information from
        them.</t>
      </section>

      <section anchor="notat" title="Notational Conventions" toc="default">
        <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"/>. These keywords are capitalized when used to
        unambiguously specify requirements of the protocol or application
        features and behavior that affect the interoperability and security of
        implementations. When these words are not capitalized, they are meant
        in their natural-language sense.</t>

        <t>For purposes of readability examples are not URL encoded.
        Implementers MUST percent encode URLs as described in <xref
        target="RFC3986">Section 2.1 of</xref>.</t>

        <t>Throughout this documents all figures may contain spaces and extra
        line-wrapping for readability and space limitations. Similarly, some
        URI's contained within examples, have been shortened for space and
        readability reasons.</t>
      </section>

      <section anchor="defs" title="Definitions" toc="default">
        <t>This specification uses the definitions from the SCIM Schema Specification <xref
        target="RFC7643"/> and the SCIM Protocol Specification <xref target="RFC7644"/>. </t>
      </section>
    </section>

      <section anchor="mv-extension" title="Multi-Value Paging Extension">
        <t>Detecting the availability of multi-valued attribute filtering and paging
              extension is covered in <xref target="discovery"/>.</t>

        <t>When supported, returned values for multi-valued attributes can
              be filtered or paged using filters and/or paging parameters
              appended to attributes specified in the SCIM <spanx
              style="verb">attributes</spanx> parameter. Attributes listed in
              the attributes parameter MAY be appended with value qualifiers
              using square brackets("[ ]") that contains a <spanx style="verb">
                  valFilter</spanx>
              (see Figure 1 <xref target="RFC7644"/>), paging parameters
              (see
              Section 3.9 <xref target="RFC7644"/>), or a combination of both
              separated by the <spanx style="verb">&amp;</spanx> character.
        </t>

        <t>In order to qualify specific attributes without changing the
              default list of attributes returned for a query, an asterix
              <spanx style="verb">*</spanx> MAY be used in the attributes
              parameter to indicate the default set of attributes is to be
              returned in addition to any specific attributes listed. For
              example: <spanx style="verb">attributes=*,members[type eq
                  "user"]</spanx> specifies all default attributes are to be
              returned and only values of <spanx style="verb">members</spanx>
              which have <spanx style="verb">type</spanx> set to <spanx
              style="verb">user</spanx>.
        </t>

        <t>
              When an attribute has a multi-value filter or paging qualifier,
              the service provider SHALL include additional <spanx style="verb">
              meta</spanx> sub-attributes (see Section 3.1 of <xref
              target="RFC7643"/>). The name of the multi-valued attribute plus
              the String <spanx style="verb">cnt</spanx> is used to indicate
              the count of attribute values available expressed as an Integer (see
              Section 2.3.4 of <xref target="RFC7643"/>). When a
              <spanx style="verb">valFilter</spanx> expression is used, the
              number SHALL indicate the total number of matches that may be
              returned based on the filter. When no filter expression is
              specified, the number SHALL indicate the total number of values.
              For an example, see
              <spanx style="verb">emails.cnt</spanx> in<xref target="F2"/>.
              This count indicates that there is only one value with <spanx
              style="verb">type</spanx> equal to <spanx style="verb">work
              </spanx>.
        </t>

        <t>
              When <spanx style="verb">startIndex</spanx> is used as an
              attribute paging qualifier and the value is greater than the
              number of values, the server SHALL omit the attribute from the
              result to indicate no values exist at that index.
        </t>

        <figure anchor="F1" align="left" alt="" height="" suppress-title="false"
                    title="Using a filter to return only work email values"
                width="">
            <preamble>In the following example, a user is returned, but only <spanx style="verb">work</spanx>
                  emails are to be returned.</preamble>
            <artwork align="left" alt="" height="" name="" type="" width=""
                     xml:space="preserve">
GET /Users/2819c223-7f76-453a-919d-413861904646? \
    attributes=*,emails[type eq \"work\"]
Host: example.com
Accept: application/scim+json
Authorization: Bearer h480djs93hd8</artwork>
        </figure>

        <figure anchor="F2" align="left" alt="" height=""
                  suppress-title="false" title="Response with filtered emails attribute" width="">
            <preamble>The service provider responds with:</preamble>
            <artwork align="left" alt="" height="" name="" type="" width=""
                     xml:space="preserve">HTTP/1.1 200 OK
Content-Type: application/scim+json
Location:
  https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646
ETag: W/"f250dd84f0671c3"

{
  "schemas":["urn:ietf:params:scim:schemas:core:2.0:User"],
  "id":"2819c223-7f76-453a-919d-413861904646",
  "externalId":"bjensen",
  "meta":{
    "resourceType":"User",
    "created":"2011-08-01T18:29:49.793Z",
    "lastModified":"2011-08-01T18:29:49.793Z",
    "location":
"https://example.com/v2/Users/2819c223-7f76-453a-919d-413861904646",
    "version":"W\/\"f250dd84f0671c3\"",
    "emails.cnt":1
  },
  "name":{
    "formatted":"Ms. Barbara J Jensen III",
    "familyName":"Jensen",
    "givenName":"Barbara"
  },
  "userName":"bjensen",
  "phoneNumbers":[
    {
      "value":"555-555-8377",
      "type":"work"
    }
  ],
  "emails":[
    {
      "value":"bjensen@example.com",
      "type":"work"
    }
  ]
}</artwork>
        </figure>

        <figure anchor="F3" align="left" alt="" height="" suppress-title="false"
                    title="Querying multiple groups with attribute qualifiers"
                width="">
            <preamble>In the following example, all Groups are searched and
                only Groups whose name starts with "Group" are selected.
                Additionally, the members attribute values are filtered return
                only member values with <spanx style="verb">type</spanx>
                equal to <spanx style="verb">groups</spanx> (as in sub-groups)
                returning only the first 5 values using the attributes paging
                qualifying parameters.</preamble>
            <artwork align="left" alt="" height="" name="" type="" width=""
                     xml:space="preserve">GET /v2/Groups?filter=displayName sw 'Group'&amp; \
    attributes=*,members[type eq \"Group\"&amp;count=5&amp;startIndex=1]
Host: example.com
Accept: application/scim+json
Authorization: Bearer h480djs93hd8</artwork>
        </figure>

        <figure anchor="F4" align="left" alt="" height="" suppress-title="false"
                    title="Returning multiple results with paged attribute values" width="">
              <preamble>The server responds with 2 matched resources. The first
                  resource only has one Group member value, while the second
                  resource has 7 member values and has been limited to the first
                  5 members per the
                  <spanx style="verb">count</spanx> paging parameter
                  .</preamble>
              <artwork align="left" alt="" height="" name="" type="" width=""
                     xml:space="preserve">HTTP/1.1 200 OK
Content-Type: application/scim+json

{
  "schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
  "totalResults": 2,
  "Resources": [
    {
      "id": "c3a26dd3-27a0-4dec-a2ac-ce211e105f97",
      "schemas": ["urn:ietf:params:scim:schemas:core:2.0:Group"],
      "displayName": "Group A",
      "meta": {
        "resourceType": "Group",
        "created": "2011-08-01T18:29:49.793Z",
        "lastModified": "2011-08-01T18:29:51.135Z",
        "location":
"https://example.com/v2/Groups/c3a26dd3-27a0-4dec-a2ac-ce211e105f97",
        "version": "W\/\"mvwNGaxB5SDq074p\"",
        "members.cnt":1
      },
      "members": [
        {
          "value": "6c5bb468-14b2-4183-baf2-06d523e03bd3",
          "$ref":
"https://example.com/v2/Groups/6c5bb468-14b2-4183-baf2-06d523e03bd3",
          "type": "Group"
        }
      ]
    },
    {
      "id": "6c5bb468-14b2-4183-baf2-06d523e03bd3",
      "schemas": ["urn:ietf:params:scim:schemas:core:2.0:Group"],
      "displayName": "Group B",
      "meta": {
        "resourceType": "Group",
        "created": "2011-08-01T18:29:50.873Z",
        "lastModified": "2011-08-01T18:29:50.873Z",
        "location":
"https://example.com/v2/Groups/6c5bb468-14b2-4183-baf2-06d523e03bd3",
        "version": "W\/\"wGB85s2QJMjiNnuI\"",
        "members.cnt":7
      },
      "members": [
        {
          "value": "c3a26dd3-27a0-4dec-a2ac-ce211e105f97",
          "$ref":
"https://example.com/v2/Groups/c3a26dd3-27a0-4dec-a2ac-ce211e105f97",
          "type": "Group"
        }
        {
          "value": "596ec090-2f66-4d3e-ad4c-68d9ac05ad53",
          "$ref":
"https://example.com/v2/Groups/596ec090-2f66-4d3e-ad4c-68d9ac05ad53",
          "type": "Group"
        }
        {
          "value": "aaf4c421-ceba-4ce0-a119-3d62418f5f9f",
          "$ref":
"https://example.com/v2/Groups/aaf4c421-ceba-4ce0-a119-3d62418f5f9f",
          "type": "Group"
        }
        {
          "value": "58b64358-82e7-4a77-a8eb-9c6d644f9752",
          "$ref":
"https://example.com/v2/Groups/58b64358-82e7-4a77-a8eb-9c6d644f9752",
          "type": "Group"
        }
        {
          "value": "3e32ee8c-246c-42ab-a750-2c2e84d57f1f",
          "$ref":
"https://example.com/v2/Groups/3e32ee8c-246c-42ab-a750-2c2e84d57f1f",
          "type": "Group"
        }
      ]
    }
  ]
}</artwork>
        </figure>

        <t>In <xref target="F3"/> the client may observe that the number
                of matches available for the second Group (whose <spanx
                style="verb">id</spanx> is <spanx style="verb">6c5bb468-14b2-4183-baf2-06d523e03bd3</spanx>)
                is 7. In <xref
                target="F4"/>,
                the client may return the second page, by repeating the query
                with <spanx style="verb">startIndex</spanx> set to 6.
        </t>

        <figure anchor="F5" align="left" alt="" height="" suppress-title="false"
                    title="Query returning the second page of values for an attribute" width="">
            <preamble>In the following example, paging of member values of a
                specific group is requested.</preamble>
            <artwork align="left" alt="" height="" name="" type="" width=""
                     xml:space="preserve">GET /v2/Groups/6c5bb468-14b2-4183-baf2-06d523e03bd3? \
    attributes=*,members[type eq \"Group\"&amp;count=5&amp;startIndex=6]
Host: example.com
Accept: application/scim+json
Authorization: Bearer h480djs93hd8</artwork>
        </figure>

        <figure anchor="F6" align="left" alt="" height="" suppress-title="false"
                    title="Returning the second page of values for an attribute" width="">
            <artwork align="left" alt="" height="" name="" type="" width=""
                     xml:space="preserve">HTTP/1.1 200 OK
Content-Type: application/scim+json
Location:
 https://example.com/v2/Groups/e9e30dba-f08f-4109-8486-d5c6a331660a
ETag: W/"lha5bbazU3fNvfe5"

{
  "id": "6c5bb468-14b2-4183-baf2-06d523e03bd3",

  "schemas": ["urn:ietf:params:scim:schemas:core:2.0:Group"],
  "displayName": "Group B",
  "meta": {
    "resourceType": "Group",
    "created": "2011-08-01T18:29:50.873Z",
    "lastModified": "2011-08-01T18:29:50.873Z",
    "location":
"https://example.com/v2/Groups/6c5bb468-14b2-4183-baf2-06d523e03bd3",
    "version": "W\/\"wGB85s2QJMjiNnuI\"",
    "members.cnt":7
  },

  "members": [
    {
      "value": "596ec090-2f66-4d3e-ad4c-68d9ac05ad53",
      "$ref":
"https://example.com/v2/Groups/596ec090-2f66-4d3e-ad4c-68d9ac05ad53",
      "type": "Group"
    }
    {
      "value": "2e6afed5-282d-4563-83dc-9ef7183b0003",
      "$ref":
"https://example.com/v2/Groups/2e6afed5-282d-4563-83dc-9ef7183b0003",
      "type": "Group"
    }
  ]
}</artwork>
        </figure>

      </section>

      <section anchor="discovery" title="Service Provider Configuration Feature Discovery">
          <t>Multi-value paging support may be determined by querying the
          <spanx style="verb">/ServiceProviderConfig</spanx> endpoint and
              looking up the Boolean attribute <spanx style="verb">mvpaging</spanx>
              indicating support for multi-valued paging and filtering.</t>
      </section>


    <section anchor="Security" title="Security Considerations" toc="default">
     <t>To be completed</t>

    </section>
    <section title="Privacy Considerations">
      <t>To be completed.</t>
    </section>


    <section anchor="IANA" title="IANA Considerations">
      <t>No IANA considerations.</t>


    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml' ?>


      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml' ?>

      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.7643.xml'?>

      <?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.7644.xml'?>


    </references>




    <section title="Acknowledgments">
      <t>This draft is an updated submission based on the original ID draft-hunt-scim-mv-paging-00 contributed by
      Phil Hunt and Gregg Wilson.</t>

    </section>

    <section title="Change Log">
      <t>[[This section to be removed prior to publication as an RFC]]</t>

      <t>Draft 00 - PH - Initial draft</t>

    </section>
  </back>
</rfc>
