Class: Restfully::Rack::BasicAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/restfully/rack/basic_auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, username, password) ⇒ BasicAuth

Returns a new instance of BasicAuth.



6
7
8
9
10
# File 'lib/restfully/rack/basic_auth.rb', line 6

def initialize(app, username, password)
  @app = app
  @username = username
  @password = password
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/restfully/rack/basic_auth.rb', line 12

def call(env)
  env['HTTP_AUTHORIZATION'] = [
    "Basic",
    Base64.encode64([
      @username,
      @password
    ].join(":"))
  ].join(" ")
  
  @app.call(env)
end