Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sigv4 gem updates: SRA Identity + backports #48

Merged
merged 14 commits into from
May 8, 2024
42 changes: 32 additions & 10 deletions gems/aws-sdk-core/lib/aws-sdk-core/signers/sigv4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,41 @@ module AWS::SDK::Core
module Signers
# A signer that signs requests using the SigV4 Auth scheme.
class SigV4 < Hearth::Signers::Base
def sign(request:, identity:, properties:)
signer = AWS::SigV4::Signer.new
# @param signer [AWS::SigV4::Signer] (AWS::SigV4::Signer.new) An
# initialized signer, allowing override of default signing parameters.
# To override default signing behavior, configure an
# auth_scheme on the client:
#
# custom_signer = AWS::SDK::Core::Signers::SigV4.new(
# signer: AWS::SigV4::Signer.new(**my_signing_properties)
# )
# custom_sigv4_auth_scheme = AWS::SDK::Core::AuthSchemes::SigV4.new(
# signer: custom_signer
# )
# client = AWS::SDK::S3::Client.new(
# auth_schemes: [custom_sigv4_auth_scheme]
# )
#
# Note: If you need to override resolved signing properties, you must
# wrap the AWS::SDK::<Service>::Auth::Resolver and modify the
# returned properties rather than initializing a signer with those
# properties - providing an initialized signer here is only for
# overriding signing defaults.
def initialize(signer: AWS::SigV4::Signer.new)
@signer = signer
super()
end

attr_reader :signer

def sign(request:, identity:, properties:)
apply_unsigned_body(request, properties)

signature = signer.sign_request(request: {
http_method: request.http_method,
url: request.uri,
headers: request.headers.to_h,
body: request.body
},
credentials: identity,
**properties)
signature = @signer.sign_request(
request: request,
credentials: identity,
**properties
)
apply_signature(request, signature)
end

Expand Down
4 changes: 2 additions & 2 deletions gems/aws-sigv4/lib/aws-sigv4/credentials.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

module AWS::SigV4
# A Credentials data object that stores AWS credentials. This object may be
# populated from various different Credential Providers.
# An AWS Credentials identity data object that stores AWS credentials
# used for Sigv4 and Sigv4a.
class Credentials
# @param [String] access_key_id
# @param [String] secret_access_key
Expand Down
Loading
Loading