Sha256: f42ae6b0e6b15b9d951840d9aba1ecffe364d076714f16d58e34f6e992de6931

Contents?: true

Size: 1.55 KB

Versions: 38

Compression:

Stored size: 1.55 KB

Contents

# frozen_string_literal: true

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

38 entries across 38 versions & 1 rubygems

Version Path
aws-sdk-cloudsearchdomain-1.56.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.55.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.54.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.53.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.52.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.51.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.50.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.49.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.48.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.47.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.46.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.45.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.44.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.43.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.41.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.40.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.39.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.38.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.37.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb
aws-sdk-cloudsearchdomain-1.36.0 lib/aws-sdk-cloudsearchdomain/plugins/conditional_signing.rb