64
Integrating services with Luca Mearelli Web2Expo - Berlin 2008

Integrating services with OAuth

Embed Size (px)

Citation preview

Page 1: Integrating services with OAuth

Integrating services with

Luca MearelliWeb2Expo - Berlin 2008

Page 2: Integrating services with OAuth

Web 2.0 means sharing data,

through API

Page 3: Integrating services with OAuth

Users want toaccess their data

using many services

Page 4: Integrating services with OAuth

Developers want tosatisfy their users

(and make it easy for them)

Page 5: Integrating services with OAuth

Service providers need tokeep their users data secure

Page 6: Integrating services with OAuth

welcomethe password antipattern

Page 7: Integrating services with OAuth
Page 8: Integrating services with OAuth
Page 9: Integrating services with OAuth
Page 10: Integrating services with OAuth

Image from http://www.codinghorror.com/blog/archives/001072.html

Page 11: Integrating services with OAuth

Passwords are precious

Page 12: Integrating services with OAuth

Stop asking them

Stop the antipattern

Page 13: Integrating services with OAuth

How to delegate access?

Page 14: Integrating services with OAuth

Your valet key for the web

Page 15: Integrating services with OAuth

a play in 3 acts (to exchange authorization)

Page 16: Integrating services with OAuth

Actors on the sceneUser

ConsumerService Provider

Page 17: Integrating services with OAuth

PrologueWhere the Consumer presents

himself to the Service Provider

Page 18: Integrating services with OAuth

Consumer (to Service Provider): here i am, this is what i do

Page 19: Integrating services with OAuth

Consumer keyConsumer secret

consumer ! service provider

Page 20: Integrating services with OAuth
Page 21: Integrating services with OAuth

First actWhere the Consumer obtains

an unauthorized Request Token

Page 22: Integrating services with OAuth

Consumer (to Service Provider): give me a request token

Page 23: Integrating services with OAuth

oauth_consumer_keyoauth_signature_methodoauth_signatureoauth_timestampoauth_nonceoauth_version (optional)

[additional parameters]

consumer ! service provider

Page 24: Integrating services with OAuth

Service Provider (to consumer): here is the request token

(you can use it only once!)

Page 25: Integrating services with OAuth

oauth_token (request token)

oauth_token_secret[additional parameters]

service provider ! consumer

Page 26: Integrating services with OAuth
Page 27: Integrating services with OAuth

Second actWhere the User authorizes

the Request Token

Page 28: Integrating services with OAuth

Consumer (to the User): Please go to the Service Provider

and authorize this request

Page 29: Integrating services with OAuth

oauth_token (request token)

oauth_callback[additional parameters]

consumer ! user ! service provider

Page 30: Integrating services with OAuth

Service Provider (to the User): Do you authorize consumer

to access your data?

Page 31: Integrating services with OAuth
Page 32: Integrating services with OAuth

User (to the Service Provider): YES!

(or maybe NO :-) )

Page 33: Integrating services with OAuth

Service Provider (to the User): You can go back to the consumer

Page 34: Integrating services with OAuth

oauth_token (request token)

user ! service provider service provider ! user ! consumer

Page 35: Integrating services with OAuth

Third actWhere the Consumer exchanges

the Request Token for an Access Token

Page 36: Integrating services with OAuth

Consumer (to the Service Provider): Please give me the acces token

for the user

Page 37: Integrating services with OAuth

oauth_consumer_keyoauth_token (request token)

oauth_signature_methodoauth_signatureoauth_timestampoauth_nonceoauth_version (optional)

consumer ! service provider

Page 38: Integrating services with OAuth

Service Provider (to the Consumer): here is the access token for the user

Page 39: Integrating services with OAuth

oauth_token (access token)

oauth_token_secret[additional parameters]

service provider ! consumer

Page 40: Integrating services with OAuth
Page 41: Integrating services with OAuth

EpilogueWhere the consumer

accesses the resources

Page 42: Integrating services with OAuth

Consumer (to the Service Provider): Here i am again on behalf of the user

Page 43: Integrating services with OAuth

oauth_consumer_keyoauth_token (access token)

oauth_signature_methodoauth_signatureoauth_timestampoauth_nonceoauth_version (optional)

[additional parameters]

consumer ! service provider

Page 44: Integrating services with OAuth
Page 45: Integrating services with OAuth

The details...

Page 46: Integrating services with OAuth

OAuth parameters exchange

HTTP Authorization headerHTTP Post body

URL query parameters

Page 47: Integrating services with OAuth

Request signing algorithmPLAINTEXT

HMAC-SHA1RSA-SHA1

Page 48: Integrating services with OAuth

Signature base stringa consistent reproducible concatenation of

the request elements into a single string

Page 49: Integrating services with OAuth

Other security measuresNonces

