Class: Rack::PactBroker::UIAuthentication

Inherits:
Object
  • Object
show all
Includes:
PactBroker::Api::Resources::Authentication
Defined in:
lib/rack/pact_broker/ui_authentication.rb

Instance Method Summary collapse

Methods included from PactBroker::Api::Resources::Authentication

#authenticated?

Constructor Details

#initialize(app) ⇒ UIAuthentication

Returns a new instance of UIAuthentication.



9
10
11
# File 'lib/rack/pact_broker/ui_authentication.rb', line 9

def initialize app
  @app = app
end

Instance Method Details

#auth?(env) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/rack/pact_broker/ui_authentication.rb', line 21

def auth? env
  authenticated? nil, env["HTTP_AUTHORIZATION"]
end

#call(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/rack/pact_broker/ui_authentication.rb', line 13

def call env
  if auth? env
    @app.call(env)
  else
    [401, {"WWW-Authenticate" => 'Basic realm="Restricted Area"'}, []]
  end
end