aws-sigv4 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/VERSION +1 -1
  4. data/lib/aws-sigv4/signer.rb +4 -143
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25c3ddf60803af303d37af469c7250ceba22d6a23e62bbfb7a9a82ae3d01b8e8
4
- data.tar.gz: 36537ef12949c9d0a632060485c3dcf340176a8241c3e65828e47991581e7c89
3
+ metadata.gz: '0618892feafb12a38e21c6c50b932072a0760be0338f45672c29b8b541564774'
4
+ data.tar.gz: 780fb4cb4956691909e2c830b1938902774d085f9335f7101347b3974917f61b
5
5
  SHA512:
6
- metadata.gz: aa33926ae5a1804fee36cce9b7cadead40d9d5806154e62840be377c663d94dbac07ea537601f4fa47c1d4861dccb3bdf7801b2b1edf256a0a452a73fdf2c9de
7
- data.tar.gz: 8e1e705a6dfef2edd5af640de60f01321f1a811f41f407e906f08881d83d197ba9011c4ed3d2a218f6f17f94fcd602e0a6759abcf7c5e5e27f5d66465c3f3f3c
6
+ metadata.gz: 7c24541da4eea76873ffca584ee6b7fbbe8e57ff018f2e512e780bf4bc2ba5113bfce0312eec85ed61e246419a76000b6b54de629fc96ef252fe944b98175319
7
+ data.tar.gz: bc84f7601827ffd7015a6f52bec0a141bc16445c47de5dec271eb35e183ff377ee0527e5692ae21c8573c18e81505cf30f00f1cec736bc2fbf89a288c59cc42a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 1.10.0 (2024-09-17)
5
+ ------------------
6
+
7
+ * Feature - Remove CRT `sigv4a` signing capability.
8
+
9
+ 1.9.1 (2024-07-29)
10
+ ------------------
11
+
12
+ * Issue - Add missing require of `pathname` to `Signer`.
13
+
4
14
  1.9.0 (2024-07-23)
5
15
  ------------------
6
16
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.0
1
+ 1.10.0
@@ -6,6 +6,7 @@ require 'time'
6
6
  require 'uri'
7
7
  require 'set'
8
8
  require 'cgi'
9
+ require 'pathname'
9
10
  require 'aws-eventstream'
10
11
 
11
12
  module Aws
@@ -73,15 +74,6 @@ module Aws
73
74
  # and `#session_token`.
74
75
  #
75
76
  class Signer
76
-
77
- @@use_crt =
78
- begin
79
- require 'aws-crt'
80
- true
81
- rescue LoadError
82
- false
83
- end
84
-
85
77
  # @overload initialize(service:, region:, access_key_id:, secret_access_key:, session_token:nil, **options)
86
78
  # @param [String] :service The service signing name, e.g. 's3'.
87
79
  # @param [String] :region The region name, e.g. 'us-east-1'. When signing
@@ -153,13 +145,6 @@ module Aws
153
145
  @signing_algorithm = options.fetch(:signing_algorithm, :sigv4)
154
146
  @normalize_path = options.fetch(:normalize_path, true)
155
147
  @omit_session_token = options.fetch(:omit_session_token, false)
156
-
157
- if @signing_algorithm == 'sigv4-s3express'.to_sym &&
158
- Signer.use_crt? && Aws::Crt::GEM_VERSION <= '0.1.9'
159
- raise ArgumentError,
160
- 'This version of aws-crt does not support S3 Express. Please
161
- update this gem to at least version 0.2.0.'
162
- end
163
148
  end
164
149
 
165
150
  # @return [String]
@@ -235,9 +220,6 @@ module Aws
235
220
  # a `#headers` method. The headers must be applied to your request.
236
221
  #
237
222
  def sign_request(request)
238
-
239
- return crt_sign_request(request) if Signer.use_crt?
240
-
241
223
  creds, _ = fetch_credentials
242
224
 
243
225
  http_method = extract_http_method(request)
@@ -343,7 +325,6 @@ module Aws
343
325
  # signature value (a binary string) used at ':chunk-signature' needs to converted to
344
326
  # hex-encoded string using #unpack
345
327
  def sign_event(prior_signature, payload, encoder)
346
- # Note: CRT does not currently provide event stream signing, so we always use the ruby implementation.
347
328
  creds, _ = fetch_credentials
348
329
  time = Time.now
349
330
  headers = {}
@@ -430,9 +411,6 @@ module Aws
430
411
  # @return [HTTPS::URI, HTTP::URI]
431
412
  #
432
413
  def presign_url(options)
433
-
434
- return crt_presign_url(options) if Signer.use_crt?
435
-
436
414
  creds, expiration = fetch_credentials
437
415
 
438
416
  http_method = extract_http_method(options)
@@ -800,129 +778,12 @@ module Aws
800
778
  end
801
779
  end
802
780
 
