class Armrest::Auth

Public Class Methods

new(options={}) click to toggle source
# File lib/armrest/auth.rb, line 5
def initialize(options={})
  @options = options
end

Public Instance Methods

provider() click to toggle source
# File lib/armrest/auth.rb, line 9
def provider
  providers.each do |meth|
    provider = send(meth)
    if provider
      logger.debug "Resolved auth provider: #{provider}"
      return provider
    end
  end
  nil
end

Private Instance Methods

app_credentials() click to toggle source
# File lib/armrest/auth.rb, line 33
def app_credentials
  return unless ENV['ARM_CLIENT_ID'] || ENV['AZURE_CLIENT_ID']
  Armrest::Api::Auth::Login.new(@options)
end
cli_credentials() click to toggle source
# File lib/armrest/auth.rb, line 43
def cli_credentials
  return unless File.exist?("#{ENV['HOME']}/.azure/accessTokens.json")
  Armrest::Api::Auth::CLI.new(@options)
end
msi_credentials() click to toggle source
# File lib/armrest/auth.rb, line 38
def msi_credentials
  api = Armrest::Api::Auth::Metadata.new(@options)
  api if api.available?
end
providers() click to toggle source
# File lib/armrest/auth.rb, line 21
def providers
  if @options[:type]
    ["#{@options[:type]}_credentials"]
  else # full chain
    [
      :app_credentials,
      :msi_credentials,
      :cli_credentials,
    ]
  end
end