Changes

Jump to: navigation, search

CloudServices/Sagrada/TokenServer

907 bytes added, 23:00, 11 January 2012
no edit summary
== Definitions and assumptions ==
First, a few definitions. The major players in the network topology are:
* '''Service''': a service Mozilla provides, like '''Sync''' or '''Easy Setup'''.
* '''Cluster''': Group of webheads and storage devices that make up a set of Service Nodes.
* '''Colo''': physical datacenter, may contain multiple clusters
 Cryptographically, we have the following terms: * '''HKDF''': HMAC-based Key Derivation Function, a method for deriving multiple secret keys from a single master secret (https://tools.ietf.org/html/rfc5869).* '''Two-Legged OAuth''': an authentication scheme for HTTP requests, based on a HMAC signature over the request metadata. (http://tools.ietf.org/html/rfc5849#section-3)* '''Auth Token''': used to identify the user after starting a session. Contains the user application id and the expiration date.* '''Metadata Token''': used to send application-specific metadata for the Service.* '''Master Secret''': the a secret shared between Login Server and Service Node. Never used directly, only for deriving other secrets.
* '''Signing Secret''': derived from the master secret, used to sign auth and metadata tokens. For example: sig-secret = HKDF_Expand(master-secret, "SIGN")
* '''Encryption Secret''': derived from the master secret, used to encrypt the metadata token. For example: enc-secret = HKDF_Expand(master-secret, "ENCRYPT")
Here's the proposed two-step flow (with Browser ID):
# the client trades a browser id assertion for a session an auth tokenand corresponding secret# the client turns uses the session auth token into a to sign subsequent requests using two-legged oauth token
Getting a session an auth token:
<pre>
|<--- build token [5] | | |
keep token <-------- [6] --------| | | |
create signed auth header [7] | | | |
</pre>
Client Service Node
============================================================
create signed auth header [7] | | call node --------------- [8] ---|---------------->|--> verify token [9] | | verify request signature [10] | |<-- process request [911]
get response <-------------------|-----------------|
</pre>
* the client request requests a token, giving its browser id assertion [1]
POST /request_token HTTP/1.1
* the Login Server asks the Users DB if the user is already allocated to a node. [3]
* if the user is not allocated to a node, the Login Server asks a new one to the Node Assignment Server [4]
* the Login Server creates a response with a session an auth token and corresponding token secret [5], using and sends it back to the user. The auth token contains the user id, a time stamp and a secret string only known by the selected node and itselftimestamp, and sends it back to is signed using the user along with a signing secret. The token secret is derived from the shared master secret, and auth token using HKDF (https://tools.ietf.org/html/rfc5869). It also adds the node url in the response, and optionaly a metadata token. [6]
HTTP/1.1 200 OK
Content-Type: application/json
{'oauth_consumer_key': <auth-token>, 'oauth_consumer_secret': <derivedtoken-secret>,
'service_entry': <node>,
'metadata': <metadata-token>
}
* the client calculates with the information received, an OAuth authorization header, and saves the node locationand oauth parameters to use in subsequent requests. [6]* for each subsequent request to the client calls the right nodeService, using the client calculates a special Authorization header. It tramsmits asusing two-is legged OAuth [7] and sends the request to the token and allocated node location [8] along with the metadata token if provided [7]
POST /request HTTP/1.1
Host: some.node.services.mozilla.com
Authorization: OAuth realm="Example",
oauth_consumer_key=<token>
metadata=<metadata-token>,
oauth_tokenoauth_consumer_key="kkk9d7dh3k39sjv7",<auth-token>
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="137131201", (client timestamp)
* the node is able with its shared secret uses the Signing Secret to validate that the request is valid, by calculating Auth Token [9]. If invalid or expired then the node returns a 401* the node calculates the derived key given Token Secret from its Master Secret and the salt Auth Token, and checks whether the signature in the shared secret Authorization header is valid [910]. If it's an invalid or expired token, then the node returns a 401* the node processes the request as defined by the Service [11]
== Tokens ==
A token is a json encoded mapping. They The are two tokens:
* the authorization token: contains the user application id and the expiration date.
auth_token = {'uid': '123', 'expires': 1324654308.907832}
The token is signed using the salted derived signing secret and base64-ed. The signature is HMAC-SHA1:
auth_token, signature = HMAC-SHA1(auth_token, secret_keysig_secret)
auth_token = b64encode(auth_token, salt, signature)
 
'''The authorization token is not encrypted'''
Confirm
358
edits

Navigation menu