Sha256: 45d7dfc9604ffb502441ad26137bee793d7c064cf36b46923a296f152b16c8a8

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

module Fog
  module Credentials
    class AzureRM

      def self.get_credentials(tenant_id, client_id, client_secret)
        if @credentials.nil? || new_client(tenant_id, client_id, client_secret)
          get_new_credentials(tenant_id, client_id, client_secret)
        else
          @credentials
        end
      end

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

      def self.get_new_credentials(tenant_id, client_id, client_secret)
        @tenant_id = tenant_id
        @client_id = client_id
        @client_secret = client_secret
        @token_provider = MsRestAzure::ApplicationTokenProvider.new(@tenant_id, @client_id, @client_secret)
        @credentials = MsRest::TokenCredentials.new(@token_provider)
        @credentials
      end

      def self.new_client(tenant_id, client_id, client_secret)
        @tenant_id != tenant_id ||
            @client_id != client_id ||
            @client_secret != client_secret
      end

      private_class_method :get_new_credentials
      private_class_method :new_client
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-azure-rm-0.0.2 lib/fog/azurerm/credentials.rb
fog-azure-rm-0.0.1 lib/fog/azurerm/credentials.rb
fog-azure-rm-0.0.0 lib/fog/azurerm/credentials.rb