Class: Fog::AWS::Storage::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/aws/storage.rb

Overview

Immutable snapshot of the credential-derived state needed to sign a request: the access key id, secret, session token, and the matching signer (v4) or HMAC (v2). These values are correlated. Under use_iam_profile they are all replaced together whenever credentials are refreshed.

Bundling them into one frozen object stored in a single instance variable lets a caller read a consistent set with one atomic reference read (see Real#request). Reading the fields as separate instance variables lets a refresh land between two reads and pair, for example, an old session token with a new signer, which S3 rejects with a 403. Keeping this connection safe to share across threads depends on never mutating an instance; build a new one and swap the reference.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(aws_access_key_id: nil, aws_secret_access_key: nil, aws_session_token: nil, signer: nil, hmac: nil) ⇒ Credentials

Returns a new instance of Credentials.



148
149
150
151
152
153
154
155
# File 'lib/fog/aws/storage.rb', line 148

def initialize(aws_access_key_id: nil, aws_secret_access_key: nil, aws_session_token: nil, signer: nil, hmac: nil)
  @aws_access_key_id     = aws_access_key_id
  @aws_secret_access_key = aws_secret_access_key
  @aws_session_token     = aws_session_token
  @signer                = signer
  @hmac                  = hmac
  freeze
end

Instance Attribute Details

#aws_access_key_idObject (readonly)

Returns the value of attribute aws_access_key_id.



146
147
148
# File 'lib/fog/aws/storage.rb', line 146

def aws_access_key_id
  @aws_access_key_id
end

#aws_secret_access_keyObject (readonly)

Returns the value of attribute aws_secret_access_key.



146
147
148
# File 'lib/fog/aws/storage.rb', line 146

def aws_secret_access_key
  @aws_secret_access_key
end

#aws_session_tokenObject (readonly)

Returns the value of attribute aws_session_token.



146
147
148
# File 'lib/fog/aws/storage.rb', line 146

def aws_session_token
  @aws_session_token
end

#hmacObject (readonly)

Returns the value of attribute hmac.



146
147
148
# File 'lib/fog/aws/storage.rb', line 146

def hmac
  @hmac
end

#signerObject (readonly)

Returns the value of attribute signer.



146
147
148
# File 'lib/fog/aws/storage.rb', line 146

def signer
  @signer
end