A Rails plugin the provides basic functionality for session based authentication
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app/views/users
generators/configurable_authentication
lib
tasks
test
MIT-LICENSE
README
Rakefile
init.rb
install.rb
uninstall.rb

README

ConfigurableAuthentication
==========================

This Ruby on Rails plugin provides default behaviour for authentication.
Only the minimum of code is generated (e.g. migrations).

Three classes are defined:
- Authenticator: the controller that handles logon,
- Authentication: the model that represents users,
- Authenticated: controllers that have actions which require authentication.

Installation
============
Download:
  $ ./script/plugin install git://github.com/maxmilesrl/configurable_authentication.git

This plugin includes a migration generator to add necessary fields to your user table.
For instructions, type:
  $ script/generate configurable_authentication

Example
=======
In 'app/controllers/users_controller.rb' (Authenticator)
  class UsersController < ApplicationController
    acts_as_authenticator do |config|
      config.authentication_class = ::User # this is required
      config.post_login_redirect = {:controller => '/home', :action => 'index'} # default redirect to use after login
      config.post_logout_redirect = {:controller => '/home', :action => 'index'}
    end
  end

In 'app/models/user.rb' (Authentication)
  class User < ActiveRecord::Base
    acts_as_authentication do |config|
    end
  end

In 'app/controllers/posts_controller.rb' (Authenticated)
  acts_as_authenticated do |config|
    config.login_redirect = {:controller => '/users', :action => 'login'} # the URL of the authenticator
  end

  before_filter :login_required, :except => :index

Configuration
=============
Each class has a configuration class:
- ConfigurableAuthentication::Authenticator::Configuration
- ConfigurableAuthentication::Authentication::Configuration
- ConfigurableAuthentication::Authenticated::Configuration

The classes hold configuration as class variables.

In order to get the values, inpect the class:
 $ script/console
 >> ConfigurableAuthentication::Authenticator::Configuration
 => #<ConfigurableAuthentication::Authenticator::Configuration @@after_login=nil, @@post_logout_redirect=nil,
 @@after_logout=nil, @@authentication_class=nil, @@post_login_redirect=nil, @@login_failure_message="login failed",
 @@login_success_message="login successful">

Copyright (c) 2009 Max Mile srl, released under the MIT license