Module: Aker::Rack

Defined in:
lib/aker/rack.rb,
lib/aker/rack/setup.rb,
lib/aker/rack/logout.rb,
lib/aker/rack/facade.rb,
lib/aker/rack/failure.rb,
lib/aker/rack/request_ext.rb,
lib/aker/rack/authenticate.rb,
lib/aker/rack/session_timer.rb,
lib/aker/rack/environment_helper.rb,
lib/aker/rack/configuration_helper.rb,
lib/aker/rack/default_logout_responder.rb

Overview

Integration of Aker with Rack.

Defined Under Namespace

Modules: ConfigurationHelper, EnvironmentHelper, RequestExt Classes: Authenticate, DefaultLogoutResponder, Facade, Failure, Logout, SessionTimer, Setup

Class Method Summary (collapse)

Class Method Details

+ use_in(builder, configuration = nil)

This method returns an undefined value.

Configures all the necessary middleware for Aker into the given rack application stack. With Rack::Builder:

 Rack::Builder.new do
   Aker::Rack.use_in(self) # self is the builder instance
 end

Aker's middleware stack relies on the existence of a session, so the session-enabling middleware must be higher in the application stack than Aker.

Parameters:

  • builder (#use)

    the target application builder. This could be a Rack::Builder object or something that acts like one.

  • configuration (Aker::Configuration, nil) (defaults to: nil)

    the configuration to apply to this use. If nil, uses the global configuration (Aker.configuration).



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/aker/rack.rb', line 38

def use_in(builder, configuration=nil)
  effective_configuration = configuration || Aker.configuration
  unless effective_configuration
    fail "No configuration was provided and there's no global configuration.  " <<
      "Please set one or the other before calling use_in."
  end

  install_modes(effective_configuration)

  builder.use Setup, effective_configuration

  with_mode_middlewares(builder, effective_configuration) do
    effective_configuration.install_middleware(:before_authentication, builder)
    builder.use Warden::Manager do |manager|
      manager.failure_app = Aker::Rack::Failure.new
    end
    builder.use Authenticate
    effective_configuration.install_middleware(:after_authentication, builder)
    builder.use Logout, '/logout'
    builder.use SessionTimer
  end

  builder.use DefaultLogoutResponder, '/logout'
end