OnlyForMe
Added by kuba97531
at October 28, 2009 22:01
GitHub stats:
watcher(s)
fork(s)
About
Simple authentication for applications that don’t need users/roles etc.
Details
Only For Me is simple middleware to keep application only for you. It provides simple authentication for applications that don’t need users/roles etc.
Use it when
– you want to host your application in public domain
– you don’t want anyone other than you access your application
– you don’t want to bother with authentication plugins
When someone opens your application he is shown a simple form, when he must enter some secret phrase.
Usage
All parameters except :template_path are optional, but it is good to provide at least access password.
require 'only_for_me'
config.middleware.use OnlyForMe, :template_path => "#{RAILS_ROOT}/app/views/only-for-me.html.erb"
# template is the file that will be shown to unauthenticated users.
# (if parameter is missing default view is provided)
# the view must provide a form with one field. Name field
# must be the same as parameter :param_name, and is accessible inside of template as "param_name"
# also the path requested by user is available as "current_action"
This example shows and explains all parameters
require 'only_for_me'
config.middleware.use OnlyForMe,
:secret_phrases => ['password'],
# list of all passwords that we accept. User can use any of these
:param_name => 'secret_phrase',
# name of the parameter used in the authentication form
:cookie_name => 'only.for.me',
# name of the cookie in wich we store authentication key
:expires => 1.hour,
# how long should session last?
:template_path => "#{RAILS_ROOT}/app/views/layouts/only_for_me.html.erb"
