Page MenuHomec4science

README
No OneTemporary

File Metadata

Created
Sun, May 12, 13:26
= TequilaAuthentication plugin
Authenticating users against the EPFL's[http://www.epfl.ch]
Tequila Authentication API (see http://tequila.epfl.ch)
=====================
=== How to mix-in.
This module gets mixed in a Controller when calling 'allow_tequila_login'.
=== Example
class MyTequilaController < ApplicationController
# The Tequila coniguration to be used for this Controller.
TEQUILA_CONFIG =
TequilaConfig.new(:server => 'my_tequila.server.org',
:port => 1234,
:requested_infos => { :service => "My service",
:request => "firstname,name,uniqueid",
:allows => "category=guest" })
#
# Mix-in the TequilaAuthentication plugin code.
allow_tequila_login
#
# Protect some actions.
before_filter :my_protect_actions_filter,
:only => [:protected_action1, :protected_action2]
#
# Some unprotected Rails action
def not_protected_action
# Put the action's code here ...
end
#
# A protected Rails action
def protected_action1
# Put the action's code here ...
end
#
# Another protected Rails action
def protected_action2
# Put the action's code here ...
end
private
#
# Method used to retrieve the Tequila Configuration.
# MUST BE IMPLEMENTED !
def tequila_configuration
TEQUILA_CONFIG
end
# The filter used to protect actions.
def my_protect_actions_filter
# If the user is already logged, skip the filters and go to the action.
return true unless session[:user_id].nil?
# Perform the tequila login
return false unless private_tequila_login
# Gather the user's informations received from the Tequila service.
tequila_user_infos = session[:tequila_user_infos]
# Start a new HTTP Session
reset_session
session[:user_id] = tequila_user_infos[:uniqueid]
# Process the other Tequila informations asked for ...
# Some more code here ...
# Continue processing the other filters/the action.
true
end
end
=== HTML Documentation
It can be generated with:
rake doc:plugins:tequila_authentication
See 'rake -T' for more informations.
=== Testing
Nothing special. You can use from your application's top level
directory (Unix commands):
( cd vendor/plugins/tequila_authentication/ && rake )
or
rake test:plugins PLUGIN=tequila_authentication

Event Timeline