Class: SoarAuthentication::Authenticate

Inherits:
Object
  • Object
show all
Defined in:
lib/soar_authentication.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Authenticate

Returns a new instance of Authenticate.



8
9
10
# File 'lib/soar_authentication.rb', line 8

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



6
7
8
# File 'lib/soar_authentication.rb', line 6

def app
  @app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/soar_authentication.rb', line 12

def call(env)
  request = Rack::Request.new(env)
  auth = SoarAuthentication::Authentication.new(request)
  return [401, {"Content-Type" => "text/html"}, ["401 - Not authenticated"]] if not auth.authenticated?

  @app.call(env)
end