Class: Balrog::RoutesMiddleware
- Inherits:
-
Object
- Object
- Balrog::RoutesMiddleware
- Includes:
- Guard
- Defined in:
- lib/balrog/routes_middleware.rb
Overview
Public: Balrog routes middleware that redirects the user to a security gate unless the session includes { ‘balrog’ => ‘authenticated’ }.
In order to protect SideKiq Web you would do something like this:
require ‘sidekiq/web’
Sidekiq::Web.disable(:sessions) Sidekiq::Web.use Balrog::RoutesMiddleware
mount Sidekiq::Web => ‘/sidekiq’
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RoutesMiddleware
constructor
A new instance of RoutesMiddleware.
Methods included from Guard
Constructor Details
#initialize(app) ⇒ RoutesMiddleware
Returns a new instance of RoutesMiddleware.
18 19 20 |
# File 'lib/balrog/routes_middleware.rb', line 18 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/balrog/routes_middleware.rb', line 22 def call(env) unless authenticated?(env['rack.session']['balrog']) html = ApplicationController.renderer.render 'balrog/gate', layout: 'balrog' return [200, {"Content-Type" => "text/html"}, [html]] end @app.call(env) end |