If I was to implement a new server-to-server API, what authentication standards are available to make it as easy for others to consume?
Ideally the less I need to document about how the authentication works, the better (hence the standard), and its more likely that developers consuming the service can use a standard library.
Some restrictions though:
- I can't guarantee that the API will be available on HTTPS, as it may be on a box hosting multiple websites (with 1 IP address).
- It should block replay attacks... so if the request was captured by another node on the network, that same request can't be re-sent to the API.
- Ideally you should just send the request and get back a response... so no need to contact the API first to get a one-time key (nonce)
- The request should probably be signed by the sender in its entirety, to avoid man-in-the-middle type attacks.
I suspect an SSL type setup is a bit too complicated, as it seems most developers don't really know how to implement it properly.
With oAuth 1.0, it seems fairly simple:
http://provider.example.net/profile
Authorization: OAuth realm="http://provider.example.net/",
oauth_consumer_key="dpf43f3p2l4k3l03",
oauth_signature_method="HMAC-SHA1",
oauth_signature="IxyYZfG2BaKh8JyEGuHCOin%2F4bA%3D",
oauth_timestamp="1191242096",
oauth_token="",
oauth_nonce="kllo9940pd9333jh",
oauth_version="1.0"
But developers seem to be focusing on oAuth 2 now, with one possible solution being:
How does 2-legged oauth work in OAuth 2.0?
Which first requires you to call "/oauth/token" to get a token, but there doesn't seem to be much in the form of a specification on how this actually works (see replies):
http://www.ietf.org/mail-archive/web/oauth/current/msg07957.html
However there is some mention of using a MAC in oAuth 2, which might be useful... for example, do the Authorization once to get the MAC (with no login details), keep this semi indefinitely, and re-use for all subsequent requests:
http://blog.facilelogin.com/2013/01/oauth-20-bearer-token-profile-vs-mac.html
There is also an interesting discussion about HMAC, which kind of implies there isn't a standard on how this works either:
http://flascelles.wordpress.com/2010/01/04/standardize-hmac-oauth-restful-authentication-schemes/
Other notes:
Implementation, documentation and discussion for oAuth 1.0:
http://www.ietf.org/mail-archive/web/oauth/current/msg06218.html https://developers.google.com/accounts/docs/OAuth#GoogleAppsOAuth http://oauth.googlecode.com/svn/spec/ext/consumer_request/1.0/drafts/2/spec.html
Unfortunately the more I read about oAuth 2.0, the more I agree with Eran Hammer:
What is now offered is a blueprint for an authorisation protocol, "that is the enterprise way", providing a "whole new frontier to sell consulting services and integration solutions". http://en.wikipedia.org/wiki/OAuth