open id, o auth and webservices

44
OpenID, OAuth and Webservices A developers guide eb Directions 2008 - Myles Eftos

Upload: myles-eftos

Post on 14-Jan-2015

4.162 views

Category:

Technology


2 download

DESCRIPTION

This presentation was given at Web Directions South in 2008. It is a developers guide to building sites using OpenID, OAuth and webservices - no code, but enough to point you in the right direction

TRANSCRIPT

Page 1: Open Id, O Auth And Webservices

OpenID, OAuth and Webservices

A developers guide

Web Directions 2008 - Myles Eftos

Page 2: Open Id, O Auth And Webservices

Our lives in digits

So many web apps - so many usernames, so many passwords

How do we access our data?

How can we do that safely?

How can we do it easily?

Page 3: Open Id, O Auth And Webservices

Meet Jim

Uses Twitter, Gmail, Digg, Newsgator, LinkedIn + many more

His housemate finds his username and password

Hilarity ensues

Page 4: Open Id, O Auth And Webservices

OpenID to the rescue!

There are consumers, and there are providers

Everyone gets a URL

Magic happens…

Page 5: Open Id, O Auth And Webservices

Step 1

User enters their OpenID URL

Page 6: Open Id, O Auth And Webservices

Step 2

Consumer discovers link tagsfor delegation

<link rel="openid.server" href="http://my.openid.server"><link rel="openid.delegate" href="http://madpilot.openid.server">

Page 7: Open Id, O Auth And Webservices

Step 3

Consumer redirects to theProvider login screen

openid.mode = checkid_setupopenid.identity = http://myid.openid.comopenid.return_to = http://www.consumer.com?rp_nouce=[RANDOM]openid.trustroot = http://www.consumer.com

Page 8: Open Id, O Auth And Webservices

Step 4

User enters credentials

Page 9: Open Id, O Auth And Webservices

Step 5

Provider redirects to Consumerwith return_url parameters

openid.mode = id_resopenid.return_to = http://www.consumer.com?rp_nouce=[RANDOM]

openid.identity = http://madpilot.openid.comopenid.signed = mode,identity,return_to

openid.assoc_handle = [some hash]openid.sig = [Base64 encoded HMAC signature]

Page 10: Open Id, O Auth And Webservices

Step 6

Consumer POSTs back tovalidate what was returned

openid.mode = check_authenticationopenid.signed = mode,identity,return_toopenid.assoc_handle = [same hash as before]openid.sig = [Same Base64 encoded HMAC signature as before]openid.return_to = http://www.consumer.com?rp_nouce=[RANDOM]Openid.identity = http://madpilot.openid.com

Page 11: Open Id, O Auth And Webservices

Step 7

If the returned values look okthe Provider returns is_valid:true

is_valid:true

Page 12: Open Id, O Auth And Webservices

And again with passion

Dumb mode has lots of redirects

Not-dumb mode asynchronously (AJAX) gets an immediate answer

If the user is logged in, the user can continue

If not, decide what to do (authenticate would be a good idea)

Page 13: Open Id, O Auth And Webservices

Simple Registration

SREG to it’s friends

Send your favourite parameters

Pull nickname, email, date of birth, gender, country, language, time zone

Consumer can request required and optional parameters

Page 14: Open Id, O Auth And Webservices

I want my data!

Data in the cloud is cool

Backups, hardware upgrades – someone else’s problem

Vendor lock-in is the suck

Web services are the awse

Page 15: Open Id, O Auth And Webservices

REST vs SOAP

The world needs more religious wars

Both lie on HTTP

Both use XML*

Remote Procedure Pattern vs. Resource Pattern

* REST doesn’t really care…

Page 16: Open Id, O Auth And Webservices

SOAP: Why no one uses it

In theory it rocks.

Has a description language (WDSL)

It is verbose

Perhaps, something more Ideological?

Page 17: Open Id, O Auth And Webservices

REST: The web for computers

The web is based on resources

Type in a URL: GET that resource

Submit a form: POST to that resource

Forgotten verbs: PUT and DELETE

Page 18: Open Id, O Auth And Webservices

One end point to rule them all

OK, maybe two

/companies.xml GET Returns all companies

/companies.xml POST Creates a new company

/companies/1.xml GET Return the company with id=1

/companies/1.xml PUT Update the company with id=1

/companies/1.xml DELETE Delete the company with id=1

Page 19: Open Id, O Auth And Webservices

HTTP/1.1 101

HTTP does a lot of stuff

Page 20: Open Id, O Auth And Webservices

HTTP/1.1 101

