Table of contents:
Background information about OAuth
This section proposes a quick introduction to OAuth concepts.
For a detailed presentation of OAuth, you should read the OAuth 1.0 Protocol specification.
Problem to solve
OAuth addresses authentication issues in cases that include:
- a Service Provider that exposes a web service,
- a User that wants to access the service,
- a Service Consumer that will access the Service Provider on behalf of the user.
In this context, the end user may have different accounts on each application.
The User may also want to grant more or less rights to the consumer. Typically, when Application A access to services of Application B, it may be granted only read accesses. But when using Application C, users wants to grant Read/Write.
OAuth provides a solution to handle this problem.
The synopsis of the authentication goes like that:
- User wants to access a module of Application A that needs to access a Service hosted by B (for example an OpenSocial Gadget)
- Application A will request a "Request Token" from Application B
- Application B will respond with:
- a Request Token
- an authentication URL
- User will be redirected to the authentication URL on the Application B
- User will then
- authenticate against Application B
- accept the access request from Application A displayed by Application B (and maybe specify some associated security)
- User will then be redirected to Application A (on the callback url, with the token and a random verifier)
- Application A will receive the request
- call Application B to exchange the Request Token for an Access Token
- Application B will only allow the exchange if
- the verifier is OK
- the Request Token has been granted by user
- Application A will then
- store the Access Token
- use it to access Service in B on behalf of User
The interesting part is that:
- User does not have to give Application A his login/password on Application B
- User can choose how Application A can access his data on Application B
- define security if needed
- he should also be able to revoke the grant at any time
- Application A can store the token and reuse it as long as it is valid (no more authentication needed)
- Application A and B do not need to share the same user DB
2-Legged OAuth (Signed Fetch)
Of course 3-Legged OAuth is not always the best option. In some situations, you only want to do a server-to-server authentication.
To answer this use case, OAuth supports a simple mode that will only use the OAuth signature system (see below) to have a trusted communication between two servers.
An important part of OAuth is that the http requests have to be signed:
- to be able to verify the identity of the caller
- to be sure the request was not modified during the transfer
For that OAuth can use 2 different signing methods:
- HMAC symmetric signature (Shared Secret)
- RSA1 asymmetric signature (Public /Private keys)
All requests using OAuth (2-Legged or 3-Legged) are signed using one of these 2 signature method.
The signature method is part of the request and may be chosen by the client, but the server may also enforce one of them.
In terms of security both methods have pros and cons, but RSA1 is generally more expensive.
OAuth in Nuxeo EP
Managing Service Consumers in Nuxeo
Consumers are declared in Nuxeo OAuthConsumerRegistry.
You can access this service via the Admin Center / OAuth / Consumers.
To define a OAuth Consumer you will need to enter:
- a Consumer Key: identifier of the application
- a Consumer Secret (HMAC key) and/or a RSA1 public key
- a callback url
- only needed for 3-Legged OAuth
- most consumers will automatically provide this callback url as part of the OAuth dialog
- a security mode
- you can restrain consumer usage to 3-Legged OAuth
- you can accept 2-Legged OAuth (i.e. only server-to-server authentication), in this case you will need to choose how the nuxeo user will be chosen:
- OpenSocial viewer
- OpenSocial owner
- Dedicated login
Depending on the consumer, it may not allow all possibilities:
- may be only HMAC signature will be supported
- may be only 3-Legged OAuth will be supported
For example, you may want to use iGoogle as a consumer of some of your Nuxeo Gadgets and services.
In this case, you will need to a consumer with:
- www.google.com as consumer key
- use RSA1 key as documented here
- provide in Nuxeo the callback url http://oauth.gmodules.com/gadgets/oauthcallback
The special case of Nuxeo/Shindig
When Nuxeo is both the provider and the consumer, 2-Legged OAuth (signed Fetch) is used with a HMAC Signature. The HMAC secret is dynamically generated at runtime and shared between Shindig and Nuxeo in memory.
Nuxeo OAuth Urls
Access URL: /nuxeo/oauth/access-token (url to request an Access Token)
Request URL: /nuxeo/oauth/request-token (url to request a Request Token)
Authorization URL: /nuxeo/oauth/authorize (url used by a User to grant access)
Managing Service providers in Nuxeo
Service providers are declared in OAuthServiceProviderRegistry.
You can access it via Admin Cener / OAuth / Service providers.
You will have to enter the following information:
- a gadget URL (AppId): the identifier of the gadget inside Nuxeo that will use the service
- a service Name: the name of the service as used in the makeRequest call
- a consumer Key: the consumer key (login) that must be used to call the service
- a consumer Secret (HMAC key): a shared secret used to sign OAuth requests
- OAuth callback urls
OAuth callback urls will only be used if the gadget does not provide the needed information as part of the Gadget Spec (it should). If the consumer secret is empty, Nuxeo with use the server global RSA1 key.
When looking up the right service provider, Nuxeo will do the search based on the service Name and the AppId and fallback to the closest match.
OAuth requires Nuxeo to manage Tokens:
- Request Tokens are managed in memory (transient)
- Access Token are managed in the SQL DB
You can use the Admin Center screens to:
- see the Tokens that Nuxeo granted or was granted
- revoke (delete) the Tokens