Timestamps

Page 50: Integrating services with OAuth

Service setupOAuth discovery (XRDS)

Page 51: Integrating services with OAuth

<?xml version="1.0" encoding="UTF-8"?>

<XRDS xmlns="xri://$xrds">

<XRD xml:id="oauth" xmlns:simple="http://xrds-simple.net/core/1.0" xmlns="xri://$XRD*($v*2.0)" version="2.0">

<Type>xri://$xrds*simple</Type>

<Expires>2008-12-31T23:59:59Z</Expires>

<Service priority="10">

<Type>http://oauth.net/discovery/1.0/consumer-identity/static</Type>

<LocalID>0685bd9184jfhq22</LocalID>

</Service>

<Service priority="10">

<Type>http://oauth.net/core/1.0/endpoint/resource</Type>

<Type>http://oauth.net/core/1.0/parameters/auth-header</Type>

<Type>http://oauth.net/core/1.0/parameters/uri-query</Type>

<Type>http://oauth.net/core/1.0/signature/HMAC-SHA1</Type>

</Service>

<Service priority="10">

<Type>http://oauth.net/core/1.0/endpoint/authorize</Type>

<Type>http://oauth.net/core/1.0/parameters/uri-query</Type>

<URI>https://api.example.com/session/login</URI>

</Service>

<Service priority="10">

<Type>http://oauth.net/core/1.0/endpoint/access</Type>

<Type>http://oauth.net/core/1.0/parameters/auth-header</Type>

<Type>http://oauth.net/core/1.0/parameters/uri-query</Type>

<Type>http://oauth.net/core/1.0/signature/PLAINTEXT</Type>

<URI>https://api.example.com/session/activate</URI>

</Service>

<Service priority="10">

<Type>http://oauth.net/core/1.0/endpoint/request</Type>

<Type>http://oauth.net/core/1.0/parameters/auth-header</Type>

<Type>http://oauth.net/core/1.0/parameters/uri-query</Type>

<Type>http://oauth.net/core/1.0/signature/PLAINTEXT</Type>

<URI>https://api.example.com/session/request</URI>

</Service>

</XRD>

<XRD xmlns="xri://$XRD*($v*2.0)" version="2.0">

<Type>xri://$xrds*simple</Type>

<Service priority="10">

<Type>http://oauth.net/discovery/1.0</Type>

<URI>#oauth</URI>

</Service>

</XRD>

</XRDS>

Page 52: Integrating services with OAuth

BenefitsGranular authorizationEasy grant and revoke

Tracking of use

Page 53: Integrating services with OAuth

Many open/free librariesuse them, contribute to them

Page 54: Integrating services with OAuth

Challenges

Page 55: Integrating services with OAuth

UI/UX for the Service ProviderProvide basic informations to the user

Ease the user’s choiceLink / enable getting deeper info

Page 56: Integrating services with OAuth

UI/UX for the ConsumerExplain what’s happening

Educate the user Use the right language

Page 57: Integrating services with OAuth

Security considerationsConfidentiality of Requests

Spoofing, Proxying, PhishingSecrecy of credentialsCryptographic issues

Denial of Service / Resource Exhaustion

Page 58: Integrating services with OAuth

Beyond the browserMobile devices

Installable applications

Page 59: Integrating services with OAuth
Page 60: Integrating services with OAuth

The sequelOAuth over XMPP

Page 61: Integrating services with OAuth

<iq from='[email protected]/bot'

id='sub1'

to='feeds.worldgps.tld'

type='set'>

<pubsub xmlns='http://jabber.org/protocol/pubsub'>

<subscribe node='bard_geoloc'/>

<oauth xmlns='urn:xmpp:tmp:oauth'>

<oauth_consumer_key>0685bd9184jfhq22</oauth_consumer_key>

<oauth_nonce>4572616e48616d6d65724c61686176</oauth_nonce>

<oauth_signature>wOJIO9A2W5mFwDgiDvZbTSMK%2FPY%3D</oauth_signature>

<oauth_signature_method>HMAC-SHA1</oauth_signature_method>

<oauth_timestamp>1218137833</oauth_timestamp>

<oauth_token>ad180jjd733klru7</oauth_token>

<oauth_version>1.0</oauth_version>

</oauth>

</pubsub>

</iq>

Page 62: Integrating services with OAuth

The moraleIntegrating services can be done

without asking or storing the user’s credentials while at the same time

gaining flexibility and control.

Page 63: Integrating services with OAuth

Links!http://oauth.nethttp://oauth.net/core/1.0/http://code.google.com/p/oauth/http://groups.google.com/group/oauth/http://oauth.net/discovery/1.0

Page 64: Integrating services with OAuth

Thanks for listening!!

Luca Mearellihttp://spazidigitali.com

[email protected]