You are here: Browse Railsplugins Restful Authentication
Several features were updated in May, 2008. The newest version of this plugin may be found in http://github.com/technoweenie/restful-authentication/tree/master While a “classic” (backward-compatible) version may be found in http://github.com/technoweenie/restful-authentication/tree/classic
!! important: if you upgrade your site, existing user account !!
!! passwords will stop working unless you use --old-passwords !!
This page has notes on
See the wiki (or the notes/ directory) if you want to learn more about:
These best version of the release notes are in the notes/ directory in the source code —look there for the latest version. The wiki versions are taken (manually) from there.
There are now RSpec stories that allow expressive, enjoyable tests for the authentication code. The flexible code for resource testing in stories was extended from Ben Mabey’s.
Here are a few changes in the May 2008 release that increase “Defense in Depth” but may require changes to existing accounts
The new password encryption (using a site key salt and stretching) will break existing user accounts’ passwords. We recommend you use the—old-passwords option or write a migration tool and submit it as a patch. See the note for more information.
By default,
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 \
--rspec \
--skip-migration \
--skip-routes \
--old-passwords
--stateful implies --include-activation). Based on the
idea at [[http://www.vaporbase.com/postings/stateful_authentication]]. Passing
--skip-migration will skip the user migration, and --skip-routes will skip
resource generation—both useful if you’ve already run this generator.config/routes.rbThe below assumes a Model named ‘User’ and a Controller named ‘Session’; please
alter to suit. There are additional security minutae in notes/README-Tradeoffs
—only the paranoid or the curious need bother, though.
config/routes.rb if you like:
map.signup ’/signup’, :controller => ‘users’, :action => ‘new’ @ map.signin ’/login’, :controller => ‘session’, :action => ‘new’ @ map.signout ’/logout’, :controller => ‘session’, :action => ‘destroy’ @
--include-activation, also add to your config/routes.rb: map.activate ’/activate/:activation_code’, :controller => ‘users’, :action => ‘activate’, :activation_code => nil)
and add an observer to config/environment.rb:
config.active_record.observers = :users_observer--stateful, add an observer to config/environment.rb: config.active_record.observers = :user_observer
and modify the users resource line to read
map.resources :users, :member => { :suspend => :put,
:unsuspend => :put,
:purge => :delete }NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly