rack for user authentication

29
RIRUG http://rirug.com Rack For User Authentication

Upload: craig-jolicoeur

Post on 18-May-2015

5.395 views

Category:

Technology


3 download

DESCRIPTION

Using Rack for user authentication with Rack apps

TRANSCRIPT

Page 1: Rack for User Authentication

RIRUGhttp://rirug.com

RackFor User Authentication

Page 2: Rack for User Authentication

RIRUGhttp://rirug.com

Common Web App Needs

Page 3: Rack for User Authentication

RIRUGhttp://rirug.com

Common Web App Needs

• A User

Page 4: Rack for User Authentication

RIRUGhttp://rirug.com

Common Web App Needs

• A User

• A way to associate requests with that user

Page 5: Rack for User Authentication

RIRUGhttp://rirug.com

Many Current Auth Solutions

• RESTful Authentication

• AuthLogic

• Clearance

• OpenID

• HTTP Auth

• LDAP

• CAS

• Roll Your Own

Page 6: Rack for User Authentication

RIRUGhttp://rirug.com

Why Another One?

Page 7: Rack for User Authentication

RIRUGhttp://rirug.com

RackRails 2.3 introduced Rack

compatibility.

Rails 3 is Rack dependent.

Rack allows for modular application design.

Page 8: Rack for User Authentication

RIRUGhttp://rirug.com

Default Rails Rack Stack

Page 9: Rack for User Authentication

RIRUGhttp://rirug.com

How Does This Affect Authentication?

• Rack allows for “mountable apps”

• Rails middleware

• Rails metal

Page 10: Rack for User Authentication

RIRUGhttp://rirug.com

How will your authentication cope?

Page 11: Rack for User Authentication

RIRUGhttp://rirug.com

Apps Usually Need a “User”

Page 12: Rack for User Authentication

RIRUGhttp://rirug.com

Current Authentication Systems Will Conflict

Between Apps

Page 13: Rack for User Authentication

RIRUGhttp://rirug.com

Page 14: Rack for User Authentication

RIRUGhttp://rirug.com

Warden

• Injects a lazy proxy into the request

• Proxy follows around the request

• Does nothing until asked

• Authenticates requests for any kind of “user”

• Provides a mechanism for authentication

• Available to all downstream Rack parts

Page 15: Rack for User Authentication

RIRUGhttp://rirug.com

Authenticating(Loggin In)

Page 16: Rack for User Authentication

RIRUGhttp://rirug.com

Accessing the user

Page 17: Rack for User Authentication

RIRUGhttp://rirug.com

Logging Out

Page 18: Rack for User Authentication

RIRUGhttp://rirug.com

Authentication Logic

• Strategy Based

• Packagable

• Sharable between discrete apps

• Simple

Page 19: Rack for User Authentication

RIRUGhttp://rirug.com

Warden Strategy

Page 20: Rack for User Authentication

RIRUGhttp://rirug.com

Strategies

• Multiple Strategies

• Strategies Cascade

Page 21: Rack for User Authentication

RIRUGhttp://rirug.com

Rack Setup

Page 22: Rack for User Authentication

RIRUGhttp://rirug.com

Rails Integration

Page 23: Rack for User Authentication

RIRUGhttp://rirug.com

Warden + Devise

Page 24: Rack for User Authentication

RIRUGhttp://rirug.com

Devise

• Flexible Rails authentication based on Warden

• Rack based

• Complete MVC solution using Rails engines

• Allows for multiple roles (models/scopes)

• Based on modularity

Page 25: Rack for User Authentication

RIRUGhttp://rirug.com

Devise Modules

• Database Authenticatable

• Token Authenticatable

• Confirmable

• Recoverable

• Rememberable

• Registerable

• Trackable

• Timeoutable

• Validatable

• Lockable

Page 26: Rack for User Authentication

RIRUGhttp://rirug.com

Demo

Page 27: Rack for User Authentication

RIRUGhttp://rirug.com

Rack Resources

• http://rack.rubyforge.org/

• http://rack.rubyforge.org/doc/SPEC.html

• http://railslab.newrelic.com/2009/06/05/episode-14-rack-metal

Page 28: Rack for User Authentication

RIRUGhttp://rirug.com

Warden Resources

• http://www.slideshare.net/hassox/warden-introduction

• http://wiki.github.com/hassox/warden/overview

• http://github.com/hassox/rails_warden