803
- ### CRT Code
804
-
805
- # the credentials used by CRT must be a
806
- # CRT StaticCredentialsProvider object
807
- def crt_fetch_credentials
808
- creds, expiration = fetch_credentials
809
- crt_creds = Aws::Crt::Auth::StaticCredentialsProvider.new(
810
- creds.access_key_id,
811
- creds.secret_access_key,
812
- creds.session_token
813
- )
814
- [crt_creds, expiration]
815
- end
816
-
817
- def crt_sign_request(request)
818
- creds, _ = crt_fetch_credentials
819
- http_method = extract_http_method(request)
820
- url = extract_url(request)
821
- headers = downcase_headers(request[:headers])
822
-
823
- datetime =
824
- if headers.include? 'x-amz-date'
825
- Time.parse(headers.delete('x-amz-date'))
826
- end
827
-
828
- content_sha256 = headers.delete('x-amz-content-sha256')
829
- content_sha256 ||= sha256_hexdigest(request[:body] || '')
830
-
831
- sigv4_headers = {}
832
- sigv4_headers['host'] = headers['host'] || host(url)
833
-
834
- # Modify the user-agent to add usage of crt-signer
835
- # This should be temporary during developer preview only
836
- if headers.include? 'user-agent'
837
- headers['user-agent'] = "#{headers['user-agent']} crt-signer/#{@signing_algorithm}/#{Aws::Sigv4::VERSION}"
838
- sigv4_headers['user-agent'] = headers['user-agent']
839
- end
840
-
841
- headers = headers.merge(sigv4_headers) # merge so we do not modify given headers hash
842
-
843
- config = Aws::Crt::Auth::SigningConfig.new(
844
- algorithm: @signing_algorithm,
845
- signature_type: :http_request_headers,
846
- region: @region,
847
- service: @service,
848
- date: datetime,
849
- signed_body_value: content_sha256,
850
- signed_body_header_type: @apply_checksum_header ?
851
- :sbht_content_sha256 : :sbht_none,
852
- credentials: creds,
853
- unsigned_headers: @unsigned_headers,
854
- use_double_uri_encode: @uri_escape_path,
855
- should_normalize_uri_path: @normalize_path,
856
- omit_session_token: @omit_session_token
857
- )
858
- http_request = Aws::Crt::Http::Message.new(
859
- http_method, url.to_s, headers
860
- )
861
- signable = Aws::Crt::Auth::Signable.new(http_request)
862
-
863
- signing_result = Aws::Crt::Auth::Signer.sign_request(config, signable)
864
-
865
- Signature.new(
866
- headers: sigv4_headers.merge(
867
- downcase_headers(signing_result[:headers])
868
- ),
869
- string_to_sign: 'CRT_INTERNAL',
870
- canonical_request: 'CRT_INTERNAL',
871
- content_sha256: content_sha256,
872
- extra: {config: config, signable: signable}
873
- )
874
- end
875
-
876
- def crt_presign_url(options)
877
- creds, expiration = crt_fetch_credentials
878
-
879
- http_method = extract_http_method(options)
880
- url = extract_url(options)
881
- headers = downcase_headers(options[:headers])
882
- headers['host'] ||= host(url)
883
-
884
- datetime = Time.strptime(headers.delete('x-amz-date'), "%Y%m%dT%H%M%S%Z") if headers['x-amz-date']
885
- datetime ||= (options[:time] || Time.now)
886
-
887
- content_sha256 = headers.delete('x-amz-content-sha256')
888
- content_sha256 ||= options[:body_digest]
889
- content_sha256 ||= sha256_hexdigest(options[:body] || '')
890
-
891
- config = Aws::Crt::Auth::SigningConfig.new(
892
- algorithm: @signing_algorithm,
893
- signature_type: :http_request_query_params,
894
- region: @region,
895
- service: @service,
896
- date: datetime,
897
- signed_body_value: content_sha256,
898
- signed_body_header_type: @apply_checksum_header ?
899
- :sbht_content_sha256 : :sbht_none,
900
- credentials: creds,
901
- unsigned_headers: @unsigned_headers,
902
- use_double_uri_encode: @uri_escape_path,
903
- should_normalize_uri_path: @normalize_path,
904
- omit_session_token: @omit_session_token,
905
- expiration_in_seconds: presigned_url_expiration(options, expiration, datetime)
906
- )
907
- http_request = Aws::Crt::Http::Message.new(
908
- http_method, url.to_s, headers
909
- )
910
- signable = Aws::Crt::Auth::Signable.new(http_request)
911
-
912
- signing_result = Aws::Crt::Auth::Signer.sign_request(config, signable, http_method, url.to_s)
913
- url = URI.parse(signing_result[:path])
914
-
915
- if options[:extra] && options[:extra].is_a?(Hash)
916
- options[:extra][:config] = config
917
- options[:extra][:signable] = signable
918
- end
919
- url
920
- end
921
-
922
781
  class << self
923
782
 
783
+ # Kept for backwards compatability
784
+ # Always return false since we are not using crt signing functionality
924
785
  def use_crt?
925
- @@use_crt
786
+ false
926
787
  end
927
788
 
928
789
  # @api private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sigv4
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-23 00:00:00.000000000 Z
11
+ date: 2024-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-eventstream