<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc rfcedstyle="yes"?>
<?rfc subcompact="no"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="no" ?>
<rfc number="5361" category="std">

  <front>
    <title abbrev="Permission Document Format">A Document Format for Requesting Consent</title>

    <author initials="G." surname="Camarillo" fullname="Gonzalo
                Camarillo">
      <organization>Ericsson</organization>
      <address>
	<postal>
          <street>Hirsalantie 11</street>
	  <code>02420</code> 
	  <city>Jorvas</city> 
	  <country>Finland</country>
 	</postal>
	<email>Gonzalo.Camarillo@ericsson.com</email>
      </address>
    </author>

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

    <area>RAI</area>
    <workgroup>SIPPING</workgroup>

<!-- [rfced] Please insert any keywords (beyond those that appear in
the title) for use on http://www.rfc-editor.org/rfcsearch.html. -->
<keyword>example</keyword>

    <abstract>
      <t>
This document defines an Extensible Markup Language (XML) format for a
permission document used to request consent. A permission document
written in this format is used by a relay to request a specific
recipient permission to perform a particular routing translation. 
      </t>
    </abstract>
  </front>

  <middle>

<section title="Introduction">
<t>
The framework for consent-based communications in the Session
Initiation Protocol (SIP) <xref
target="RFC5360"/> identifies the need for a
format to create permission documents. Such permission documents are
used by SIP <xref target="RFC3261"/> relays to request permission to
perform translations. A relay is defined as any SIP server, be it a
proxy, B2BUA (Back-to-Back User Agent), or some hybrid, which receives
a request and translates the Request-URI into one or more next-hop
URIs to which it then delivers a request. 
</t>
<t>
The format for permission documents specified in this document is
based on Common Policy <xref target="RFC4745"/>, an XML document
format for expressing privacy preferences. 
</t>
</section>

<section title="Definitions and Terminology">
<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"/>.
</t>
<t>
This document uses the terms defined in <xref
target="RFC5360"/>.  For completeness, these
terms are repeated here. Figure 1 of <xref
target="RFC5360"/> shows the relationship
between target and recipient URIs in a translation operation.
</t>
<t>
<list style="hanging">

<t hangText="Recipient URI:"><vspace blankLines="1"/> The Request-URI
of an outgoing request sent by an entity (e.g., a user agent or a
proxy). The sending of such request can have been the result of a
translation operation.</t>

<t hangText="Relay:"><vspace blankLines="1"/> Any SIP server, be it a
proxy, B2BUA (Back-to-Back User Agent), or some hybrid, that receives
a request, translates its Request-URI into one or more next-hop URIs
(i.e., recipient URIs), and delivers the request to those
  URIs.</t>

<t hangText="Target URI:"><vspace blankLines="1"/> The Request-URI of
an incoming request that arrives to a relay that will perform a
translation operation.</t>

<t hangText="Translation logic:"><vspace blankLines="1"/> The logic
that defines a translation operation at a relay. This logic includes
the translation's target and recipient URIs.</t>

<t hangText="Translation operation:"><vspace blankLines="1"/>
Operation by which a relay translates the Request-URI of an incoming
request (i.e., the target URI) into one or more URIs (i.e., recipient
URIs) that are used as the Request-URIs of one or more outgoing
requests.</t>

</list>
</t>

</section>

<section title="Permission Document Structure" anchor="sec-structure">

<t>
A permission document is an XML document, formatted according to the
schema defined in <xref target="RFC4745"/>. Permission documents
inherit the MIME type of common policy documents,
'application/auth-policy+xml'. As described in <xref
target="RFC4745"/>, this type of document is composed of three parts:
conditions, actions, and transformations. 
</t>
<t>
This section defines the new conditions and actions defined by this
specification. This specification does not define any new
transformation. 
</t>

<section title="Conditions" anchor="sec-structure-conditions">

<t>
The conditions in a permission document are a set of expressions, each
of which evaluates to either TRUE or FALSE. Note that, as discussed in
<xref target="RFC4745"/>, a permission document applies to a
translation if all the expressions in its conditions part evaluate to
TRUE.
</t>

