Class: Aws::S3::Plugins::S3Signer Private

Inherits:
Seahorse::Client::Plugin
  • Object
show all
Defined in:
lib/aws-sdk-s3/plugins/s3_signer.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This plugin is an implementation detail and may be modified.

Defined Under Namespace

Classes: BucketRegionErrorHandler, CachedBucketRegionHandler, LegacyHandler, V4Handler

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build_v4_signer(options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :region (required, String)
  • :credentials (required, #credentials)

234
235
236
237
238
239
240
241
242
243
# File 'lib/aws-sdk-s3/plugins/s3_signer.rb', line 234

def build_v4_signer(options = {})
  Aws::Sigv4::Signer.new(
    service: options[:service],
    region: options[:region],
    credentials_provider: options[:credentials],
    signing_algorithm: options.fetch(:signing_algorithm, :sigv4),
    uri_escape_path: false,
    unsigned_headers: ['content-length', 'x-amzn-trace-id']
  )
end

.new_hostname(context, region) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check to see if the bucket is actually an ARN Otherwise it will retry with the ARN as the bucket name.


247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/aws-sdk-s3/plugins/s3_signer.rb', line 247

def new_hostname(context, region)
  uri = URI.parse(
    Aws::Partitions::EndpointProvider.resolve(
      region, 's3', 'regional',
      {
        dualstack: context[:use_dualstack_endpoint],
        fips: context.config.use_fips_endpoint
      }
    )
  )

  if (arn = context.[:s3_arn])
    # Retry with the response region and not the ARN resolved one
    ARN.resolve_url!(
      uri, arn[:arn], region, arn[:fips], arn[:dualstack]
    ).host
  else
    "#{context.params[:bucket]}.#{uri.host}"
  end
end

Instance Method Details

#add_handlers(handlers, cfg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


30
31
32
33
34
35
36
37
38
# File 'lib/aws-sdk-s3/plugins/s3_signer.rb', line 30

def add_handlers(handlers, cfg)
  case cfg.signature_version
  when 'v4' then add_v4_handlers(handlers)
  when 's3' then add_legacy_handler(handlers)
  else
    msg = "unsupported signature version `#{cfg.signature_version}'"
    raise ArgumentError, msg
  end
end

#add_legacy_handler(handlers) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


46
47
48
# File 'lib/aws-sdk-s3/plugins/s3_signer.rb', line 46

def add_legacy_handler(handlers)
  handlers.add(LegacyHandler, step: :sign)
end

#add_v4_handlers(handlers) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


40
41
42
43
44
# File 'lib/aws-sdk-s3/plugins/s3_signer.rb', line 40

def add_v4_handlers(handlers)
  handlers.add(CachedBucketRegionHandler, step: :sign, priority: 60)
  handlers.add(V4Handler, step: :sign)
  handlers.add(BucketRegionErrorHandler, step: :sign, priority: 40)
end