Class: Rack::NinjaAuth::Middleware

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/rack/ninja_auth.rb

Constant Summary collapse

SESSION_KEY =
'rack-ninja_auth'
SALT_BYTES =
16

Instance Method Summary collapse

Constructor Details

#initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil, authorized_file: nil) ⇒ Middleware

Returns a new instance of Middleware.



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rack/ninja_auth.rb', line 18

def initialize(app, email_matcher: //, secured_routes: //, not_allowed_file: nil, authorized_file: nil)
  $stderr.puts "Please set NINJA_GOOGLE_CLIENT_ID and NINJA_GOOGLE_CLIENT_SECRET to use NinjaAuth" unless ENV["NINJA_GOOGLE_CLIENT_ID"] && ENV["NINJA_GOOGLE_CLIENT_SECRET"]
  @main_app = app
  @email_matcher = email_matcher
  @secured_route_matcher = secured_routes
  @not_allowed_file = ::File.join(__dir__, '../../views/401.html')
  @not_allowed_file = not_allowed_file if not_allowed_file && ::File.exists?(not_allowed_file)
  @authorized_file = ::File.join(__dir__, '../../views/200.html')
  @authorized_file = authorized_file if authorized_file && ::File.exists?(authorized_file)
  super()
end