omniauth: from the ground up

40
OmniAuth: From the Ground Up Michael Bleigh / Red Dirt Ruby Conf 2011

Upload: michael-bleigh

Post on 18-May-2015

14.132 views

Category:

Technology


2 download

DESCRIPTION

Slides from my Red Dirt Ruby Conf 2011 talk about OmniAuth. Source code at https://github.com/mbleigh/omniauth-from-the-ground-up

TRANSCRIPT

Page 1: OmniAuth: From the Ground Up

OmniAuth: From the Ground Up

Michael Bleigh / Red Dirt Ruby Conf 2011

Page 2: OmniAuth: From the Ground Up

Michael Bleigh

Page 3: OmniAuth: From the Ground Up

@mbleigh

Page 4: OmniAuth: From the Ground Up

@intridea

Page 5: OmniAuth: From the Ground Up

OmniAuth!github.com/intridea/omniauth

Page 6: OmniAuth: From the Ground Up

Not JUST RailsIt’s Rack, Baby!

Page 7: OmniAuth: From the Ground Up

Login viaanything

Page 8: OmniAuth: From the Ground Up

Past.Present.Future.

Page 9: OmniAuth: From the Ground Up

Past!The why of OmniAuth

Page 10: OmniAuth: From the Ground Up

Why are there so many Ruby authentication

solutions?

Page 11: OmniAuth: From the Ground Up

Assumptions.

Page 12: OmniAuth: From the Ground Up

I only need one User model.

Users will sign up and provide a password.

Only e-mail can validate users.

I only need one authentication method.

I’m only going to use Rails in my app.

I don’t want to customize anything.

Page 13: OmniAuth: From the Ground Up

Magic in all the wrong places.

Page 14: OmniAuth: From the Ground Up

Can we do better?

Page 15: OmniAuth: From the Ground Up

I Need Auth

User Info

MAGIC!

Page 16: OmniAuth: From the Ground Up

OmniAuth

Page 17: OmniAuth: From the Ground Up

An expanding,normalized system

for external authentication.

Page 18: OmniAuth: From the Ground Up

March 30, 2010 First Commit

October 1, 2010 0.1.0 (public release)

It takes a while to make easy things.

Page 19: OmniAuth: From the Ground Up

0.1.010 providers,

3 contributors

Page 20: OmniAuth: From the Ground Up

0.2.336 providers,

52 contributors

Page 21: OmniAuth: From the Ground Up

37signals Bit.ly CAS DailyMile Doit.im Dopplr Evernote Facebook

Flickr Foursquare GitHub Goodreads Google Google Apps Gowalla Hyves Identi.ca Instagram Instapaper LDAP LinkedIn Meetup Miso Mixi Netflix

OpenID Salesforce SmugMug SoundCloud TeamBox TradeMe

TripIt Tumblr Twitter Vimeo Vkontakte YouTube

Page 22: OmniAuth: From the Ground Up

Present!The how of OmniAuth

Page 23: OmniAuth: From the Ground Up

Let’s kill the magic.

image via stopdropandrew.com

Page 24: OmniAuth: From the Ground Up

The Guts

• OmniAuth is just middleware

• Each provider is a strategy

• Each strategy has three phases:

• Setup Phase

• Request Phase

• Callback Phase

Page 25: OmniAuth: From the Ground Up

The User Info Hash{    “provider”  =>  “friendface”,    “uid”  =>  “123456”,    “user_info”  =>  {        “nickname”  =>  “mbleigh”,        “name”  =>  “Michael  Bleigh”,        “email”  =>  “[email protected]”    },    “auth”  =>  {        “token”  =>  “120942310491asfas-­‐213-­‐0123”    }}

Page 26: OmniAuth: From the Ground Up

The Bare Minimum

{    “provider”  =>  “minimal”,    “uid”  =>  “123456”,    “user_info”  =>  {        “name”  =>  “Michael  Bleigh”    }}

Page 27: OmniAuth: From the Ground Up

Setup Phase

• Optional (:setup  =>  true)

• Calls through to app to allow:

• Dynamic provider credentials

• Runtime strategy modification

• Stuff I haven’t thought of

Page 28: OmniAuth: From the Ground Up

Request Phase

• Requests information of the user

• For OAuth, redirects to provider

• For OpenID, requests URL

• For LDAP, requests user/pass

/auth/:provider

Page 29: OmniAuth: From the Ground Up

Callback Phase

• Creates the user info hash

• For OAuth, grabs and uses access token to fetch user info

• For OpenID, parses the response

• For LDAP, retrieves directory info

/auth/:provider/callback

Page 30: OmniAuth: From the Ground Up

Roll your own!

Page 31: OmniAuth: From the Ground Up

Hell yeah!Lightning

Livecoding!

Page 32: OmniAuth: From the Ground Up

Future!The what now of OmniAuth

Page 33: OmniAuth: From the Ground Up

OmniAuth for internal auth?

Page 34: OmniAuth: From the Ground Up

oa-identity

• Treat internal auth like an external provider

• Same flow (request, callback)

• Customizable user info

• Mission: RailsConf!

Page 35: OmniAuth: From the Ground Up

Playing even nicer with others.

Page 36: OmniAuth: From the Ground Up

RobusterRails integration.

Page 37: OmniAuth: From the Ground Up

oa-rails

• Authentication model generator

• Convenience hooks for building your stable of providers

• An (optional) fully automatic engine-based auth flow

Page 38: OmniAuth: From the Ground Up

Dev Friendliness

Page 39: OmniAuth: From the Ground Up

[your  idea  here]

Page 40: OmniAuth: From the Ground Up

Thanks!

@mbleigh @intrideagithub.com/intridea/omniauth

http://spkr8.com/t/7281