Class: ZerigoDNS::Middleware::ZerigoAuth
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- ZerigoDNS::Middleware::ZerigoAuth
- Defined in:
- lib/zerigodns/middleware/zerigo_auth.rb
Overview
Handles authentication using the Zerigo config.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Adds username & api key to Basic Auth header.
-
#initialize(app = nil, options = {}) ⇒ ZerigoAuth
constructor
Constructs new middleware instance.
Constructor Details
#initialize(app = nil, options = {}) ⇒ ZerigoAuth
Constructs new middleware instance
4 5 6 |
# File 'lib/zerigodns/middleware/zerigo_auth.rb', line 4 def initialize app=nil, ={} @app = app end |
Instance Method Details
#call(env) ⇒ Object
Adds username & api key to Basic Auth header.
10 11 12 13 14 15 |
# File 'lib/zerigodns/middleware/zerigo_auth.rb', line 10 def call env # => Ruby 1.8.7 does not support Base64.strict_encode64 auth_enc = Base64.encode64(formatted_login).gsub("\n", '') env.request_headers['Authorization'] = "Basic #{auth_enc}" @app.call(env) end |