<section title="Recipient Condition" 
anchor="sec-structure-conditions-identity">
<t>
The recipient condition is matched against the recipient URI of a
translation. Recipient conditions can contain the same elements and
attributes as identity conditions.
</t>
<t>
When performing a translation, a relay matches the recipient condition
of the permission document that was used to request permission for
that translation against the destination URI of the outgoing request.
When receiving a request granting or denying permissions (e.g., a SIP
PUBLISH request as described in <xref
target="RFC5360"/>), the relay matches the
recipient condition of the permission document that was used to
request permission against the identity of the entity granting or
denying permissions (i.e., the sender of the PUBLISH request). If
there is a match, the recipient condition evaluates to
TRUE. Otherwise, the recipient condition evaluates to FALSE.
</t>
<t>
Since only authenticated identities can be matched, this section
defines acceptable means of authentication, which are in line with
those described in Section 5.6.1 of <xref
target="RFC5360"/>.
</t>
<t>
The 'id' attribute in the elements &lt;one&gt; and &lt;except&gt; MUST
contain a scheme when these elements appear in a permission document.
</t>
<t>
When used with SIP, a recipient granting or denying a relay
permissions is considered authenticated if one of the following
techniques is used:
</t>
<t>
<list style="hanging">

<t hangText="SIP Identity"><xref target="RFC4474"/>, as described in
Section 5.6.1.1 of <xref
target="RFC5360"/>. For PUBLISH requests that
are authenticated using the SIP Identity mechanism, the identity of
the sender of the PUBLISH request is equal to the SIP URI in the From
header field of the request, assuming that the signature in the
Identity header field has been validated. </t>

<t hangText="P-Asserted-Identity"><xref target="RFC3325"/> (which can
only be used in closed network environments) as described in Section
5.6.1.2 of <xref target="RFC5360"/>. For
PUBLISH requests that are authenticated using the P-Asserted-Identity
mechanism, the identity of the sender of the PUBLISH request is equal
to the P-Asserted-Identity header field of the request. </t>

<t hangText="Return Routability Test,">as described in Section
5.6.1.3 of <xref target="RFC5360"/>. It can be
used for SIP PUBLISH and HTTP GET requests. No authentication is
expected to be used with return routability tests and, therefore, no
identity matching procedures are defined.</t>

<t hangText="SIP digest,">as described in Section 5.6.1.4 of <xref
target="RFC5360"/>. The identity of the sender
is set equal to the SIP Address of Record (AOR) for the user that has
authenticated themselves.
</t>
</list>
</t>

</section>

<section title="Identity Condition" anchor="sec-structure-conditions-sender">
<t>
The identity condition, which is defined in <xref target="RFC4745"/>,
is matched against the URI of the sender of the request that is used
as input for a translation.
</t>
<t>
When performing a translation, a relay matches the identity condition
against the identity of the sender of the incoming request.  If they
match, the identity condition evaluates to TRUE. Otherwise, the
identity condition evaluates to FALSE.
</t>
<t> 
Since only authenticated identities can be matched, the following
subsections define acceptable means of authentication, the procedure
for representing the identity of the sender as a URI, and the
procedure for converting an identifier of the form user@domain,
present in the 'id' attribute of the &lt;one&gt; and &lt;except&gt;
elements, into a URI.
</t>

<section title="Acceptable Means of Authentication"
anchor="sec-structure-conditions-sender-auth">
<t>
When used with SIP, a request sent by a sender is considered
authenticated if one of the following techniques is used: 
</t>
<t>
<list style="hanging">

<t hangText="SIP Digest:"> the relay authenticates the sender using
SIP digest authentication <xref target="RFC2617"/>. However, if the
anonymous authentication described on page 194 of <xref
target="RFC3261"/> is used, the sender is not considered
authenticated. 
</t>

<t hangText="Asserted Identity:"> if a request contains a
P-Asserted-ID header field <xref target="RFC3325"/> and the request is
coming from a trusted element, the sender is considered
authenticated. 
</t>

<t hangText="Cryptographically Verified Identity:"> if a request
contains an Identity header field as defined in <xref
target="RFC4474"/>, and it validates the From header field of the
request, the request is considered to be authenticated.  Note that
this is true even if the request contained a From header field of the
form sip:anonymous@example.com. As long as the signature verifies that
the request legitimately came from this identity, it is considered
authenticated. 
</t>
</list>
</t>

</section>

<section title="Computing a URI for the Sender"
anchor="sec-structure-conditions-sender-uri">
<t>
For requests that are authenticated using SIP Digest, the identity of
the sender is set equal to the SIP Address of Record (AOR) for the
user that has authenticated themselves. For example, consider the
following "user record" in a database:
</t>
<artwork>
   SIP AOR: sip:alice@example.com 
   digest username: ali 
   digest password: f779ajvvh8a6s6 
   digest realm: example.com 
