lib/conjur/authn.rb in conjur-cli-5.4.0 vs lib/conjur/authn.rb in conjur-cli-5.5.0
- old
+ new
@@ -126,10 +126,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))
end
end
@@ -150,8 +152,16 @@
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