Merb Auth

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

    2 Favorites

    Merb Auth - Presentation Transcript

    1. MerbAuth Darwinian Authentication
    2. In The Beginning Conditions for Authentication were ripe Merb Plugins Rubigen with scopes (6th Nov 2007) Restful Authentication was missing
    3. merbful_authentication
    4. merbful_authentication Released 4th January 2008 Direct port of Restful Authentication Supported DataMapper & ActiveRecord Supported Rspec & Test::Unit
    5. Pros First plugin with multi-ORM support in Merb A lot of applications used it
    6. Cons Generated code Very complex Maintenance sucked
    7. The Catalyst Slices were born
    8. Original merb-auth
    9. merb-auth Mostly direct port of merbful_authentication Used brand new slices plugin Moved to Library Code not Generated ORM support via mixins Forgotten Passwords 17 June 2008
    10. merb-auth - Pros Live code. Not generated Minimal Application Configuration Implemented as a slice Easier to maintain (still sucked)
    11. merb-auth - Cons User model hidden Hard to please all through configuration Unclear how to customize it Tied to one model type Dictates user model Extensions difficult (No OpenID) Difficult to change logic
    12. Evolutionary Step Required
    13. The Catalyst Adam French proposed: Authenticating Sessions Simple session based api Using Exceptions to refuse entry Provides correct status code
    14. ExceptionalAuthentication Adam created a prototype ExceptionalAuthentication Application including his proposals
    15. Session API session.authenticated? session.authenticate! session.user session.user= session.abandon!
    16. ExceptionalAuthentication Originally a DataMapper based system Decided to allow arbitrary “user” objects
    17. Code Named - Mauth
    18. MerbAuth - What is it? Authentication Framework Cascading Strategy Concept Only what’s needed to support authentication Supports user objects such as DM, AR, Sequel, Hash, String, File, IO, or just plain old Object
    19. MerbAuth - What it’s Not A user management system
    20. Default Merb Stack Merb stack includes MerbAuth with: Password Slice Password based form authentication Basic Authentication Salted Users Routes / Forms
    21. Activating Merb Stack Comes with a Basic User model (Change it up) rake db:automigrate Make something to protect
    22. Protect It Route Level authenticate do resources :paychecks end Controller Level before :ensure_authenticated
    23. Activating Merb Stack Add a user to the system Login “/login”
    24. Protect - Router Based authenticate(BasicAuth) do resources :api authenticate do resources :posts do resources :comments end end end
    25. Controller Based :ensure_authenticated before :ensure_authenticated # OR before :ensure_authenticated, :with => [OpenID, BasicAuth]
    26. Why Protect Routes?
    27. Why Protect Routes? RACK CONTROLLER Pass FILTERS DISPATCHER AUTH ACTION + FAIL RENDER ROUTER RACK FILTERS
    28. What is a Strategy? Strategy contains logic for “Authentication” Implements a #run! method class PasswordStrategy < Merb::Authentication::Strategy def run! login = request.params[:login] password = request.params[:password] User.authenticate!(login, password) if login end end Declare many. One for each login type
    29. MerbAuth Cascading Strategies Each strategy is run in order Success == First Strategy to return object Failure == No Strategies return object Stops trying when authenticated Re-order strategies with Merb::Authentication.default_strategy_order=
    30. What Happens on Fail? Raises Unauthenticated exception Uses Merbs Exception Handling Exceptions#unauthenticated Sets correct status code
    31. Display Errors <%= error_messages_for session.authentication %>
    32. Customize Login Form Exceptions#unauthenticated (view)
    33. How to Logout? session.abandon!
    34. What Strategies Are There? Password based form login Open ID Basic Authentication Require a default strategy to load / define it Monkey patch parts of it you need to change
    35. Mixins Use mixins to extend your User or MerbAuth Salted User mixin Redirect Mixin (redirect_back_or)
    36. Advanced Strategies Loaded in order of declaration Implement a #run! method Use Inheritance to share code Arbitrary Object Session Serialization Return an object from #run! to authenticate
    37. Advanced Strategies YourStrategy#redirect! YourStrategy.abstract! YourStrategy#user_class YourStrategy#headers YourStrategy#status request.params (request params) params (route params)
    38. Failure Messages Inside a strategy session.authentication.errors.add(:label, \"message\")
    39. Overview of Advanced Setup require ‘merb-auth-core’ Define <User> model (Maybe) Setup session storage Declare strategies Protect methods Setup login / logout actions
    40. Where Next? Implement slices Implement Strategies & Mixins
    41. Resources http://adam.speaksoutofturn.com/articles/ entication_vs_orization.html http://github.com/wycats/merb-more/merb-auth http://github.com/ck/cookbook http://github.com/RichGuk/merb-auth-example
    42. Thanks Adam French Ben Burket

    + hassoxhassox, 2 years ago

    custom

    3731 views, 2 favs, 0 embeds more stats

    A talk given at merbcamp debuting merb-auth

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 3731
      • 3731 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 71
    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