Class: Mongo::Crypt::KMS::AWS::Credentials Private
- Inherits:
-
Object
- Object
- Mongo::Crypt::KMS::AWS::Credentials
- Extended by:
- Forwardable
- Includes:
- Validations
- Defined in:
- lib/mongo/crypt/kms/aws/credentials.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
AWS KMS Credentials object contains credentials for using AWS KMS provider.
Constant Summary collapse
- FORMAT_HINT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'AWS KMS provider options must be in the format: ' + "{ access_key_id: 'YOUR-ACCESS-KEY-ID', secret_access_key: 'SECRET-ACCESS-KEY' }"
Instance Attribute Summary collapse
-
#access_key_id ⇒ String
readonly
private
AWS access key.
-
#secret_access_key ⇒ String
readonly
private
AWS secret access key.
-
#session_token ⇒ String | nil
readonly
private
AWS session token.
Instance Method Summary collapse
-
#initialize(opts) ⇒ Credentials
constructor
private
Creates an AWS KMS credentials object form a parameters hash.
-
#to_document ⇒ BSON::Document
private
Convert credentials object to a BSON document in libmongocrypt format.
Methods included from Validations
#validate_param, validate_tls_options
Constructor Details
#initialize(opts) ⇒ Credentials
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates an AWS KMS credentials object form a parameters hash.
53 54 55 56 57 58 59 60 |
# File 'lib/mongo/crypt/kms/aws/credentials.rb', line 53 def initialize(opts) @opts = opts return if empty? @access_key_id = validate_param(:access_key_id, opts, FORMAT_HINT) @secret_access_key = validate_param(:secret_access_key, opts, FORMAT_HINT) @session_token = validate_param(:session_token, opts, FORMAT_HINT, required: false) end |
Instance Attribute Details
#access_key_id ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns AWS access key.
29 30 31 |
# File 'lib/mongo/crypt/kms/aws/credentials.rb', line 29 def access_key_id @access_key_id end |
#secret_access_key ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns AWS secret access key.
32 33 34 |
# File 'lib/mongo/crypt/kms/aws/credentials.rb', line 32 def secret_access_key @secret_access_key end |
#session_token ⇒ String | nil (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns AWS session token.
35 36 37 |
# File 'lib/mongo/crypt/kms/aws/credentials.rb', line 35 def session_token @session_token end |
Instance Method Details
#to_document ⇒ BSON::Document
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Convert credentials object to a BSON document in libmongocrypt format.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/mongo/crypt/kms/aws/credentials.rb', line 65 def to_document return BSON::Document.new if empty? BSON::Document.new({ accessKeyId: access_key_id, secretAccessKey: secret_access_key, }).tap do |bson| bson.update({ sessionToken: session_token }) unless session_token.nil? end end |