lib/conjur/authn.rb in conjur-cli-5.6.6 vs lib/conjur/authn.rb in conjur-cli-6.0.0.rc1
- old
+ new
@@ -32,31 +32,26 @@
def initialize
super "No Conjur credentials provided or found"
end
end
- autoload :API, 'conjur/authn-api'
class << self
def login(options = {})
delete_credentials
get_credentials(options)
end
def authenticate(options = {})
require 'conjur/api'
- Conjur::API.authenticate(*get_credentials(options))
+ Conjur::API.authenticate *get_credentials(options)
end
def delete_credentials
- netrc.delete host
+ netrc.delete Conjur.configuration.authn_url
netrc.save
end
- def host
- Conjur::Authn::API.host
- end
-
def netrc
@netrc ||= read_netrc
end
def read_netrc
@@ -81,22 +76,22 @@
nil
end
end
def read_credentials
- netrc[host]
+ netrc[Conjur.configuration.authn_url]
end
def fetch_credentials(options = {})
ask_for_credentials(options)
write_credentials
end
alias save_credentials fetch_credentials
def write_credentials
- netrc[host] = @credentials
+ netrc[Conjur.configuration.authn_url] = @credentials
netrc.save
@credentials
end
def ask_for_credentials(options = {})
@@ -126,14 +121,12 @@
require 'conjur/base'
cls = Conjur::API
end
if token = token_from_environment
cls.new_from_token token
- elsif token_file = token_from_file
- cls.new_from_token_file token_file
else
- cls.new_from_key(*get_credentials(options))
+ cls.new_from_key *get_credentials(options)
end
end
protected
@@ -152,16 +145,8 @@
return nil unless token = ENV['CONJUR_AUTHN_TOKEN']
require 'json'
require 'base64'
JSON.parse(Base64.decode64(token))
- end
-
- def token_from_file
- token_file = ENV['CONJUR_AUTHN_TOKEN_FILE']
- if token_file && !File.exists?(token_file)
- $stderr.puts "Warning: CONJUR_AUTHN_TOKEN_FILE #{token_file.inspect} does not exist"
- end
- token_file
end
end
end