Class: Vertebrae::Request::BasicAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Vertebrae::Request::BasicAuth
- Defined in:
- lib/request/basic_auth.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, *args) ⇒ BasicAuth
constructor
A new instance of BasicAuth.
Constructor Details
#initialize(app, *args) ⇒ BasicAuth
Returns a new instance of BasicAuth.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/request/basic_auth.rb', line 12 def initialize(app, *args) @app = app credentials = "" = args. if .has_key? :username credentials = "#{options[:username]}:#{options[:password]}" elsif .has_key? :basic_auth credentials = "#{options[:basic_auth]}" end @auth = Base64.encode64(credentials) @auth.gsub!("\n", "") end |
Instance Method Details
#call(env) ⇒ Object
6 7 8 9 10 |
# File 'lib/request/basic_auth.rb', line 6 def call(env) env[:request_headers].merge!('Authorization' => "Basic #{@auth}\"") @app.call env end |