HTTP does a lot of stuff

Status codes

200 OK!

201 Created

301 Moved Permanently

400 Bad Request

401 Authorization Required

403 Forbidden

404 Not Found

405 Not allowed

410 Gone

422 Invalid Entity

500 Server Error

503 Server Unavailable

Page 21: Open Id, O Auth And Webservices

HTTP/1.1 101

HTTP does a lot of stuff

Status codes

Headers and modifiers

If-Modified-Since

If-Unmodified-Since

If-Match

If-None-Match

If-Range

Page 22: Open Id, O Auth And Webservices

Communism doesn’t work

You don’t want any old person changing stuff

401 Authorization Required

Still needs a password though – a pure OpenID implementation is out

Anti-password pattern alert!

Page 23: Open Id, O Auth And Webservices

Check up on Jim

Signs up to a new Web 2.0 CRM

Offers to copy contacts from Gmail

Requires your Gmail username and password… Sounds phishy

Page 24: Open Id, O Auth And Webservices

Bloody OAuth it is…

OAuth is a machine authorisation protocol

Like a Valet Key

Give permission for a system to access your account

…or take away permission

Again, there are Providers and there are Consumers

Page 25: Open Id, O Auth And Webservices

Step 1

User wants to access their photosfrom another service

Page 26: Open Id, O Auth And Webservices

Step 2

Consumer sends a POST request to the request token URL at the Provider. It identifies itself using a shared secret key that was prepared earlier

Page 27: Open Id, O Auth And Webservices

Step 3

The Provider returns a unauthorised request token.The token is good for one use

Page 28: Open Id, O Auth And Webservices

Step 4

The consumer redirects the user to theAuthorisation URL of the provider

Page 29: Open Id, O Auth And Webservices

Step 5

If the user hasn’t logged in to the Providerservice, they do so now on the Provider

You could use OpenID for this bit

Page 30: Open Id, O Auth And Webservices

Step 6

The Provider asks the user if they reallywants to let the Consumer have the photos

Page 31: Open Id, O Auth And Webservices

Step 7

The Provider redirects the user back to the Consumerand lets the Provider know that is can request a

authorized token

Page 32: Open Id, O Auth And Webservices

Step 8

The Consumer requests an authorised tokenusing the now authorised request token

Page 33: Open Id, O Auth And Webservices

Step 9

The Provider exchanges the request tokenfor an access token. This token is

good for a pre-determined period of time(Maybe forever)

Page 34: Open Id, O Auth And Webservices

Step 10

The Consumer can now accessthe data using it’s access token

Page 35: Open Id, O Auth And Webservices

Step 11

The Provider sends the data ifthe access token checks out

Page 36: Open Id, O Auth And Webservices

Look ma – no passwords!

User never enters their password on the Consumer

The Consumer actually has it’s own password (the token)

The token can be revoked, stopping access

Page 37: Open Id, O Auth And Webservices

The Dark Side: OpenID

Phishing

DNS Spoofing

Not an AUTHORISATION system

Consumer has to trust the Provider

Doesn’t really work without a browser

Page 38: Open Id, O Auth And Webservices

The Dark Side: REST

No standard! (Lather, rinse, repeat)

No description language – requires more legwork

Page 39: Open Id, O Auth And Webservices

The Dark Side: OAuth

Doesn’t work so well without a browser

More complex/higher overhead than username/password

Doesn’t work with cURL

Page 40: Open Id, O Auth And Webservices

Yadis with egg and cheese

Service discovery protocol

OpenID is the only open, distributed authentication system (Surprised?)

XML RDF based

Allows Providers and Consumers to negotiate protocols

Page 41: Open Id, O Auth And Webservices

Yadis with egg and cheese

<?xml version=“1.0” encoding=“UTF-8”?>

<xrds:XRDS xmlns:xrds=“xri://$xrds” xmlns=“xri://$xrd*($v*2.0)”>

<XRD>

<Service>

<Type>http://lid.netmesh.org/sso/2.0</Type>

</Service>

<Service>

<Type>http://lid.netmesh.org/sso/1.0</Type>

</Service>

</XRD>

</xrds:XRDS>

Page 42: Open Id, O Auth And Webservices

You know what would be cool?

OpenID on your desktop

OpenID on your mobile

Webservice brokering system

File system integration

Page 43: Open Id, O Auth And Webservices

Your local libraries

OpenID: http://wiki.openid.net/Libraries

OAuth: http://oauth.net/code

Page 44: Open Id, O Auth And Webservices

In conclusion, Thank You

Question time starts… Now