Class: Weary::Middleware::BasicAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/weary/middleware/basic_auth.rb

Constant Summary

AUTH_HEADER =
"HTTP_AUTHORIZATION"

Instance Method Summary collapse

Constructor Details

#initialize(app, *credentials) ⇒ BasicAuth

Returns a new instance of BasicAuth



6
7
8
9
# File 'lib/weary/middleware/basic_auth.rb', line 6

def initialize(app, *credentials)
  @app = app
  @auth = [credentials.join(':')].pack('m*')
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
# File 'lib/weary/middleware/basic_auth.rb', line 11

def call(env)
  env.update AUTH_HEADER => "Basic #{@auth}"
  @app.call(env)
end