Class: Aws::Crt::Auth::SigningConfig

Inherits:
Object
  • Object
show all
Includes:
ManagedNative
Defined in:
lib/aws-crt/auth/signing_config.rb

Overview

Signing Config

Instance Method Summary collapse

Methods included from ManagedNative

included, #manage_native, #native, #native_set?, #release

Constructor Details

#initialize(options = {}) ⇒ SigningConfig

Returns a new instance of SigningConfig.

Parameters:

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

    a customizable set of options

  • options[Integer] (Hash)

    a customizable set of options

Options Hash (options):

  • :signed_body_header_type (Boolean) — default: :sbht_content_sha256

    - Controls if signing adds a header containing the canonical request’s body value

  • :signed_body_value (String)
    • Optional string to use

    as the canonical request’s body value. If string is empty, a value will be calculated from the payload during signing. Typically, this is the SHA-256 of the (request/chunk/event) payload, written as lowercase hex. If this has been precalculated, it can be set here. Special values used by certain services can also be set (e.g. “UNSIGNED-PAYLOAD” “STREAMING-AWS4-HMAC-SHA256-PAYLOAD” “STREAMING-AWS4-HMAC-SHA256-EVENTS”).



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/aws-crt/auth/signing_config.rb', line 47

def initialize(options = {})
  # validation of parameters is handled in signing_config_new

  # create a callback function for aws_should_sign_header_fn
  @sign_header_fn = extract_unsigned_header_fn(
    options[:unsigned_headers]
  )

  signed_body_header_type = options.fetch(
    :signed_body_header_type,
    :sbht_content_sha256
  )

  # ensure we retain a reference to the credentials to avoid GC
  @credentials = options[:credentials]
  manage_native do
    Aws::Crt::Native.signing_config_aws_new
  end

  Aws::Crt::Native.signing_config_aws_set_algorithm(native, options[:algorithm])
  Aws::Crt::Native.signing_config_aws_set_signature_type(native, options[:signature_type])
  Aws::Crt::Native.signing_config_aws_set_region(native, options[:region], options[:region].length)
  Aws::Crt::Native.signing_config_aws_set_service(native, options[:service], options[:service].length)
  Aws::Crt::Native.signing_config_aws_set_date(native, extract_date(options))
  Aws::Crt::Native.signing_config_aws_set_credentials_provider(native, @credentials&.native)
  Aws::Crt::Native.signing_config_aws_set_signed_body_header_type(native, signed_body_header_type)
  if @sign_header_fn
    Aws::Crt::Native.signing_config_aws_set_should_sign_header_fn(native, @sign_header_fn)
  end

  assign_body_value(options)
  assign_flags(options)

  validate_config!
end