Sha256: 17fd288762ce54ffee28377ae943b59747faf919716eb72bc2a28525e585c2c5

Contents?: true

Size: 1.52 KB

Versions: 32

Compression:

Stored size: 1.52 KB

Contents

require 'aws-sigv4'

module Aws
  module CloudSearchDomain
    module Plugins

      # Makes it possible to conditional sign {Aws::CloudSearchDomain::Client}
      # requests. When credentials are configured, requests are signed.
      # When they are omitted, the request is sent anonymously.
      class ConditionalSigning < Seahorse::Client::Plugin

        # The Aws::CloudSearchDomain::Client is configured with a null
        # signer when the credentials are `nil` or simply not set.
        # @api private
        class NullSigner
          def initialize(*args); end
          def sign_request(*args)
            Aws::Sigv4::Signature.new(headers: {})
          end
        end

        # Adding region as an option to avoid an issue when `Aws.config[:region]`
        # is populated and the global configuration plugin merges options onto
        # this client.
        option(:region)

        option(:sigv4_region, doc_type: String, docstring: <<-DOCS) do |cfg|
Only needed when sending authenticated/signed requests to a Cloud
Search domain and the endpoint does not contain the region name.
        DOCS
          # extract the region name from the cloud search domain endpoint
          if cfg.endpoint
            cfg.endpoint.to_s.split('.')[1]
          else
            raise ArgumentError, 'missing required option :endpoint'
          end
        end

        option(:sigv4_signer) do |cfg|
          if cfg.credentials.nil? || !cfg.credentials.set?
            NullSigner.new
          end
        end

      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
aws-sdk-cloudsearchdomain-1.18.1 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.17.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.16.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.15.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.14.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.13.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.12.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.11.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.10.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.9.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.8.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.7.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.6.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.5.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.4.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.3.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.2.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.1.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.0.1 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.0.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb