Ruby on Rails
Crypted Authentication Plugin

This article is part of the confusing world of Authentication in Rails. Feel free to get lost in a gazillion of nearly useless and/or outdated Wikipages.

A simple but effective encrypted password plugin for Rails. It deals with the encryption of a clear-text password using a randomly generated salt, and authentication.

It does not try to do too much – it makes no major assumptions about your domain and only requires a small change to your schema to implement.

It is extracted from code used on several projects and contains a full BDD-style test suite.

Using the plugin

Install the plugin in the usual manner from the repository.

Generate a migration to add a username, salt and encrypted_password column to the table you want to add authentication to (for example the users table). Then add the following statement to your model:


class User < ActiveRecord::Base
  make_authenticatable
end

In order for this plugin to work, you need to add the following code to the view that you wish to make authenticatable:


<p><label for="user_password">Password</label><br/>
<%= password_field 'user', 'password'  %></p>

For more information, please check out the full README at the Agile Evolved open source trac.