Class: Rack::PactBroker::UIAuthentication
- Inherits:
-
Object
- Object
- Rack::PactBroker::UIAuthentication
- Defined in:
- lib/rack/pact_broker/ui_authentication.rb
Instance Method Summary collapse
- #auth?(env) ⇒ Boolean
- #call(env) ⇒ Object
-
#initialize(app) ⇒ UIAuthentication
constructor
A new instance of UIAuthentication.
Methods included from PactBroker::Api::Resources::Authentication
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
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 |