</artwork>
<t>
If the relay receives a request and challenges it with the realm set to
"example.com", and the subsequent request contains an Authorization
header field with a username of "ali" and a digest response generated
with the password "f779ajvvh8a6s6", the identity used in matching
operations is "sip:alice@example.com". 
</t>
<t>
For requests that are authenticated using <xref target="RFC3325"/>,
the identity of the sender is equal to the SIP URI in the
P-Asserted-ID header field. If there are multiple values for the
P-Asserted-ID header field (there can be one sip URI and one tel URI
<xref target="RFC3966"/>), then each of them is used for the
comparisons outlined in <xref target="RFC4745"/>; if either of
them match a &lt;one&gt; or &lt;except&gt; element, it is considered a
match.
</t>
<t>
For requests that are authenticated using the SIP Identity mechanism
<xref target="RFC4474"/>, identity of the sender is equal to the SIP
URI in the From header field of the request, assuming that the
signature in the Identity header field has been validated. 
</t>
<t>
SIP also allows for anonymous requests. If a request is anonymous
because the digest challenge/response used the "anonymous" username,
the request is considered unauthenticated and will not match the
&lt;identity&gt; condition. If a request is anonymous because it
contains a Privacy header field <xref target="RFC3323"/>, but still
contains a P-Asserted-ID header field, the identity in the
P-Asserted-ID header field is still used in the authorization
computations; the fact that the request was anonymous has no impact on
the identity processing. However, if the request had traversed a trust
boundary and the P-Asserted-ID header field and the Privacy header
field had been removed, the request will be considered unauthenticated
when it arrives at the relay, and thus not match the &lt;sender&gt;
condition. Finally, if a request contained an Identity header field
that was validated, and the From header field contained a URI of the
form sip:anonymous@example.com, then the sender is considered
authenticated, and it will have an identity equal to
sip:anonymous@example.com. Had such an identity been placed into a
&lt;one&gt; or &lt;except&gt; element, there will be a match.
</t>
</section>

<section title="Computing a SIP URI from the id Attribute"
anchor="sec-structure-conditions-sender-id">
<t>
If the &lt;one&gt; or &lt;except&gt; condition does not contain a
scheme, conversion of the value in the 'id' attribute to a SIP URI is
done trivially.  If the characters in the 'id' attribute are valid
characters for the user and hostpart components of the SIP URI, a
'sip:' is appended to the contents of the 'id' attribute, and the
result is the SIP URI. If the characters in the 'id' attribute are not
valid for the user and hostpart components of the SIP URI, conversion
is not possible and, thus, the identity condition evaluates to
FALSE. This happens, for example, when the user portion of the 'id'
attribute contains UTF-8 characters.
</t>
</section>

</section>


<section title="Target Condition" anchor="sec-structure-conditions-target">
<t>
The target condition is matched against the target URI of a
translation. The target condition can contain the same elements and
attributes as identity conditions. 
</t>
<t>
When performing a translation, a relay matches the target condition
against the destination of the incoming request, which is typically
contained in the Request-URI. If they match, the target condition
evaluates to TRUE. Otherwise, the target condition evaluates to FALSE.
</t>
</section>

<section title="Validity Condition">
<t>
The &lt;validity&gt; element is not applicable to this document. Each
&lt;permission&gt; element has an infinite lifetime and can be revoked using
an independent mechanism, as described in Section 5.8 of <xref
target="RFC5360"/>. In any case, as discussed
in Section 4.1 of <xref target="RFC5360"/>,
permissions are only valid as long as the context where they were
granted is valid. If present, &lt;validity&gt; elements MUST be
ignored.
</t>
</section>

<section title="Sphere Condition">
<t>
The &lt;sphere&gt; element is not applicable to this document and
therefore is not used.  If present, &lt;sphere&gt; elements MUST be
ignored.
</t>
</section>

</section>


<section title="Actions" anchor="sec-structure-actions">
<t>
The actions in a permission document provide URIs to grant or deny
permission to perform the translation described in the document. 
</t>
<t>
<list style="hanging">
<t>
Note that the &lt;trans-handling&gt; element is not an action, as
defined in Common Policy <xref target="RFC4745"/>, but rather an
informational element. Therefore, the conflict resolution mechanism
does not apply to it.
</t>
</list>
</t>
<t> 
Each policy rule contains at least two &lt;trans-handling&gt;
elements; one element with a URI to grant and another with a URI to
deny permission.
</t>

