Class: Sentiero::Web::BasicAuth
- Inherits:
-
Object
- Object
- Sentiero::Web::BasicAuth
- Defined in:
- lib/sentiero/web/basic_auth.rb
Overview
Optional HTTP Basic auth middleware for standalone dashboards. Passes through when basic_auth is unset; blank configured credentials lock everyone out (401). Assumes TLS upstream.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ BasicAuth
constructor
A new instance of BasicAuth.
Constructor Details
#initialize(app) ⇒ BasicAuth
Returns a new instance of BasicAuth.
12 13 14 |
# File 'lib/sentiero/web/basic_auth.rb', line 12 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/sentiero/web/basic_auth.rb', line 16 def call(env) creds = Sentiero.configuration.basic_auth return @app.call(env) if creds.nil? return @app.call(env) if BasicAuthCheck.(env, creds) [401, {"content-type" => "text/plain", "www-authenticate" => 'Basic realm="Sentiero"'}, ["Unauthorized"]] end |