Updated contact information.
Updated example JIDs to example.org
Initial published version approved by the XMPP Council.
Added acknowledgements section.
Removed links to articles expression opinions.
Reformulated the reference to SASL in the introduction.
A reference to Unicode Standard Annex #15, Unicode Normalization Forms, and NFC normalization has been added.
First draft.
Sometimes there might be a need for an application to sign a data form (Data Forms (XEP-0004)
This document describes a method whereby forms can be signed using other credentials. This can be used in an In-band registration form to sign the form with the credentials of a special account on the server with permissions to create new XMPP accounts, with perhaps a limit on number of accounts that can be created. This method can be used by manufacturers of devices for Internet of Things, so that devices can create accounts automatically on XMPP servers in an orderly fashion, and manufacturers are allowed to administer and control their automatically created accounts separately. It also provides a mechanism whereby server operators can monitor who is responsible for account creation and to what extent.
A fixed algorithm (OAuth 1.0 Protocol
A form that needs to be signed by the client using external credentials, shows this by including a hidden FORM_TYPE field valued urn:xmpp:xdata:signature:oauth1. The sub-namespace :oauth1 identifies the algorithm to be used, in this case OAUTH v1.0.
The form contains a set of invisible parameters that the underlying software signing the form and supporting this specification must understand. These are:
Name | Description |
---|---|
oauth_version | Must be 1.0. Is not changed by the client performing the signing. |
oauth_signature_method | Specifies the signature method, or hash function, to use when signing the form. This can be changed by the client. Possible values are: HMAC-SHA1, RSA-SHA1 and PLAINTEXT. |
oauth_token | This is a token provided by the server to the client. This parameter might not be available if the server has provided the client with this token earlier during the session. |
oauth_token_secret | This is a temporary secret shared between the server and client, and is related to the token. This parameter might not be available if the server has provided the client with this token earlier during the session. |
oauth_nonce | A nonce value that the client has to set. Can be a random alphanumerical string. |
oauth_timestamp | Number of seconds since 1st of January 1970, 00:00:00 GMT. The client has to set this at the time of signature. |
oauth_consumer_key | A key identifying the account doing the signing of the form. The client has to set this to identify who performs the signature. |
oauth_signature | The signature, signing the form. The client has to set this with the signature of the form, as calculated and described below. |
Before calculating the signature, the following functions need to be defined:
Converts the sequence of octets x into a Base-64 encoded string.
The string s are escaped using the RFC 3986
Unreserved characters are alphanumeric characters (a-z, A-Z, 0-9), hyphen ('-'), period ('.'), underscore ('_') and tilde ('~').
Corresponds to the Hash-function to use, according to the parameter oauth_signature_method. It computes the hash value of the octets x, and returns a sequence of octets.
To calculate the signature of the form, follow the steps in the following subsections, in the same order.
You choose Hash function by setting the parameter oauth_signature_method to either HMAC-SHA1, RSA-SHA1 or PLAINTEXT.
First, all form parameters to be signed, including hidden parameters and the OAUTH parameters except oauth_token_secret and oauth_signature, are sorted by variable name (var).
Each (name, value) pair in the list of sorted parameters are first transformed into pairs of Escape(name)=Escape(value) segments, and then concatenated into one string, where each segment is delimited using an ampersand ('&') character.
The Signature Base String (BStr) is then formed concatenating Escape(type) (the form type used when submitting the form), Escape(to) (the full destination address, including resource, if any) and Escape(PStr), using ampersands ('&') as delimiter.
Depending on which signature method is chosen, different Hash functions are used. If HMAC-SHA1 is chosen, then the Hash function
HMAC(text, key) according to RFC 2104
Here, the client signing the form must have the oauth_consumer_secret available to be able to sign the form correctly.
If RSA-SHA1 is chosen, then the signature method RSASSA-PKCS1-v1_5(K, M) according to RFC 3447
In this example, the oauth_consumer_secret must be an RSA private key.
If PLAINTEXT is chosen, no Hash function is used. Instead, the signature is calculated as follows:
Once the signature has been calculated, the corresponding parameter oauth_signature has to be set in the form before sending it to the destination address.
When the recipient receives the signed formm it performs the same calculations as above, based on the parameters received, and knowledge of the shared secret which it can look up by using the parameter oauth_consumer_key.
As mentioned above, a major use case for signing forms, is in-band registration for creating new accounts on an XMPP Server, as defined in XEP-0077.
In case a form signature is not value, the server MUST respond with a bad-request error message, as follows:
If an entity supports signing forms as specified herein, it MUST advertise that fact by returning a feature of "urn:xmpp:xdata:signature:oauth1" in response to Service Discovery (XEP-0030)
In order for an application to determine whether an entity supports this protocol, where possible it SHOULD use the dynamic, presence-based profile of service discovery defined
in Entity Capabilities (XEP-0115)
This document only specifies signatures using OAUTH v1.0. Each entity that supports form signatures using this method, reports this by including the namespace urn:xmpp:xdata:signature:oauth1 in its features. The specification is extensible, in that it can allow for future signature methods to be used, by defining new namespaces replacing oauth1 by another string corresponding to the desired method, but leaving the base part of the namespace urn:xmpp:xdata:signature: intact.
The PLAINTEXT signature method should only be used if SSL/TLS is used by both the entity signing the form as well as the creator of the form. If the creator of the form is a server, this later part can be ignored. If unsure, PLAINTEXT should only be used in development & debugging cycles of an application, and not in production environments.
If the server provides information to be used in signing a form, it must also verify that the client only changes values it is allowed to change. An alternative is to not use the values provided by the client for the corresponding server-side parameters when calculating the signature on the server side. This makes sure a client cannot willfully alter server-side parameters when it returns the signed form.
This document requires no interaction with the Internet Assigned Numbers Authority (IANA)
The XMPP Registrar
Field Standardization for Data Forms (XEP-0068)
Thanks to Kevin Smith, Lance Stout, Matthew Wild, Philipp Hancke and Tobias Markmann for all valuable feedback.