Warden Introduction

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    3 Favorites

    Warden Introduction - Presentation Transcript

    1. Warden General Rack Authentication
    2. Many Web Apps Need
    3. 1. A User
    4. 2. A way to associate it with a request
    5. Many Solutions Exist • • Restful Authentication Basic Auth • • AuthLogic Digest • • Merbful Authentication LAPD • • Merb-Auth CAS • Home Grown • OpenID
    6. Why Another One?
    7. Rack
    8. Rack Router
    9. class SimpleRack include Rack::Router::Routable def initialize prepare do |r| r.map \"/\", :to => router { |c| c.map \"/hello\", :to => ChildApp } r.map \"/hello\", :to => ParentApp r.map \"/one\", :to => lambda { |env| do_one(env) } r.map \"/two\", :to => lambda { |env| do_two(env) } end end def do_one(env) # Stuff end def do_two(env) # Stuff end end
    10. Mountable Apps
    11. How Will Your Authentication Cope?
    12. Apps Usually Need a “User”
    13. Current Breed Will Conflict Between Apps
    14. Warden • Injects a very lazy proxy into the request • Proxy follows around in the request • Does nothing until you ask it • Authenticates Requests for any kind of “User” • Provides a mechanism for Authentication • Available in all downstream Rack parts
    15. Authenticating (Logging In) env['warden'].authenticate :password env['warden'].authenticate! :password, :basic, :open_id env['warden'].authenticated? :password
    16. Accessing The User env['warden'].user
    17. Logging Out env['warden'].logout
    18. Authentication Logic • Strategy Based • Packagable • Sharable between discrete Apps • Simple
    19. Strategy Warden::Strategies.add(:password) do def valid? params[:username] || params[:password] end def authenticate! u = User.authenticate(params[:username], params[:password]) u.nil? ? fail!(\"Could not log in\") : success!(u) end end
    20. Strategies • Multiple Strategies • Strategies Cascade env['warden'].authenticate! :password, :basic, :open_id
    21. Failure throw(:warden) throw(:warden, :some => :option) Drops out to a “Failure Application”
    22. Rack Setup Rack::Builder.new do use Rack::Session::Cookie use Warden::Manager do |manager| manager.default_strategies :password, :basic manager.failure_app = BadAuthenticationEndsUpHere end run SomeApp end
    23. Session Integration Warden::Manager.serialize_into_session{ |user| user.id } Warden::Manager.serialize_from_session{ |key| User.get(id)}
    24. Other Features • Callbacks • User Scopes - Multiple Users / session • Authenticated Session Data • Locks Session per user
    25. Rails Integration config/initializers/warden.rb Rails.configuration.middleware.use Warden::Manager do |manager| manager.default_strategies :password manager.failure_app = LoginController end # Rails needs the action to be passed in with the params Warden::Manager.before_failure do |env, opts| request = env[\"action_controller.rescue.request\"] request.params[\"action\"] = \"unauthenticated\" end # Session Serialization & Strategies
    26. More Information • http://github.com/hassox/warden • http://wiki.github.com/hassox/warden

    + hassoxhassox, 7 months ago

    custom

    1329 views, 3 favs, 0 embeds more stats

    A introductory talk about Warden, a Ruby Rack authe more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1329
      • 1329 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 3
    • Downloads 17
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories