One document matched: draft-hammer-oauth-v2-mac-token-02.xml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<rfc category='std' ipr='trust200902' docName='draft-hammer-oauth-v2-mac-token-02'>
<?rfc strict='yes' ?>
<?rfc toc='yes' ?>
<?rfc tocdepth='3' ?>
<?rfc symrefs='yes' ?>
<?rfc sortrefs='yes' ?>
<?rfc compact='yes' ?>
<?rfc subcompact='yes' ?>
<front>
<title abbrev='MAC Authentication'>HTTP Authentication: MAC Authentication</title>
<author fullname='Eran Hammer-Lahav' surname='Hammer-Lahav' initials='E'>
<organization>Yahoo!</organization>
<address>
<email>eran@hueniverse.com</email>
<uri>http://hueniverse.com</uri>
</address>
</author>
<date year='2011'/>
<abstract>
<t>
This document specifies the HTTP MAC authentication scheme, as well as its OAuth 2.0
binding.
</t>
</abstract>
</front>
<middle>
<section title='Introduction'>
<t>
This specification defines the HTTP MAC authentication scheme and provides a method for
making authenticated HTTP requests with partial cryptographic verification of the request -
covering the HTTP method, request URI, host, and in some cases the request body.
</t>
<t>
This specification uses the terminology defined in <xref target='I-D.ietf-oauth-v2' />.
</t>
<t>
Please discuss this draft on the
<eref target='https://www.ietf.org/mailman/listinfo/oauth'>oauth@ietf.org</eref> mailing
list.
</t>
<section title='Example'>
<figure>
<preamble>
The client attempts to access a protected resource without authentication, making the
following HTTP request to the resource server:
</preamble>
<artwork>
<![CDATA[
GET /resource/1?b=1&a=2 HTTP/1.1
Host: example.com
]]>
</artwork>
</figure>
<figure>
<preamble>
The resource server returns the following authentication challenge:
</preamble>
<artwork>
<![CDATA[
HTTP/1.1 401 Unauthorized
WWW-Authenticate: MAC realm="example"
Date: Thu, 02 Dec 2010 21:39:45 GMT
]]>
</artwork>
</figure>
<t>
The client has previously obtained a set of token credentials for accessing resources on
the <spanx style='verb'>http://example.com/</spanx> resource server. The MAC credentials
issued to the client included the following attributes:
</t>
<t>
<list style='hanging' hangIndent='6'>
<t hangText='Access Token:'>h480djs93hd8</t>
<t hangText='Token secret:'>489dks293j39</t>
<t hangText='MAC algorithm:'>hmac-sha-1</t>
</list>
</t>
<t>
The client attempts the HTTP request again, this time using the token credentials issued
earlier to authenticate. To construct the authentication header, the client calculates
the current timestamp and generates a nonce. The nonce is unique to the timestamp used,
typically a random string:
</t>
<t>
<list style='hanging' hangIndent='6'>
<t hangText='Timestamp:'>137131200</t>
<t hangText='Nonce:'>dj83hs9s</t>
</list>
</t>
<t>
The client normalizes the request and constructs the normalized request string (the new line
separator character is represented by <spanx style='verb'>\n</spanx> for display purposes
only):
</t>
<figure>
<artwork>
<![CDATA[
h480djs93hd8\n
137131200\n
dj83hs9s\n
\n
GET\n
example.com\n
80\n
/resource/1\n
a=2\n
b=1\n
]]>
</artwork>
</figure>
<t>
The normalized request string is signed using the specified MAC algorithm
<spanx style='verb'>hmac-sha-1</spanx> with the normalized request string as text and the
token secret as key. The resulting digest is base64-encoded to produce the request
signature:
</t>
<figure>
<artwork>
<![CDATA[
YTVjyNSujYs1WsDurFnvFi4JK6o=
]]>
</artwork>
</figure>
<t>
The client includes the access token, timestamp, nonce, and signature with the request
using the <spanx style='verb'>Authorization</spanx> request header field:
</t>
<figure>
<artwork>
<![CDATA[
GET /resource/1 HTTP/1.1
Host: example.com
Authorization: MAC token="h480djs93hd8",
timestamp="137131200",
nonce="dj83hs9s",
signature="YTVjyNSujYs1WsDurFnvFi4JK6o="
]]>
</artwork>
</figure>
<t>
The resource server validates the request by calculating the signature again based on the
request received and verifies the validity and scope of the access token. If valid, the
resource server responds with the requested protected resource representation.
</t>
</section>
<section title='Notational Conventions'>
<t>
The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL NOT', 'SHOULD',
'SHOULD NOT', 'RECOMMENDED', 'MAY', and 'OPTIONAL' in this specification are to be
interpreted as described in <xref target='RFC2119' />.
</t>
<t>
This specification uses the Augmented Backus-Naur Form (ABNF) notation of
<xref target='I-D.ietf-httpbis-p1-messaging' />. Additionally, the following rules
are included from [RFC2617]: realm, auth-param.
</t>
</section>
</section>
<section title='Issuing MAC Credentials' anchor='issue'>
<t>
This specification does not define a general purpose method for requesting or issuing MAC
credentials (an <xref target='I-D.ietf-oauth-v2'>OAuth 2.0</xref> binding is provided in
<xref target='oauth2' />). It simply assumes that the client is in the possession of a set
of MAC credentials with the following REQUIRES attributes:
</t>
<t>
<list style='hanging' hangIndent='6'>
<t hangText='access token'>
<vspace />
A string representing an access authorization issued to the client. The string is
usually opaque to the client. Tokens represent specific scopes and durations of
access. The token may denote an identifier used to retrieve the authorization
information, or self-contain the authorization information in a verifiable manner (i.e.
a token string consisting of some data and a signature).
</t>
<t hangText='secret'>
<vspace />
A shared symmetric secret used as the MAC algorithm key.
</t>
<t hangText='algorithm'>
<vspace />
A MAC algorithm used to calculate the request signature. Value MUST be one
of <spanx style='verb'>hmac-sha-1</spanx>, <spanx style='verb'>hmac-sha-256</spanx>, or
a registered extension algorithm name as described in <xref target='extensions' />.
</t>
</list>
</t>
<figure>
<preamble>
The access token and secret strings MUST NOT include characters other than:
</preamble>
<artwork>
<![CDATA[
DIGIT / ALPHA / %x20-21 / %x23-5B / %x5D-7E
; Any printable ASCII character except for <"> and <\>
]]>
</artwork>
</figure>
</section>
<section title='Making Requests' anchor='requests'>
<t>
To make authenticated requests, the client must be in possession of a valid set of MAC
credentials accepted by the resource server. The client constructs the request by
calculating of a set of attributes, and adding them to the HTTP request using the
<xref target='authz_header'>Authorization header field</xref>. Authenticated requests can
be sent in response to an authentication challenge or directly.
</t>
<section title='The "Authorization" Request Header' anchor='authz_header'>
<t>
The <spanx style='verb'>Authorization</spanx> request header field uses the framework
defined by <xref target='RFC2617' /> as follows:
</t>
<figure>
<artwork>
<![CDATA[
credentials = 'MAC' [ RWS 1#param ]
param = access-token /
timestamp /
nonce /
body-hash /
signature
access-token = 'token' '=' <"> plain-string <">
timestamp = 'timestamp' '=' <"> 1*DIGIT <">
nonce = 'nonce' '=' <"> plain-string <">
body-hash = 'bodyhash' '=' <"> plain-string <">
signature = 'signature' '=' <"> plain-string <">
plain-string = 1*( DIGIT / ALPHA / %x20-21 / %x23-5B / %x5D-7E )
]]>
</artwork>
</figure>
<t>
The header attributes are defined as follows:
</t>
<t>
<list style='hanging' hangIndent='6'>
<t hangText='token'>
<vspace />
REQUIRED. The access token string.
</t>
<t hangText='timestamp'>
<vspace />
REQUIRED. The current time expressed in the number of seconds since January 1, 1970
00:00:00 GMT, and MUST be a positive integer.
</t>
<t hangText='nonce'>
<vspace />
REQUIRED. A random string, uniquely generated by the client to allow the resource
server to verify that a request has never been made before and helps prevent replay
attacks when requests are made over an insecure channel. The nonce value MUST be
unique across all requests with the same timestamp and access token combination.
<vspace />
To avoid the need to retain an infinite number of nonce values for future checks,
resource servers MAY choose to restrict the time period after which a request with an
old timestamp is rejected. Such a restriction implies a level of synchronization
between the client's and server's clocks. The client MAY use the
<spanx style='verb'>Date</spanx> response header field to synchronize its clock after
a failed request.
</t>
<t hangText='bodyhash'>
<vspace />
OPTIONAL. The HTTP request entity-body hash as described in
<xref target='body-hash' />.
</t>
<t hangText='signature'>
<vspace />
REQUIRED. The HTTP request signature as described in <xref target='signature' />.
</t>
</list>
</t>
<t>
Attributes MUST NOT appear more than once. Attribute values are limited to a subset of
ASCII, which does not require escaping, as defined by the plain-string ABNF.
</t>
</section>
<section title='Body Hash' anchor='body-hash'>
<t>
The body hash is used to provide integrity verification of the HTTP request entity-body.
The hash value is calculated using a hash algorithm over the entire HTTP request
entity-body as included in the request.
</t>
<t>
The client MAY include the body hash with any request. The server SHOULD require the
calculation and inclusion of the body hash with any request containing an entity-body, or
when the presence (or lack of) of an entity-body matters.
</t>
<t>
The body hash algorithm is determined by the access token algorithm provided with the
access token. The SHA-1 hash algorithm as defined by <xref target='NIST FIPS-180-3' /> is
used with the <spanx style='verb'>hmac-sha-1</spanx> access token algorithm. The SHA-256
hash algorithm as defined by <xref target='NIST FIPS-180-3' /> is used with the
<spanx style='verb'>hmac-sha-256</spanx> access token algorithm. Additional access token
algorithms MUST specify the body hash algorithm.
</t>
<t>
The body hash is calculated as follows:
</t>
<figure>
<artwork>
<![CDATA[
bodyhash = BASE64 ( HASH (text) )
]]>
</artwork>
</figure>
<t>
Where:
</t>
<t>
<list style='hanging' hangIndent='6'>
<t hangText='HASH'>
<vspace />
is the hash algorithm function,
</t>
<t hangText='text'>
<vspace />
is the HTTP request entity-body,
</t>
<t hangText='BASE64'>
<vspace />
is the base64-encoding function per <xref target='RFC2045' /> section 6.8, applied to
the hash digest result octet string, and
</t>
<t hangText='bodyhash'>
<vspace />
is the value used in the normalized request string and to set the
<spanx style='verb'>bodyhash</spanx> attribute of the
<spanx style='verb'>Authorization</spanx> header field.
</t>
</list>
</t>
<t>
The body hash is calculated before the normalized request string is constructed and the
signature is calculated.
</t>
<figure>
<preamble>
For example, the HTTP request:
</preamble>
<artwork>
<![CDATA[
POST /request HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
hello=world%21
]]>
</artwork>
</figure>
<figure>
<preamble>
using access token <spanx style="verb">j92fsdjf094gjfdi</spanx>, timestamp
<spanx style="verb">137131206</spanx>, nonce <spanx style="verb">f403hksd</spanx>,
access token algorithm <spanx style="verb">hmac-sha-1</spanx>, and secret
<spanx style="verb">8yfrufh348h</spanx>, is transmitted as (line
breaks are for display purposes only):
</preamble>
<artwork>
<![CDATA[
POST /request HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded
Authorization: MAC token="h480djs93hd8",
timestamp="137131200",
nonce="dj83hs9s",
bodyhash="k9kbtCIy0CkI3/FEfpS/oIDjk6k=",
signature="FR1UCL6Ny6bsx8EkKkiveFYv5VU="
hello=world%21
]]>
</artwork>
</figure>
</section>
<section title='Signature' anchor='signature'>
<t>
The client uses the MAC algorithm and the token secret to calculate the request
signature. This specification defines two algorithms:
<spanx style='verb'>hmac-sha-1</spanx> and <spanx style='verb'>hmac-sha-256</spanx>, and
provides an extension registry for additional algorithms.
</t>
<section title='Normalized Request String' anchor='base_string'>
<t>
The normalized request string is a consistent, reproducible concatenation of several of
the HTTP request elements into a single string. By normalizing the request into a
reproducible string, the client and resource server can both sign the same string.
</t>
<t>
The string is constructed by concatenating together, in order, the following HTTP request
elements, each followed by a new line character (%x0A):
</t>
<t>
<list style='numbers'>
<t>
The access token.
</t>
<t>
The timestamp value calculated for the request.
</t>
<t>
The nonce value generated for the request.
</t>
<t>
The request entity-body hash as described in <xref target='body-hash' /> if
one was calculated and included in the request, otherwise, an empty string. Note
that the body hash of an empty entity-body is typically not an empty string.
</t>
<t>
The HTTP request method in upper case. For example: <spanx style='verb'>HEAD</spanx>,
<spanx style='verb'>GET</spanx>, <spanx style='verb'>POST</spanx>, etc.
</t>
<t>
The hostname included in the HTTP request using the <spanx style='verb'>Host</spanx>
request header field in lower case.
</t>
<t>
The port as included in the HTTP request using the
<spanx style='verb'>Host</spanx> request header field. If the header field does not
include a port, the default value for the scheme MUST be used (e.g. 80 for HTTP and
443 for HTTPS).
</t>
<t>
The path component of the HTTP request URI as defined by <xref target='RFC3986' />
section 3.3.
</t>
<t>
The query component of the HTTP request URI as defined by <xref target='RFC3986' />
section 3.4, normalized as described in <xref target='parameters' />.
</t>
</list>
</t>
<t>
[[ TODO: I18N ]]
</t>
<figure>
<preamble>
For example, the HTTP request:
</preamble>
<artwork>
<![CDATA[
POST /request?b5=%3D%253D&a3=a&c%40=&a2=r%20b&c2&a3=2+q HTTP/1.1
Host: example.com
Hello World!
]]>
</artwork>
<postamble>
using access token <spanx style="verb">kkk9d7dh3k39sjv7</spanx>, timestamp
<spanx style="verb">137131201</spanx>, nonce <spanx style="verb">7d8f3e4a</spanx>,
and body hash <spanx style="verb">Lve95gjOVATpfV8EL5X4nxwjKHE=</spanx>
is normalized into the following string (the new line separator character is
represented by <spanx style='verb'>\n</spanx> for display purposes only):
</postamble>
</figure>
<figure>
<artwork>
<![CDATA[
kkk9d7dh3k39sjv7\n
137131201\n
7d8f3e4a\n
Lve95gjOVATpfV8EL5X4nxwjKHE=\n
POST\n
example.com\n
80\n
/request\n
a2=r%20b\n
a3=2%20q\n
a3=a\n
b5=%3D%253D\n
c%40=\n
c2=\n
]]>
</artwork>
</figure>
<section title="Parameters Normalization" anchor="parameters">
<t>
The query component is parsed into a list of name/value parameter pairs by
treating it as an <spanx style="verb">application/x-www-form-urlencoded</spanx>
string, separating the names and values and decoding them as defined by
<xref target="W3C.REC-html401-19991224" /> section 17.13.4. Form-encoded parameters
present in the entity-body are not included.
</t>
<t>
Once separated and decoded, the parameters are concatenated back together as
follows:
</t>
<t>
<list style="numbers">
<t>
First, the name and value of each parameter are escaped using the
<xref target="RFC3986" /> percent-encoding (%XX) mechanism. Characters in the
unreserved character set as defined by <xref target="RFC3986" /> section 2.3
(ALPHA, DIGIT, "-", ".", "_", "~") MUST NOT be encoded. All other characters MUST
be encoded. The two hexadecimal characters used to represent encoded characters
MUST be upper case.
</t>
<t>
The name of each parameter is concatenated to its corresponding value using an
<spanx style="verb">=</spanx> character (ASCII code 61) as separator, even if the
value is empty.
</t>
<t>
The name/value parameter pairs are sorted using ascending byte value ordering.
</t>
<t>
The sorted parameters are concatenated together into a single string by using an
new line character (ASCII code 10) as separator.
</t>
</list>
</t>
<t>
Note that the percent-encoding method described is different from the encoding scheme
used by the <spanx style="verb">application/x-www-form-urlencoded</spanx>
content-type (for example, it encodes space characters as
<spanx style="verb">%20</spanx> instead of the <spanx style="verb">+</spanx>
character). It MAY be different from the percent-encoding functions provided by web
development frameworks (e.g. encode different characters, use lower case hexadecimal
characters).
</t>
<figure>
<preamble>
For example, the HTTP request URI:
</preamble>
<artwork>
<![CDATA[
/request?b5=%3D%253D&a3=a&c%40=&a2=r%20b&c2&a3=2+q
]]>
</artwork>
<postamble>
Contains the following (fully decoded) parameters used in the normalized request
sting:
</postamble>
</figure>
<texttable>
<ttcol align='center'>Name</ttcol>
<ttcol align='center'>Value</ttcol>
<c>b5</c>
<c>=%3D</c>
<c>a3</c>
<c>a</c>
<c>c@</c>
<c></c>
<c>a2</c>
<c>r b</c>
<c>c2</c>
<c></c>
<c>a3</c>
<c>2 q</c>
</texttable>
<t>
Note that the value of <spanx style="verb">b5</spanx> is <spanx style="verb">=%3D</spanx>
and not <spanx style="verb">==</spanx>. Both <spanx style="verb">c@</spanx> and
<spanx style="verb">c2</spanx> have empty values. While the encoding rules
specified in this specification for the purpose of constructing the normalized request
string exclude the use of a <spanx style="verb">+</spanx> character (ASCII code 43)
to represent an encoded space character (ASCII code 32), this practice is widely
used in <spanx style="verb">application/x-www-form-urlencoded</spanx> encoded
values, and MUST be properly decoded, as demonstrated by one of the
<spanx style="verb">a3</spanx> parameter instances (the <spanx style="verb">a3</spanx>
parameter is used twice in this request).
</t>
<t>
The parsed parameters are normalized as follows:
</t>
<texttable>
<preamble>
Escaped:
</preamble>
<ttcol align='center'>Name</ttcol>
<ttcol align='center'>Value</ttcol>
<c>b5</c>
<c>%3D%253D</c>
<c>a3</c>
<c>a</c>
<c>c%40</c>
<c></c>
<c>a2</c>
<c>r%20b</c>
<c>c2</c>
<c></c>
<c>a3</c>
<c>2%20q</c>
</texttable>
<texttable>
<preamble>
Concatenated Pairs:
</preamble>
<ttcol align='center'>Name=Value</ttcol>
<c>b5=%3D%253D</c>
<c>a3=a</c>
<c>c%40=</c>
<c>a2=r%20b</c>
<c>c2=</c>
<c>a3=2%20q</c>
</texttable>
<texttable>
<preamble>
Sorted:
</preamble>
<ttcol align='center'>Name=Value</ttcol>
<c>a2=r%20b</c>
<c>a3=2%20q</c>
<c>a3=a</c>
<c>b5=%3D%253D</c>
<c>c%40=</c>
<c>c2=</c>
</texttable>
<figure>
<preamble>
And concatenated together into a single string (the new line separator character is
represented by <spanx style='verb'>\n</spanx> for display purposes only):
</preamble>
<artwork>
<![CDATA[
a2=r%20b\n
a3=2%20q\n
a3=a\n
b5=%3D%253D\n
c%40=\n
c2=\n
]]>
</artwork>
</figure>
</section>
</section>
<section title='hmac-sha-1'>
<t>
<spanx style='verb'>hmac-sha-1</spanx> uses the HMAC-SHA1 algorithm as defined in
<xref target='RFC2104' />:
</t>
<figure>
<artwork>
<![CDATA[
digest = HMAC-SHA1 (key, text)
]]>
</artwork>
</figure>
<t>
Where:
</t>
<t>
<list style='hanging' hangIndent='6'>
<t hangText='text'>
<vspace />
is set to the value of the normalize request string as described in
<xref target='base_string' />,
</t>
<t hangText='key'>
<vspace />
is set to the access token shared-secret provided by the authorization server, and
</t>
<t hangText='digest'>
<vspace />
is used to set the value of the <spanx style='verb'>signature</spanx> attribute,
after the result octet string is base64-encoded per <xref target='RFC2045' />
section 6.8.
</t>
</list>
</t>
</section>
<section title='hmac-sha-256'>
<t>
<spanx style='verb'>hmac-sha-1</spanx> uses the HMAC algorithm as defined in
<xref target='RFC2104' /> together with the SHA-256 hash function defined in
<xref target='NIST FIPS-180-3' />:
</t>
<figure>
<artwork>
<![CDATA[
digest = HMAC-SHA256 (key, text)
]]>
</artwork>
</figure>
<t>
Where:
</t>
<t>
<list style='hanging' hangIndent='6'>
<t hangText='text'>
<vspace />
is set to the value of the normalize request string as described in
<xref target='base_string' />,
</t>
<t hangText='key'>
<vspace />
is set to the access token shared-secret provided by the authorization server, and
</t>
<t hangText='digest'>
<vspace />
is used to set the value of the <spanx style='verb'>signature</spanx> attribute,
after the result octet string is base64-encoded per <xref target='RFC2045' />
section 6.8.
</t>
</list>
</t>
</section>
</section>
</section>
<section title='Verifying Requests' anchor='verify_request'>
<t>
A servers receiving an authenticated request validates it by performing the following
REQUIRED steps:
</t>
<t>
<list style='numbers'>
<t>
Recalculate the request body hash (if included in the request) as described in
<xref target='body-hash' /> and signature as described in <xref target='signature' />
and compare the signature to the value received from the client via the
<spanx style='verb'>signature</spanx> attribute.
</t>
<t>
Ensure that the combination of nonce, timestamp, and access token received from the
client has not been used before in a previous request (the server MAY reject requests
with stale timestamps; the determination of staleness is left up to the server to
define).
</t>
<t>
Verify the scope and status of the access token.
</t>
</list>
</t>
<t>
If the request fails verification, the server SHOULD respond with an HTTP 401 (unauthorized)
status code, and SHOULD include a token scheme authentication challenge using the
WWW-Authenticate header field. The server MAY include
further details about why the request was rejected using the
error attribute.
</t>
<section title='The "WWW-Authenticate" Response Header Field' anchor='authn-header'>
<t>
If the protected resource request does not include authentication credentials, contains
an invalid access token, or is malformed, the resource server MUST include the HTTP
<spanx style='verb'>WWW-Authenticate</spanx> response header field. The
<spanx style='verb'>WWW-Authenticate</spanx> header field uses the framework defined by
<xref target='RFC2617' /> as follows:
</t>
<figure>
<artwork>
<![CDATA[
challenge = "MAC" [ RWS 1#param ]
param = realm / error / auth-param
error = "error" "=" quoted-string
]]>
</artwork>
</figure>
<t>
Each attribute MUST NOT appear more than once.
</t>
<t>
If the protected resource request included a MAC
<spanx style='verb'>Authorization</spanx> header field and failed authentication, the
resource server MAY include the <spanx style='verb'>error</spanx> attribute to provide
the client with a human-readable explanation why the access request was declined.
</t>
<figure>
<preamble>
For example, in response to a protected resource request without authentication:
</preamble>
<artwork>
<![CDATA[
HTTP/1.1 401 Unauthorized
WWW-Authenticate: MAC realm="example"
]]>
</artwork>
</figure>
<figure>
<preamble>
And in response to a protected resource request with an authentication attempt using an
expired access token:
</preamble>
<artwork>
<![CDATA[
HTTP/1.1 401 Unauthorized
WWW-Authenticate: MAC realm="example"
error="The access token expired"
]]>
</artwork>
</figure>
<t>
The resource server response SHOULD use the appropriate HTTP status code as follows:
</t>
<t>
<list style='hanging' hangIndent='6'>
<t hangText='400 (Bad Request)'>
<vspace />
The request is missing a required parameter, includes an unsupported parameter or
parameter value, repeats the same parameter, uses more than one method for
including an access token, or is otherwise malformed.
</t>
<t hangText='401 (Unauthorized)'>
<vspace />
The access token provided is expired, revoked, malformed, or invalid. The body hash
or signature provided do not match the values calculated by the server.
</t>
<t hangText='403 (Forbidden)'>
<vspace />
The request requires higher privileges than provided by the access token.
</t>
</list>
</t>
</section>
</section>
<section title='Scheme Extensions' anchor='extensions'>
<t>
[[ TBD ]]
</t>
</section>
<section title='Use with OAuth 2.0' anchor='oauth2'>
<t>
OAuth 2.0 (<xref target='I-D.ietf-oauth-v2' />) defines a token-based authentication
framework in which third-party applications (clients) access protected resources using
access tokens. Access tokens are obtained via the resource owners' authorization from an
authorization server. This specification defines the OAuth 2.0 MAC token type, as well as
type-specific token attributes.
</t>
<t>
This specification does not define methods for the client to specifically request a
MAC-type token from the authorization server. Additionally, it does not include any
discovery facilities for identifying which HMAC algorithms are supported by a resource
server, or how the client may go about obtaining MAC access tokens.
</t>
<section title='Issuing MAC-Type Access Tokens'>
<t>
Authorization servers issuing MAC-type access tokens MUST include the following parameters
whenever a response includes the <spanx style='verb'>access_token</spanx> parameter:
</t>
<t>
<list style='hanging' hangIndent='6'>
<t hangText='secret'>
<vspace />
REQUIRED. The token shared secret used as the MAC algorithm key.
</t>
<t hangText='algorithm'>
<vspace />
REQUIRED. The MAC algorithm used to calculate the request signature. Value MUST be one
of <spanx style='verb'>hmac-sha-1</spanx>, <spanx style='verb'>hmac-sha-256</spanx>, or
a registered extension algorithm name as described in <xref target='extensions' />.
</t>
</list>
</t>
</section>
</section>
<section title='Security Considerations' anchor='Security'>
<t>
As stated in <xref target='RFC2617' />, the greatest sources of risks are usually found not
in the core protocol itself but in policies and procedures surrounding its use. Implementers
are strongly encouraged to assess how this protocol addresses their security requirements.
</t>
<section title='Secrets Transmission'>
<t>
This specification does not describe any mechanism for obtaining or transmitting access
token secrets. Methods used to obtain tokens should ensure that these transmissions are
protected using transport-layer mechanisms such as TLS or SSL.
</t>
</section>
<section title='Confidentiality of Requests'>
<t>
While this protocol provides a mechanism for verifying the integrity of requests, it
provides no guarantee of request confidentiality. Unless further precautions are taken,
eavesdroppers will have full access to request content. Servers should carefully consider
the kinds of data likely to be sent as part of such requests, and should employ
transport-layer security mechanisms to protect sensitive resources.
</t>
</section>
<section title='Spoofing by Counterfeit Servers'>
<t>
This protocol makes no attempt to verify the authenticity of the resource server. A
hostile party could take advantage of this by intercepting the client's requests and
returning misleading or otherwise incorrect responses. Service providers should consider
such attacks when developing services using this protocol, and should require
transport-layer security for any requests where the authenticity of the resource server
or of request responses is an issue.
</t>
</section>
<section title='Plaintext Storage of Credentials'>
<t>
The access token shared-secret functions the same way passwords do in traditional
authentication systems. In order to compute the signature, the server must have access to
the secret in plaintext form. This is in contrast, for example, to modern operating
systems, which store only a one-way hash of user credentials.
</t>
<t>
If an attacker were to gain access to these secrets - or worse, to the server's database
of all such secrets - he or she would be able to perform any action on behalf of any
resource owner. Accordingly, it is critical that servers protect these secrets from
unauthorized access.
</t>
</section>
<section title='Entropy of Secrets'>
<t>
Unless a transport-layer security protocol is used, eavesdroppers will have full access
to authenticated requests and signatures, and will thus be able to mount offline brute-force
attacks to recover the secret used. Authorization servers should be careful to assign
shared-secrets which are long enough, and random enough, to resist such attacks for at
least the length of time that the shared-secrets are valid.
</t>
<t>
For example, if shared-secrets are valid for two weeks, authorization servers should
ensure that it is not possible to mount a brute force attack that recovers the
shared-secret in less than two weeks. Of course, authorization servers are urged to err
on the side of caution, and use the longest secrets reasonable.
</t>
<t>
It is equally important that the pseudo-random number generator (PRNG) used to generate
these secrets be of sufficiently high quality. Many PRNG implementations generate number
sequences that may appear to be random, but which nevertheless exhibit patterns or other
weaknesses which make cryptanalysis or brute force attacks easier. Implementers should be
careful to use cryptographically secure PRNGs to avoid these problems.
</t>
</section>
<section title='Denial of Service / Resource Exhaustion Attacks'>
<t>
This specification includes a number of features which may make resource exhaustion
attacks against servers possible. For example, this protocol requires servers to track
used nonces. If an attacker is able to use many nonces quickly, the resources required to
track them may exhaust available capacity. And again, this protocol can require servers
to perform potentially expensive computations in order to verify the signature on
incoming requests. An attacker may exploit this to perform a denial of service attack by
sending a large number of invalid requests to the server.
</t>
<t>
Resource Exhaustion attacks are by no means specific to this specification. However,
implementers should be careful to consider the additional avenues of attack that this
protocol exposes, and design their implementations accordingly. For example, entropy
starvation typically results in either a complete denial of service while the system
waits for new entropy or else in weak (easily guessable) secrets. When implementing this
protocol, servers should consider which of these presents a more serious risk for their
application and design accordingly.
</t>
</section>
<section title='Coverage Limitations'>
<t>
The normalized request string has been designed to support the authentication methods
defined in this specification. Those designing additional methods, should evaluated the
compatibility of the normalized request string with their security requirements.
Since the normalized request string does not cover the entire HTTP request, servers
should employ additional mechanisms to protect such elements.
</t>
<t>
The signature does not cover entity-header fields which can often affect how the request
body is interpreted by the server (i.e. Content-Type). If the server behavior is
influenced by the presence or value of such header fields, an attacker can manipulate the
request header without being detected. This will alter the request even when using the
body hash attribute.
</t>
</section>
</section>
<section title='IANA Considerations' anchor='IANA'>
<section title='OAuth Access Token Type Registration'>
<t>
This specification registers the following access token type in the OAuth Access Token
Type Registry.
</t>
<section title='The "mac" OAuth Access Token Type'>
<t>
<list style='hanging'>
<t hangText='Type name:'>
<vspace />
mac
</t>
<t hangText='Additional Token Endpoint Response Parameters:'>
<vspace />
secret, algorithm
</t>
<t hangText='HTTP Authentication Scheme(s):'>
<vspace />
MAC
</t>
<t hangText='Change controller:'>
<vspace />
IETF
</t>
<t hangText='Specification document(s):'>
<vspace />
[[ this document ]]
</t>
</list>
</t>
</section>
</section>
<section title='OAuth Parameters Registration'>
<t>
This specification registers the following parameters in the OAuth Parameters Registry
established by <xref target='I-D.ietf-oauth-v2' />.
</t>
<section title='The "secret" OAuth Parameter'>
<t>
<list style='hanging'>
<t hangText='Parameter name:'>
secret
</t>
<t hangText='Parameter usage location:'>
authorization response, token response
</t>
<t hangText='Change controller:'>
IETF
</t>
<t hangText='Specification document(s):'>
[[ this document ]]
</t>
<t hangText='Related information:'>
None
</t>
</list>
</t>
</section>
<section title='The "algorithm" OAuth Parameter'>
<t>
<list style='hanging'>
<t hangText='Parameter name:'>
algorithm
</t>
<t hangText='Parameter usage location:'>
authorization response, token response
</t>
<t hangText='Change controller:'>
IETF
</t>
<t hangText='Specification document(s):'>
[[ this document ]]
</t>
<t hangText='Related information:'>
None
</t>
</list>
</t>
</section>
</section>
</section>
<section title='Acknowledgments'>
<t>
The author would like to thank James Manger for his suggestions, feedback, and continued
support.
</t>
</section>
<appendix title='Document History' anchor='history'>
<t>
[[ To be removed by the RFC editor before publication as an RFC. ]]
</t>
<t>
-02
</t>
<t>
<list style='symbols'>
<t>
Added body-hash support.
</t>
<t>
Updated OAuth 2.0 reference and added token type registration template.
</t>
<t>
Removed error codes and error URI.
</t>
</list>
</t>
<t>
-01
</t>
<t>
<list style='symbols'>
<t>
Changed parameters sorting to come after name=value string construction.
</t>
<t>
Added new line at the end of the normalized request string.
</t>
<t>
Moved OAuth2 references to separate section.
</t>
<t>
Added 'WWW-Authenticate' header definition.
</t>
<t>
Fixed example header use of single quote.
</t>
<t>
Restricted strings to ASCII subset (printable, no double-quotes or back-slash).
</t>
</list>
</t>
<t>
-00
</t>
<t>
<list style='symbols'>
<t>
Initial draft.
</t>
</list>
</t>
</appendix>
</middle>
<back>
<references title='Normative References'>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2045.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2104.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.2617.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-httpbis-p1-messaging-08.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml3/reference.I-D.draft-ietf-oauth-v2-12.xml' ?>
<?rfc include='http://xml.resource.org/public/rfc/bibxml4/reference.W3C.REC-html401-19991224.xml' ?>
<reference anchor='NIST FIPS-180-3'>
<front>
<title>Secure Hash Standard (SHS). FIPS PUB 180-3, October 2008</title>
<author>
<organization>National Institute of Standards and Technology</organization>
</author>
</front>
<format type='pdf' target='http://www.nist.gov/itl/upload/fips180-3_final.pdf' />
</reference>
</references>
<references title='Informative References'>
<?rfc include='http://xml.resource.org/public/rfc/bibxml/reference.RFC.5849.xml' ?>
</references>
</back>
</rfc>| PAFTECH AB 2003-2026 | 2026-04-23 08:32:07 |