<section title="Translation Handling" anchor="sec-structure-actions-handling">
<t> 
The &lt;trans-handling&gt; provides URIs for a recipient to grant
or deny the relay permission to perform a translation. The defined
values are: 
</t>
<t>
<list style="hanging">
<t hangText="deny:"> this action tells the relay not to perform the
translation. </t>

<t hangText="grant:"> this action tells the server to perform the translation. </t>
</list>
</t>
<t>
The 'perm-uri' attribute in the &lt;trans-handling&gt; element
provides a URI to grant or deny permission to perform a translation.
</t>

</section>

</section>

</section>


<section title="Example Document" anchor="sec-example">
<t>
In the following example, a client adds 'sip:bob@example.org' to the
translation whose target URI is 'sip:alices-friends@example.com'. The
relay handling the translation generates the following permission
document in order to ask for permission to relay requests sent to
'sip:alices-friends@example.com' to 'sip:bob@example.org'. The target
URI is 'sip:alices-friends@example.com', and the recipient URI is
'sip:bob@example.org'. The sender's identity does not play a role in
this example. Therefore, the permission document does not put any
restriction on potential senders.
</t>
      
  <t><figure> 
      <artwork>
        <![CDATA[
+--------+        +--------------------------------+  Permission 
|        |        |                                |   Request   
| Client |        |             Relay              |    with
|        |        | sip:alices-friends@example.com |  Permission
+--------+        |                                |   Document
    |             |+-------+                       |-------------+
    |             ||Transl.|                       |             |
    |Manipulation ||Logic  |                       |             |
    +------------>|+-------+                       |             | 
         Add      +--------------------------------+             | 
   sip:bob@example.org                                           V
                                               +---------------------+
                                               |                     |
                                               |      Recipient      |
                                               | sip:bob@example.org |
                                               |                     |
                                               +---------------------+
]]></artwork>
  </figure>
  </t>
   
<t><figure>
      <artwork>
        <![CDATA[
<?xml version="1.0" encoding="UTF-8"?>    
       <cp:ruleset
           xmlns="urn:ietf:params:xml:ns:consent-rules"
           xmlns:cp="urn:ietf:params:xml:ns:common-policy"
           <cp:rule id="f1">
        <cp:conditions>
            <cp:identity>
                <cp:many/>
            </cp:identity>
            <recipient>
                <cp:one id="sip:bob@example.org"/>
            </recipient>
            <target>
                <cp:one id="sip:alices-friends@example.com"/>
            </target>
        </cp:conditions>
        <cp:actions>
            <trans-handling
                perm-uri="sips:grant-1awdch5Fasddfce34@example.com"
                >grant</trans-handling>
            <trans-handling
                perm-uri="https://example.com/grant-1awdch5Fasddfce34"
                >grant</trans-handling>
            <trans-handling
                perm-uri="sips:deny-23rCsdfgvdT5sdfgye@example.com"
                >deny</trans-handling>
            <trans-handling
                perm-uri="https://example.com/deny-23rCsdfgvdT5sdfgye"
                >deny</trans-handling>
        </cp:actions>
        <cp:transformations/>
    </cp:rule>
    </cp:ruleset>
]]></artwork>
</figure>
  
</t>
      
</section>

<?rfc needLines="20"?>
<section title="XML Schema" anchor="sec-schema">

      <artwork>
        <![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
   <xs:schema
     targetNamespace="urn:ietf:params:xml:ns:consent-rules"
     xmlns:cr="urn:ietf:params:xml:ns:consent-rules"
     xmlns:cp="urn:ietf:params:xml:ns:common-policy"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     elementFormDefault="qualified"
     attributeFormDefault="unqualified">

     <!-- Conditions -->
     <xs:element name="recipient" type="cp:identityType"/>
     <xs:element name="target" type="cp:identityType"/>

    <!-- Actions -->
    <xs:simpleType name="trans-values">
       <xs:restriction base="xs:string">
         <xs:enumeration value="deny"/>
         <xs:enumeration value="grant"/>
       </xs:restriction>
     </xs:simpleType>

     <xs:element name="trans-handling">
       <xs:complexType>
         <xs:simpleContent>
           <xs:extension base="trans-values">
             <xs:attribute name="perm-uri" type="xs:anyURI"
                           use="required"/>
           </xs:extension>
         </xs:simpleContent>
       </xs:complexType>
     </xs:element>

   </xs:schema>
]]></artwork>

