advertisement

Clearance: Simple, complete Ruby web app authentication.

50 %
50 %
advertisement
Information about Clearance: Simple, complete Ruby web app authentication.

Published on October 15, 2008

Author: jmorrison

Source: slideshare.net

Description

Simple, complete Ruby web app authentication at http://github.com/thoughtbot/clearance/tree/master
advertisement

Clearance Jason Morrison jmorrison@thoughtbot.com

$ sudo gem install thoughtbot- Clearance --source http://gems.github.com $ curl “http://github.com/thoughtbot/ clearance/tree/master%2FREADME.textile? raw=true”

Thank you.

Encore!

“Who goes there?”

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!

Keep It Simple, Sucka.

mess ^ Generator free!

(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

Let’s see it!

http://github.com/thoughtbot/clearance

Have it your way class User < ActiveRecord::Base include Clearance::Model def encrypt(password) Digest::SHA1.hexdigest quot;--#{salt}--#{password}--quot; end protected def initialize_salt self.salt = Digest::SHA1.hexdigest( quot;--#{Time.now.to_s}--#{email}--quot;) if new_record? end end

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

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

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

Future Work

TODO.textile • Some refactoring & documentation to do

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

clearance-admin <% if current_user.admin? -%> Admin::UsersController logged_in_admin_context {} should_only_allow_admins_on ‘get :index’

clearance-openid Extract from http://hoptoadapp.com

Always be on the lookout for Clearance http://www.youtube.com/watch?v=sEaqfpqLBK4

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/

$ tail -n 8 README.textile h2. Authors * thoughtbot, inc. * Dan Croak * Jason Morrison * Mike Burns * Josh Nichols * Mike Breen

github.com /thoughtbot /clearance github.com /jasonm /talks

Add a comment

Related pages

User Management for Web & Mobile Apps with UserApp

User management within minutes. UserApp provides you with user management functionality that results in faster development, faster revenue, more users, and ...
Read more

Ruby on Rails and RubyMotion Authentication Part One ...

Ruby on Rails and RubyMotion Authentication ... I walked you through the developing of a complete Android app backed by a web ... In this simple app ...
Read more

Ruby Developer Center | Microsoft Azure

Welcome to the Ruby Developer Center. Learn how to run Ruby ... Web apps Learn how you ... your data and apps with an extra level of authentication;
Read more

Build a Simple Ruby on Rails Application Course

Build a Simple Ruby on Rails Application ... Ruby on Rails is a web application framework which makes it easy and quick to build dynamic web sites.
Read more

Basics of Authentication | GitHub Developer Guide

Basics of Authentication. Registering your app; ... the complete source code for this ... the same port we used when we had a simple Sinatra app.
Read more

simplabs/ember-simple-auth: A lightweight library for ...

README.md Ember Simple Auth API docs. Ember Simple Auth supports all Ember.js versions starting with 1.12. Ember Simple Auth. Ember Simple Auth is a ...
Read more

Code samples for SharePoint 2013

Find and download code samples for SharePoint 2013, ... Ruby (coming soon) Getting ... Display remote app content in the host web using an app ...
Read more

Learn | Codecademy

Learn Ruby on Rails Learn to build web apps with Ruby ... Ruby on Rails: Authentication Learn how to ... Learn Git Create and explore a simple Git ...
Read more

Configure forms-based authentication for a claims-based ...

Configure forms-based authentication for a ... based authentication for a SharePoint 2013 web ... FBA Web App " -ApplicationPool ...
Read more