Sha256: 0ac0c642b417e04f3a2189b02a15e948f9b3163aa4f32f11c103a6a77a45e1d1

Contents?: true

Size: 607 Bytes

Versions: 1

Compression:

Stored size: 607 Bytes

Contents

require 'digest/md5'

module Oahu
  module Request
    class Auth  < Faraday::Middleware

      def call(env)
        sig_time   = Time.now.to_i
        signature  = Digest::MD5.hexdigest [sig_time, @credentials[:client_id], @credentials[:consumer_secret]].join("-")
        env[:request_headers]['Oahu-Consumer-Id']   = @credentials[:consumer_id]
        env[:request_headers]['Oahu-Consumer-Sig']  = [sig_time, @credentials[:client_id], signature].join("|")
        @app.call(env)
      end

      def initialize(app, credentials)
        @app, @credentials = app, credentials
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oahu-0.0.1 lib/oahu/request/auth.rb