latimes / simple_admin
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
6f11b65
README
SimpleLogin
===========
Simple plugin to do administration logins through usernames and passwords saved in YAML.
Example
=======
Add this to your application controller and it will ask for Basic HTTP authentication on everything:
include SimpleAdmin
before_filter :check_basic_http_credentials
Like all filters you can add conditions:
before_filter :check_basic_http_credentials, :only => :login
When including SimpleAdmin in your controller you also get access to the authenticate(username, password) method which
can be used for custom login pages:
def login
if authenticate(params[:username], params[:password])
session[:admin] = true
redirect_to main_page
end
end
The plugin stores users in a YAML file. To add a user to the file run the admin:add_user rake task. You'll have to
provide the username and password parameters:
rake admin:add_user username=mrwalrus password=mahbukkit
Rake will append the user to the login.yaml file or create a new one. The default location for this file is
config/admin/login.yml but can be overridden by setting the LOGIN_FILE environment variable.
Say you want to use a different set of logins in production then in development? Add this to your
environments/production.rb file (changing the path to your desired location):
ENV["LOGIN_FILE"] = "#{RAILS_ROOT}/config/admin/production/login.yml"
Copyright (c) 2008 Los Angeles Times, released under the MIT license

