class Aws::S3::Plugins::S3Signer::V4Handler

Public Instance Methods

call(context) click to toggle source
# File lib/aws-sdk-s3/plugins/s3_signer.rb, line 56
def call(context)
  Aws::Plugins::SignatureV4.apply_signature(
    context: context,
    signer: sigv4_signer(context)
  )
  @handler.call(context)
end

Private Instance Methods

sigv4_signer(context) click to toggle source
# File lib/aws-sdk-s3/plugins/s3_signer.rb, line 66
def sigv4_signer(context)
  # If the client was configured with the wrong region,
  # we have to build a new signer.
  if context[:cached_sigv4_region] &&
     context[:cached_sigv4_region] != context.config.sigv4_signer.region
    S3Signer.build_v4_signer(
      service: 's3',
      region: context[:cached_sigv4_region],
      credentials: context.config.credentials
    )
  elsif (arn = context.metadata[:s3_arn])
    if arn[:arn].is_a?(MultiRegionAccessPointARN)
      signing_region = '*'
      signing_algorithm = :sigv4a
    else
      signing_region = arn[:resolved_region]
      signing_algorithm = :sigv4
    end
    S3Signer.build_v4_signer(
      service: arn[:arn].service,
      signing_algorithm: signing_algorithm,
      region: signing_region,
      credentials: context.config.credentials
    )
  elsif context.operation.name == 'WriteGetObjectResponse'
    S3Signer.build_v4_signer(
      service: 's3-object-lambda',
      region: context.config.sigv4_region,
      credentials: context.config.credentials
    )
  else
    context.config.sigv4_signer
  end
end