Rails authentication with Authlogic RPX

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

    Favorites, Groups & Events

    Rails authentication with Authlogic RPX - Presentation Transcript

    1. NB: This presentation was delivered at the Singapore Ruby Brigade meetup 7-Oct-2009 (hosted at wego.com)
    2. Some things should just be banned on the interwebs..
    3. .. pointless social “applications” ..
    4. .. pointless social “applications” ..
    5. .. twitter celebs ..
    6. .. twitter celebs ..
    7. .. custom login screens!
    8. .. custom login screens!
    9. What’s so bad about that?
      • Security
        • Proliferation of credentials unavoidably leads to greater risks
        • Do sites hash my password?
      • PITA
        • Redundant entry of registration details
        • Validation emails.. aargh!
        • Code bloat: reset/forgot password flows
        • Site developer’s need to be (should be!) security experts
      • Enterprise clients
        • Ideally want your site to treat employees as “verified employees” not just part of the madding crowd
        • Public sites: still in its infancy. Belief: before long, enterprises will clue in to this, and be “exporting” corporate credentials for use on the web. If your site supports this, you can win big.
    10. End of days for “own the user identity”?
      • Consumers: already have (multiple) “identities”
        • Hypothesis: these days a reasonable assumption
        • Why should I jump thru hoops to create another just so I can try your site?
      • Businesses: don’t really want their employees creating new “identities” on your site if it is for business purposes
        • Compliance – no control or visibility of what employees are doing or information they are creating
        • Data ownership – what happens when the employee leaves?
    11. Or “Why authentication and identity management is still worth talking about”
    12. Authorisation Options
      • Sometimes there’s no choice
        • No internet access
        • Legacy accounts
      • Special purpose
        • Admin or test users for example
      Internal (username / password)
    13. LDAP/AD Intranet applications Legacy directories
      • Supports many providers , which don’t need to be known ahead of time
      • Consumer adoption has been relatively slow, although many users now have an OpenID (via Yahoo or Google)
        • even though they don’t know this!
      • Criticised for being a little too “technical” for the average web citizen(!)
    14. OAuth Must tie to a specific provider ahead of time Also used as the basis of OpenSocial signed requests Great if you just want to target a specific community (e.g. build a twitter app)
    15. A single-sign-on solution for web sites Abstracts the authentication provider – you can support as many as JanRain support Normalizes profile settings across providers (i.e. “email” is always “email”) RPX by JanRain
    16. SAML – WS* security mainly enterprise use, but now gaining some attention via openSSO 2FA/3FA solutions – provider specific or custom integrated Many others..
    17. Authentication options in Rails Internal (username/password) LDAP/AD RPX by JanRain Many others.. OAuth Acts_as_authenticated Restful_authentication Clearance Twitter_oauth Openid_authentication ActiveLDAP acts_as_ldpa_authenticated Ruby Net-LDAP Rpx_now … Ruby oauth OpenID
    18. Or Authlogic Internal (username/password) LDAP/AD RPX by JanRain Many others.. OAuth Authlogic-oauth Authlogic-ldap Authlogic-oid Authlogic_rpx Authlogic (base) Authlogic plugin X Or use Authlogic “ unobtrusive authentication” No generator crud Smells like ActiveRecord Plugin architecture
    19. Using Authlogic_RPX
    20. RPX Request Model Link to sign-in ..chatter.. ..chatter.. Post:token Verify:token (returns:profile info)
    21. Authlogic_RPX-on-a-page
    22. Enabling Authlogic_RPX
      • See the Authlogic RPX README for full details. It walks you through the steps for enabling Authlogic RPX:
        • Enable RPX for your user model
        • Add RPX configuration for the Authlogic session model
        • Add custom user profile mapping (optional)
        • Add application controller helpers: current_user, current_user_session
        • Setup the Authlogic session controller
        • Setup the Authlogic user controller
        • Use view helpers to provide login links
        • Allow users to "Add RPX" to existing accounts (optional)
      • In this presentation, we’ll touch on some of the main points…
    23. Register your RPX app
      • Register your application at http://rpxnow.com – set it’s name and be assigned an API key, and select/configure the authentication providers:
      Note: max 6 providers with the free RPX account
    24. Configure your project
      • In config/environment.rb –
      • Set the RPX app name and API key:
      • Configure gems:
      • $ rake gems:install
      • Once setup, using Authlogic_RPX is almost identical to standard Authlogic
    25. Two MVCs: session and user
      • Minimal models:
      • Simple helpers you define and control:
        • current_user
        • require_user (e.g. for before_filter)
    26. Controllers – clean and sweet
    27. [:post] create – this is a user “signing in” Session controller All this is optional branching logic, which you can tailor specifically for your application successful save means authentication OK!
    28. [:delete] destroy – this is a user “signing out” Session controller
    29. Access controls: Registration form (optional): Save registration (optional): Edit my profile: Show my profile: Save my profile: User controller Note: sample is a controller that only lets users access their own information, but you can just as easily adapt this so they can list and see the public profile information of other users too.
    30. Auto registration
      • Authlogic_RPX will “register” new users by default.
      • For users this is great: registration is no more difficult than logging in.
        • You can disable this in the session model:
    31. UserSession model – profile mapping
      • When users auto-register, profile data from RPX is available to be inserted in the user's record on your site.
        • Authlogic_rpx will map the username and email fields by default.
      • If you have other fields you want to map, you can provide your own implementation of the map_rpx_data method in the UserSession model
    32. UserSession model – profile mapping
    33. UserSession model – profile mapping
      • WARNING: any fields you map should NOT have constraints enforced at the database level.
        • Authlogic_rpx will optimistically attempt to save the user record during registration, and violating a db constraint will cause the authentication/ registration to fail.
        • You can/should enforce any required validations at the model level. This will allow the auto-registration to proceed, and the user can be given a chance to rectify the validation errors on your user profile page
      • If it is not acceptable in your application to have user records created with potential validation errors in auto-populated fields, you will need to override map_rpx_data and implement whatever special handling makes sense in your case.
    34. RPX – the catch (or: why you might want to buy their pro service) Today I sign-in with Tomorrow I use these aren’t the same identities!
      • Need identity mapping!
        • Only RPX paid options support “identity mapping”
        • Currently not implemented in Authlogic_RPX
      • Note: RPX does try to “remember” the last service you used, but this is not guaranteed
    35. Try it out
      • Live Demonstration Site:
        • rails- authlogic-rpx-sample.heroku.com
      • Demonstration site source repository:
        • github.com/tardate/rails-authlogic-rpx-sample
    36. Take-aways
      • Getting authentication right is critical for your site’s success
        • Lower the barrier-to-entry for consumer/personal users. Eliminate the need to create redundant “identities”!
        • Business sites – make it possible for employees to use business identities “exported” via OpenID (for example), without the need for a specific agreement and integration to be in place
      3
    37. Take-aways
      • Authlogic – leading authentication framework for rails (IMHO)
        • Best even if you just want to do traditional username/password
        • Unobtrusive
        • Makes it easy to switch or add authentication options in future
        • One framework to learn – plugin the most suitable authentication method for each specific project
      2
    38. Take-aways
      • Authlogic_RPX – takes away the pain
        • Support diverse identity providers
        • Standard Authlogic - nothing special to do except plug in your API key
        • Can be used as “RPX only”, or co-exist with standard Authlogic username/password
      • Use it for:
        • Public sites + you just need authentication services + want to give users the best opportunity to use existing credentials.
      1
    39. Thank you!
      • Questions?
      0
    40. Some References
      • Authlogic: http://github.com/binarylogic/authlogic
      • Authlogic_RPX: http://github.com/tardate/authlogic_rpx
      • RPX: http:// rpxnow.com
      • OpenID: http://openid.net
      • OAuth: http://oauth.net
      • Singapore Ruby Brigade (SRB): http://groups.google.com/group/singapore-rb
    SlideShare Zeitgeist 2009

    + Paul GallagherPaul Gallagher Nominate

    custom

    852 views, 0 favs, 2 embeds more stats

    A review of the current state of authentication in more

    More info about this document

    CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

    Go to text version

    • Total Views 852
      • 804 on SlideShare
      • 48 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 11
    Most viewed embeds
    • 44 views on http://tardate.blogspot.com
    • 4 views on http://tardate.com

    more

    All embeds
    • 44 views on http://tardate.blogspot.com
    • 4 views on http://tardate.com

    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