lib/dalli/protocol/binary/sasl_authentication.rb in dalli-3.0.5 vs lib/dalli/protocol/binary/sasl_authentication.rb in dalli-3.0.6

- old
+ new

@@ -9,13 +9,16 @@ module SaslAuthentication def perform_auth_negotiation write(RequestFormatter.standard_request(opkey: :auth_negotiation)) status, content = @response_processor.auth_response - # TODO: Determine if this substitution is needed - content.tr("\u0000", ' ') - mechanisms = content.split + return [status, []] if content.nil? + + # Substitute spaces for the \x00 returned by + # memcached as a separator for easier + content&.tr("\u0000", ' ') + mechanisms = content&.split [status, mechanisms] end PLAIN_AUTH = 'PLAIN' @@ -43,10 +46,10 @@ supported_mechanisms!(mechanisms) status, content = authenticate_with_plain return Dalli.logger.info("Dalli/SASL: #{content}") if status.zero? - raise Dalli::DalliError, "Error authenticating: #{status}" unless status == 0x21 + raise Dalli::DalliError, "Error authenticating: 0x#{status.to_s(16)}" unless status == 0x21 raise NotImplementedError, 'No two-step authentication mechanisms supported' # (step, msg) = sasl.receive('challenge', content) # raise Dalli::NetworkError, "Authentication failed" if sasl.failed? || step != 'response' end