Method: Mongo::Crypt::KMS::Azure::Credentials#initialize

Defined in:
lib/mongo/crypt/kms/azure/credentials.rb

#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 Azure KMS credentials object form a parameters hash.

Parameters:

  • opts (Hash)

    A hash that contains credentials for Azure KMS provider

Options Hash (opts):

  • :tenant_id (String)

    Azure tenant id.

  • :client_id (String)

    Azure client id.

  • :client_secret (String)

    Azure client secret.

  • :identity_platform_endpoint (String | nil)

    Azure identity platform endpoint, optional.

Raises:

  • (ArgumentError)

    If required options are missing or incorrectly formatted.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/mongo/crypt/kms/azure/credentials.rb', line 61

def initialize(opts)
  @opts = opts
  return if empty?

  if opts[:access_token]
    @access_token = opts[:access_token]
  else
    @tenant_id = validate_param(:tenant_id, opts, FORMAT_HINT)
    @client_id = validate_param(:client_id, opts, FORMAT_HINT)
    @client_secret = validate_param(:client_secret, opts, FORMAT_HINT)
    @identity_platform_endpoint = validate_param(
      :identity_platform_endpoint, opts, FORMAT_HINT, required: false
    )
  end
end