Jeremy Durham

Ruby, Rails, and everything in between.

  • BlogThoughts
  • AboutAbout the Author
  • ContactGet in touch

October 21, 2009 23:54
Posted by Jeremy Durham

Restful-authentication + Machinist quick how-to

RESTful authentication has fallen out of favor as the authentication system of choice while building new projects, but I still find it simple enough to hack on and easy to implement in a new project. RESTful authentication coupled with Declarative Authorization gives you a nice full solution to authentication and authorization in most cases.

Although RESTful authentication is easy to set up and use, it’s use of fixtures and extensive custom cucumber steps that collide with built-in webrat steps have caused me to continuously rewrite my specs and features when setting up new projects. I finally got irritated enough by the whole situation today that I decided to fork RESTful auth, completely swap out fixtures, and rewrite all the cucumber features. No more static data: no more quentin, aaron, etc. Just User.make to generate random users and away we go.

Hopefully, you find my fork useful. Here’s a really quick “Getting Started” to show how simple you can get up and going:

  • rails app_name
  • git submodule add git://github.com/jeremydurham/restful-authentication.git vendor/plugins/restful_authentication
  • script/generate rspec
  • script/generate cucumber
  • generate some code and setup a root path (map.root)
  • Make sure you include flash[:error] and render :partial => ‘users/user_bar’ in your application layout, or tweak the features and specs as necessary
  • script/generate authenticated user —rspec
  • Add the appropriate paths to features/support/paths.rb (they are printed to STDOUT when generating RESTful auth)
  • rake db:migrate
  • move “include AuthenticatedSystem” to application_controller

At this point, running “rake spec” or “rake features” should both pass, and running the application should allow you to log in, log out, and sign up. Hopefully, this process took you no more than a few minutes, and you’re up and running!

If you’re looking for excellent authorization (roles, rules, etc) then make sure you take a look at declarative authorization.

No Comments

Posted Under Programming

  • Posts
  • Twitter
  • Flickr
 

DNS-321 + OpenVPN...

Technology

 

There is no Holy ...

Technology

 

Google and Apple:...

Technology

Am I the only one who thinks that the Ruby Motion video only outputs on the left channel? #annoying

follow me on
twitter

125942640_a3dcc3f951_s125942637_c4524c7c88_s125942628_a682f8a639_s122144184_5f2dd86929_s122144182_1b01ded312_s122144181_893a82f1d3_s122144179_70465b00ff_s122102402_21e6174af6_s122102401_f6d9ebff55_s

Categories

  • Technology
  • Programming
  • Family
  • Travel

This site is using the Handgloves WordPress Theme
Designed & Developed by George Wiscombe

Subscribe via RSS