Class: Fog::AzureRM::Identity::ManagedIdentityClient
- Inherits:
-
BaseClient
- Object
- BaseClient
- Fog::AzureRM::Identity::ManagedIdentityClient
- Includes:
- Utilities::General
- Defined in:
- lib/fog/azurerm/identity/managed_identity_client.rb
Overview
ManagedIdentityClient fetches temporary credentials from the instance metadata endpoint.
Constant Summary
Constants inherited from BaseClient
BaseClient::DEFAULT_TIMEOUT_S, BaseClient::FetchCredentialsError
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Attributes inherited from BaseClient
Instance Method Summary collapse
-
#fetch_credentials ⇒ Object
This method obtains a token via the Azure Instance Metadata Service (IMDS) endpoint: learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http.
-
#initialize(options) ⇒ ManagedIdentityClient
constructor
A new instance of ManagedIdentityClient.
Methods included from Utilities::General
#authority_url, #get_blob_endpoint, #get_blob_endpoint_with_domain, #get_circuit_name_from_id, #get_end_point_type, #get_hash_from_object, #get_image_name, #get_record_set_from_id, #get_record_type, #get_resource_from_resource_id, #get_resource_group_from_id, #get_subscription_id, #get_traffic_manager_profile_name_from_endpoint_id, #get_type_from_recordset_type, #get_virtual_machine_from_id, #get_virtual_network_from_id, #parse_storage_object, #raise_azure_exception, #random_string, #remove_trailing_periods_from_path_segments, #storage_endpoint_suffix, #storage_resource, #validate_params
Methods inherited from BaseClient
#fetch_credentials_if_needed, #refresh_needed?
Constructor Details
#initialize(options) ⇒ ManagedIdentityClient
Returns a new instance of ManagedIdentityClient.
18 19 20 21 22 |
# File 'lib/fog/azurerm/identity/managed_identity_client.rb', line 18 def initialize() super() @environment = [:environment] @resource = storage_resource(@environment) end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
16 17 18 |
# File 'lib/fog/azurerm/identity/managed_identity_client.rb', line 16 def resource @resource end |
Instance Method Details
#fetch_credentials ⇒ Object
This method obtains a token via the Azure Instance Metadata Service (IMDS) endpoint: learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/azurerm/identity/managed_identity_client.rb', line 26 def fetch_credentials url = "#{identity_endpoint}?api-version=#{api_version}&resource=#{CGI.escape(resource)}" client_id = ENV['AZURE_CLIENT_ID'] url += "&client_id=#{client_id}" if client_id headers = { 'Metadata' => 'true' } headers['X-IDENTITY-HEADER'] = ENV['IDENTITY_HEADER'] if ENV['IDENTITY_HEADER'] response = get(url, headers: headers) process_token_response(response) end |