</section>

<section title="Extensibility" anchor="sec-schema-extensions">
<t>
This specification defines elements that do not have extension points
in the "urn:ietf:params:xml:ns:consent-rules" namespace. Instance
documents that utilize these element definitions SHOULD be schema
valid. Applications processing instance documents with content that is
not understood by the application MUST ignore that content. IETF
extension documents of this specification MAY reuse the
"urn:ietf:params:xml:ns:consent-rules" namespace to define new
elements.
</t>
</section>

<section title="IANA Considerations" anchor="sec-iana">
<t>
This section registers a new XML namespace and a new XML schema per
the procedures in <xref target="RFC3688"/>. 
</t>

<section title="XML Namespace Registration" anchor="sec-iana-namespace">
<t>
<list style="hanging">
<t hangText="URI:">urn:ietf:params:xml:ns:consent-rules </t>

<t hangText="Registrant Contact:">IETF SIPPING working group &lt;sipping@ietf.org&gt;,
<vspace blankLines="0"/>
Gonzalo Camarillo &lt;Gonzalo.Camarillo@ericsson.com&gt; </t>
</list>
        <artwork><![CDATA[XML:

   BEGIN
   <?xml version="1.0"?>
   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
     "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
     <meta http-equiv="content-type"
           content="text/html;charset=iso-8859-1"/>
     <title>Consent Rules Namespace</title>
   </head>
   <body>
     <h1>Namespace for Permission Documents</h1>
     <h2>urn:ietf:params:xml:ns:consent-rules</h2>
   <p>See <a href="http://www.rfc-editor.org/rfc/rfc5361.txt">RFC 5361
     </a>.</p>
   </body>
   </html>
   END
]]></artwork>
</t>
</section>

<section title="XML Schema Registration" anchor="sec-iana-schema">
<t>
<list style="hanging">
<t hangText="URI:">urn:ietf:params:xml:schema:consent-rules </t>

<t hangText="Registrant Contact:">IETF SIPPING working group &lt;sipping@ietf.org&gt;,
<vspace blankLines="0"/>
Gonzalo Camarillo &lt;Gonzalo.Camarillo@ericsson.com&gt; </t>

<t hangText="XML:">The XML schema to be registered is contained in <xref target="sec-schema"/>.
</t>
</list>
</t>

</section>

    </section>

<?rfc needLines="8"?>

<section title="Security Considerations" anchor="sec-security">
<t>
RFC 5360 <xref target="RFC5360"/> discusses security-related
issues, such as how to authenticate SIP and HTTP requests granting
permissions and how to transport permission documents between relays
and recipients, that are directly related to this specification.
</t>

</section>

<section title="Acknowledgements" anchor="sec-acks">
<t>
Jonathan Rosenberg provided useful ideas on this document. Hannes
Tschofenig helped align this document with common policy. Ben Campbell
and Mary Barnes performed a thorough review of this
document. Lakshminath Dondeti provided useful comments. 
</t>
    </section>


  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?>
      <?rfc include="reference.RFC.2617"?>
      <?rfc include="reference.RFC.3261"?>
      <?rfc include="reference.RFC.3323"?>
      <?rfc include="reference.RFC.3688"?>
      <?rfc include="reference.RFC.4474"?>
      <?rfc include="reference.RFC.4745"?>
  <!-- ietf-sip-consent-framework became
      RFC 5360 -->

<reference anchor='RFC5360'>
<front>
<title>A Framework for Consent-Based Communications in the Session Initiation Protocol (SIP)</title>

<author initials='J' surname='Rosenberg' fullname='Jonathan Rosenberg'>
    <organization />
</author>

<author initials='G' surname='Camarillo' fullname='Gonzalo Camarillo'>
    <organization />
</author>

<author initials='D' surname='Willis' fullname='Dean Willis'>
    <organization />
</author>

<date month='October' year='2008'/>

</front>
<seriesInfo name='RFC' value='5360'/>

</reference>

    </references>

    <references title="Informative References">
      <?rfc include="reference.RFC.3966"?>
      <?rfc include="reference.RFC.3325"?>
    </references>
  </back>
</rfc>
