Module: Shared::HmacSignature

Included in:
PushyDaemon::Proxy
Defined in:
lib/shared/hmac_signature.rb

Instance Method Summary collapse

Instance Method Details

#headers_md5(request) ⇒ Object



20
21
22
# File 'lib/shared/hmac_signature.rb', line 20

def headers_md5 request
  request.headers['Content-MD5'] = Digest::MD5.hexdigest(request.payload.to_s)
end

#headers_sign(request, hmac_method, hmac_user, hmac_secret, names = ['date']) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/shared/hmac_signature.rb', line 7

def headers_sign request, hmac_method, hmac_user, hmac_secret, names = ['date']
  return unless hmac_user
  unless hmac_secret && hmac_method
    log_error "headers_sign: hmac: missing secret or method"
    return
  end

  # OK, lets go
  log_info "headers_sign: before: user[#{hmac_user}] secret[#{hmac_secret}] method[#{hmac_method}]", request.headers
  hmac_sign_kong request.headers, hmac_user, hmac_secret, names
  log_info "headers_sign: after:", request.headers
end