Class: ZerigoDNS::Middleware::ZerigoAuth

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/zerigodns/middleware/zerigo_auth.rb

Overview

Handles authentication using the Zerigo config.

Instance Method Summary collapse

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, options={}
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

Adds username & api key to Basic Auth header.

Parameters:

  • env (Faraday::Request)

    The request



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().gsub("\n", '')
  env.request_headers['Authorization'] = "Basic #{auth_enc}"
  @app.call(env)
end