Class: Mongo::Crypt::KMS::Azure::CredentialsRetriever Private
- Inherits:
-
Object
- Object
- Mongo::Crypt::KMS::Azure::CredentialsRetriever
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/crypt/kms/azure/credentials_retriever.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.
This class retrieves Azure credentials using Azure metadata host. This should be used when the driver is used on the Azure environment.
Constant Summary collapse
- DEFAULT_HOST =
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.
Default host to obtain Azure metadata.
'169.254.169.254'
Class Method Summary collapse
-
.fetch_access_token(extra_headers: {}, metadata_host: nil) ⇒ KMS::Azure::AccessToken
private
Fetches Azure credentials from Azure metadata host.
Class Method Details
.fetch_access_token(extra_headers: {}, metadata_host: nil) ⇒ KMS::Azure::AccessToken
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.
Fetches Azure credentials from Azure metadata host.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'build/ruby-driver-v2.19/lib/mongo/crypt/kms/azure/credentials_retriever.rb', line 41 def self.fetch_access_token(extra_headers: {}, metadata_host: nil) uri, req = prepare_request(extra_headers, ) parsed_response = fetch_response(uri, req) Azure::AccessToken.new( parsed_response.fetch('access_token'), Integer(parsed_response.fetch('expires_in')) ) rescue KeyError, ArgumentError => e raise KMS::CredentialsNotFound, "Azure metadata response is invalid: '#{parsed_response}'; #{e.class}: #{e.}" end |