Sha256: 3fa45336a5f475b809b82ac1c63033808fcfab0bd11d01f09cc16ad2c793ea9a

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

module DvelpApiAuth
  module Tests
    module Helpers
      def authorize!(fullpath, request_params = {})
        set_authorisation_header(fullpath, request_params)
        set_timestamp
      end

      private

      def set_authorisation_header(fullpath, request_params)
        if request_params.present? && request_params.is_a?(Hash)
          raw_post = request_params.to_query
        end

        http_auth = DvelpApiAuth::Authentication::Signature.new(
          fullpath,
          raw_post,
          Time.current
        ).generate

        request.env['HTTP_AUTHORISATION'] = http_auth
      end

      def set_timestamp
        request.env['HTTP_TIMESTAMP'] = Time.current
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dvelp_api_auth-0.1.0 lib/dvelp_api_auth/tests/helpers.rb