Sha256: e21d5cd7c750e0e792d208a6d153bb30311f87a3156b9cf4e16cfbc53eac2b82

Contents?: true

Size: 1.2 KB

Versions: 104

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Aws
  module Plugins
    # @api private
    class SignatureV2 < Seahorse::Client::Plugin

      option(:v2_signer) do |cfg|
        Aws::Sigv2::Signer.new(credentials_provider: cfg.credentials)
      end

      def add_handlers(handlers, _)
        handlers.add(Handler, step: :sign)
      end

      class Handler < Seahorse::Client::Handler

        def call(context)
          apply_signature(
            context.http_request,
            context.config.v2_signer
          )
          @handler.call(context)
        end

        private

        def apply_signature(req, signer)

          param_list = req.body.param_list
          param_list.delete('Timestamp') # in case of re-signing

          signature = signer.sign_request(
            http_method: req.http_method,
            url: req.endpoint,
            params: param_list.inject({}) do |hash, param|
              hash[param.name] = param.value
              hash
            end
          )

          # apply signature
          signature.each_pair do |param_name, param_value|
            param_list.set(param_name, param_value)
          end

          req.body = param_list.to_io

        end
      end
    end
  end
end

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
aws-sdk-core-3.145.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.144.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.143.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.142.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.141.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.140.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.139.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.138.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.137.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.136.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.135.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.134.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.133.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.132.0 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.131.6 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.131.5 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.131.4 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.131.3 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.131.2 lib/aws-sdk-core/plugins/signature_v2.rb
aws-sdk-core-3.131.1 lib/aws-sdk-core/plugins/signature_v2.rb