Take the 2008 Git User's Survey and help out! [ hide ]

public
Fork of technoweenie/restful-authentication
Description: Generates common user authentication code for Rails/Merb, with a full test/unit and rspec suite and optional Acts as State Machine support built-in.
Homepage: http://weblog.techno-weenie.net
Clone URL: git://github.com/b3b0p/restful-authentication.git
Search Repo:
commit  339b0889475b14e2bbf66f2ab1f3fbd57fc2c55b
tree    5dd02e2f59082e18f5974842f3ea6c2c2bac5f04
parent  1f66c5747e79de2dae7c4ea177aa463809aaade8
name age message
folder README Fri Jan 04 15:38:46 -0800 2008 update for rails 2.0: generate routes, use curr... [technoweenie]
folder Rakefile Tue Aug 01 11:32:04 -0700 2006 initial commit of the restful_authentication pl... [technoweenie]
folder generators/ Sun Mar 23 13:19:07 -0700 2008 i want logged_in? to return true/false, not a u... [technoweenie]
folder install.rb Tue Aug 01 11:32:04 -0700 2006 initial commit of the restful_authentication pl... [technoweenie]
folder lib/ Fri Jan 04 15:38:46 -0800 2008 update for rails 2.0: generate routes, use curr... [technoweenie]
README
Restful Authentication Generator
====

This is a basic restful authentication generator for rails, taken 
from acts as authenticated.  Currently it requires Rails 1.2.6 or above.

To use:

  ./script/generate authenticated user sessions \
    --include-activation \
    --stateful

The first parameter specifies the model that gets created in signup
(typically a user or account model).  A model with migration is 
created, as well as a basic controller with the create method.

The second parameter specifies the sessions controller name.  This is
the controller that handles the actual login/logout function on the 
site.

The third parameter (--include-activation) generates the code for a 
ActionMailer and its respective Activation Code through email.

The fourth (--stateful) builds in support for acts_as_state_machine
and generates activation code.  This was taken from:

http://www.vaporbase.com/postings/stateful_authentication

You can pass --skip-migration to skip the user migration.

If you're using acts_as_state_machine, define your users resource like this:

  map.resources :users, :member => { :suspend   => :put,
                                     :unsuspend => :put,
                                     :purge     => :delete }

Also, add an observer to config/environment.rb if you chose the 
--include-activation option

  config.active_record.observers = :user_observer # or whatever you 
                                                  # named your model

Security Alert
====

I introduced a change to the model controller that's been tripping 
folks up on Rails 2.0.  The change was added as a suggestion to help
combat session fixation attacks.  However, this resets the Form 
Authentication token used by Request Forgery Protection.  I've left
it out now, since Rails 1.2.6 and Rails 2.0 will both stop session
fixation attacks anyway.