Clearance: Simple, complete Ruby web app authentication.

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.

2 comments

Comments 1 - 2 of 2 previous next Post a comment

  • + jmorrison Jason Morrison 9 months ago
    That’s correct, it is now Rails-specific, though we originally had plans of framework-agnosticism.
  • + guestb74f91 guestb74f91 9 months ago
    Title says 'Ruby web app authentication' (found on Google search for non-Rails auth solutions) but this appears to be Rails-specific.
Post a comment
Embed Video
Edit your comment Cancel

5 Favorites

Clearance: Simple, complete Ruby web app authentication. - Presentation Transcript

  1. Clearance Jason Morrison jmorrison@thoughtbot.com
  2. $ sudo gem install \\ thoughtbot- Clearance \\ --source http://gems.github.com $ curl “http://github.com/thoughtbot/ \\ clearance/tree/master%2FREADME.textile? \\ raw=true”
  3. Thank you.
  4. Encore!
  5. “Who goes there?”
  6. email + confirmation + password + forgot = authentication. No authorization, no roles, no ACLs, no HTTP basic auth, no OpenID (in core), no admin (in core), no, no, no!
  7. Keep It Simple, Sucka.
  8. mess ^ Generator free!
  9. (but it’s small) # models and controllers [~/dev/clearance/lib/clearance/app] find . | xargs wc -l 434 total # units and functionals [~/dev/clearance/lib/clearance/test] find . | xargs wc -l 822 total
  10. Let’s see it!
  11. http://github.com/thoughtbot/clearance
  12. Have it your way class User < ActiveRecord::Base include Clearance::Model def encrypt(password) Digest::SHA1.hexdigest \"--#{salt}--#{password}--\" end protected def initialize_salt self.salt = Digest::SHA1.hexdigest( \"--#{Time.now.to_s}--#{email}--\") if new_record? end end
  13. Have it your way # similar deal for UsersController, ConfirmationsController class SessionsController < ApplicationController include Clearance::SessionsController def url_after_create video_url(:awesome_and_exciting_welcome) end def url_after_destroy video_url(:wistful_farewell) end end
  14. Get goin’ class User < ActiveRecord::Base include Clearance::Model acts_as_geocodable :normalize_address => true # don’t forget this guy! attr_accessible :first_name, :last_name, :street, :locality, :region, :postal_code, :website, :about end
  15. Get goin’ class UsersController < ApplicationController include Clearance::UsersController before_filter :authenticate, :except => [:new, :create] before_filter :can_only_edit_self, :only => [:edit, :update] protected def can_only_edit_self unless current_user == User.find(params[:id]) flash[:error] = 'Oh, snap! Get outta here.' redirect_to root_url end end end
  16. Future Work
  17. TODO.textile • Some refactoring & documentation to do
  18. Loot from merb-auth • Store current_user on the session, not controller • HTTP fluency • 401 Unauthorized • 405 Resource not allowed • Make a strategy: • Email confirmation • Forgot password • Salted passwords
  19. clearance-admin <% if current_user.admin? -%> Admin::UsersController logged_in_admin_context {} should_only_allow_admins_on ‘get :index’
  20. clearance-openid Extract from http://hoptoadapp.com
  21. Always be on the lookout for Clearance http://www.youtube.com/watch?v=sEaqfpqLBK4
  22. Guard Dog http://headrush.typepad.com/creating_passionate_users /2007/03/seven_blog_virt.html Kiss http://flickr.com/photos/andraspfaff/623258079/ Awesome Delorean http://flickr.com/photos/f1rstborn/757609629/ “Shh!” http://flickr.com/photos/cupcake_eater/2721122278/ Personals Ad http://flickr.com/photos/eggplant/3211654/ Baseball Photosiñata http://flickr.com/photos/mcbeth/156411746/
  23. $ tail -n 8 README.textile h2. Authors * thoughtbot, inc. * Dan Croak * Jason Morrison * Mike Burns * Josh Nichols * Mike Breen
  24. github.com /thoughtbot /clearance github.com /jasonm /talks

+ Jason MorrisonJason Morrison, 2 years ago

custom

4111 views, 5 favs, 0 embeds more stats

Simple, complete Ruby web app authentication at htt more

More info about this document

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Go to text version

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