lib/net/ssh/userauth/driver.rb in net-ssh-0.9.0 vs lib/net/ssh/userauth/driver.rb in net-ssh-1.0.0

- old
+ new

@@ -45,10 +45,11 @@ @log = log @buffers = buffers @methods = methods @on_banner = proc { |msg,lang| puts msg } @order = order.dup + @allowed_auth_methods = nil end # Causes the set of on-disk key files to be used to be set to the # given array. Any key files that were specified previously are # lost. @@ -102,10 +103,11 @@ @on_banner.call( message, language ) when USERAUTH_FAILURE authentications = buffer.read_string + @allowed_auth_methods = authentications.split(/,/) partial_success = buffer.read_bool return OpenStruct.new( :message_type => type, :authentications => authentications, :partial_success => partial_success ) @@ -149,9 +151,14 @@ data = { :password => password, :key_manager => @key_manager } @order.each do |auth_method| + # if the server has reported a list of auth methods that are + # allowed to continue, only consider those auth methods. + next if @allowed_auth_methods && + !@allowed_auth_methods.include?( auth_method ) + @log.debug "trying #{auth_method.inspect}" if @log.debug? impl = @methods[ auth_method.downcase.gsub(/-/,"_").intern ] if impl.nil? raise NotImplementedError,