Class: Merb::Authentication

Class | Merb::Authentication
In: | lib/merb-auth-core/authentication.rb lib/merb-auth-core/callbacks.rb lib/merb-auth-core/customizations.rb lib/merb-auth-core/errors.rb lib/merb-auth-core/responses.rb lib/merb-auth-core/strategy.rb
Parent: | Object

These are not intended to be used directly

### Methods

abandon! activate! after_authentication authenticate! authenticated? customize_default default_customizations default_strategy_order= error_message errors fetch_user halt! halted? headers headers= lookup_strategy maintain_session_keys new redirected? register reset_strategy_lookup! status status= store_user user user=

### Included Modules

Extlib::Hook

### Classes and Modules

Module Merb::Authentication::Strategies
Class Merb::Authentication::DuplicateStrategy
Class Merb::Authentication::Errors
Class Merb::Authentication::MissingStrategy
Class Merb::Authentication::NotImplemented
Class Merb::Authentication::Strategy

### Attributes

body | [RW] |
error_message | [W] |
session | [RW] |

### Public Class methods

activate!(label)

Activates a registered strategy by it‘s label. Intended for use with plugin authors. There is little need to register your own strategies. Just declare them and they will be active.

after_authentication(*callbacks, &block)

Use the after_authentication callbacks to setup things that should occur after the user is authenticated.

Pass in symbols, procs and or a block to the method to setup the callbacks. Callbacks are executed in the order they are added.

@params <*callbacks:[Symbol|Proc]> The callback.. Symbol == method on the user object

                                              Proc will be passed the user, request and param objects

<&block> A block to check. The user, request and params will be passed into the block

To confirm that the user is still eligable to login, simply return the user from the method or block. To stop the user from being authenticated return false or nil

#### Example

       Merb::Authentication.after_authentication do |user,request,params|
          user.active? ? user : nil
       end

@api public

customize_default(&block)

Adds any customizations just before the after_app_loads boot loader so that plugins can offer default customization. This will still allow for a user to overwrite any customizations if required in the after_app_loads block @plugin

default_customizations()

Gets the list of declared customizations

default_strategy_order=(*order)

Use this to set the default order of strategies if you need to in your application. You don‘t need to use all avaiable strategies in this array, but you may not include a strategy that has not yet been defined.

@params [Merb::Authentiation::Strategy,Merb::Authentication::Strategy]

@public

lookup_strategy()

Keeps track of strategies by class or string When loading from string, strategies are loaded withing the Merb::Authentication::Strategies namespace When loaded by class, the class is stored directly @private

maintain_session_keys()

Maintains a list of keys to maintain when needing to keep some state in the face of session.abandon! You need to maintain this state yourself @public

new(session)
register(label, path)

Allows for the registration of strategies. @params <Symbol, String>

      +label+ The label is the label to identify this strategy
      +path+  The path to the file containing the strategy.  This must be an absolute path!

Registering a strategy does not add it to the list of strategies to use it simply makes it available through the Merb::Authentication.activate method

This is for plugin writers to make a strategy availalbe but this should not stop you from declaring your own strategies

@plugin

reset_strategy_lookup!()

Restets the strategy lookup. Useful in specs

### Public Instance methods

abandon!()

"Logs Out" a user from the session. Also clears out all session data

authenticate!(request, params, *rest)

The workhorse of the framework. The authentiate! method is where the work is done. authenticate! will try each strategy in order either passed in, or in the default_strategy_order.

If a strategy returns some kind of user object, this will be stored in the session, otherwise a Merb::Controller::Unauthenticated exception is raised

@params Merb::Request, [List,Of,Strategies, optional_options_hash]

Pass in a list of strategy objects to have this list take precedence over the normal defaults

Use an options hash to provide an error message to be passed into the exception.

@return user object of the verified user. An exception is raised if no user is found

authenticated?()

Returns true if there is an authenticated user attached to this session

@return <TrueClass|FalseClass>

error_message()

A simple error message mechanism to provide general information. For more specific information

This message is the default message passed to the Merb::Controller::Unauthenticated exception during authentication.

This is a very simple mechanism for error messages. For more detailed control see Authenticaiton#errors

@api overwritable

errors()
fetch_user(session_contents = session[:user])

Tells the framework how to reconstitute a user from the data stored by store_user.

You must overwrite this method for user in your projects. Slices and plugins may set this.

@api overwritable

halt!()
halted?()
headers()
headers=(headers)
redirected?()
status()
status=(sts)
store_user(user)

Tells the framework how to store your user object into the session so that it can be re-created on the next login. You must overwrite this method for use in your projects. Slices and plugins may set this.

@api overwritable

user()

This method will retrieve the user object stored in the session or nil if there is no user logged in.

@return <User class>|NilClass

user=(user)

This method will store the user provided into the session and set the user as the currently logged in user @return <User Class>|NilClass

[Validate]