Sha256: 32b9313c61f4a0da47df331758a4c98b6379695d445986a8b488822d43aee13f

Contents?: true

Size: 1.6 KB

Versions: 59

Compression:

Stored size: 1.6 KB

Contents

module Fog
  module Credentials
    # This class is managing credentials token
    class AzureRM
      def self.get_credentials(tenant_id, client_id, client_secret, environment = ENVIRONMENT_AZURE_CLOUD)
        if @credentials.nil? || new_management_credential?(tenant_id, client_id, client_secret, environment)
          get_new_credentials(tenant_id, client_id, client_secret, environment)
        else
          @credentials
        end
      end

      def self.get_token(tenant_id, client_id, client_secret, environment = ENVIRONMENT_AZURE_CLOUD)
        get_credentials(tenant_id, client_id, client_secret, environment) if @credentials.nil?
        @token_provider.get_authentication_header
      end

      def self.get_new_credentials(tenant_id, client_id, client_secret, environment)
        @tenant_id = tenant_id
        @client_id = client_id
        @client_secret = client_secret
        @environment = environment
        return if @tenant_id.nil? || @client_id.nil? || @client_secret.nil?
        @token_provider = MsRestAzure::ApplicationTokenProvider.new(@tenant_id, @client_id, @client_secret, active_directory_service_settings(environment))
        @credentials = MsRest::TokenCredentials.new(@token_provider)
        @credentials
      end

      def self.new_management_credential?(tenant_id, client_id, client_secret, environment)
        @tenant_id != tenant_id ||
          @client_id != client_id ||
          @client_secret != client_secret ||
          @environment != environment
      end

      private_class_method :get_new_credentials
      private_class_method :new_management_credential?
    end
  end
end

Version data entries

59 entries across 59 versions & 5 rubygems

Version Path
gitlab-fog-azure-rm-1.5.0 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-1.4.0 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-1.3.0 lib/fog/azurerm/credentials.rb
fog-azure-rm-0.6.0 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-1.2.0 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-1.1.1 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-1.0.1 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-1.0.0 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-0.9.0 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-0.8.1 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-0.8.0 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-0.7.0 lib/fog/azurerm/credentials.rb
gitlab-fog-azure-rm-0.6.0 lib/fog/azurerm/credentials.rb
fog-azure-rm-0.5.3 lib/fog/azurerm/credentials.rb
fog-azure-rm-0.5.2 lib/fog/azurerm/credentials.rb
far-gem-0.5.6 lib/fog/azurerm/credentials.rb
fog-azure-rm-0.5.1 lib/fog/azurerm/credentials.rb
far-gem-0.5.5 lib/fog/azurerm/credentials.rb
fog-azure-rm-0.5.0 lib/fog/azurerm/credentials.rb
far-gem-0.5.4 lib/fog/azurerm/credentials.rb