Sha256: 23d933e284812f41a7e1399247e612ea4c785a163e8fee800303ddd8ac832fd3
Contents?: true
Size: 958 Bytes
Versions: 22
Compression:
Stored size: 958 Bytes
Contents
# frozen_string_literal: true module Kafka module Sasl class Plain PLAIN_IDENT = "PLAIN" def initialize(logger:, authzid:, username:, password:) @logger = TaggedLogger.new(logger) @authzid = authzid @username = username @password = password end def ident PLAIN_IDENT end def configured? @authzid && @username && @password end def authenticate!(host, encoder, decoder) msg = [@authzid, @username, @password].join("\000").force_encoding("utf-8") encoder.write_bytes(msg) begin msg = decoder.bytes raise Kafka::Error, "SASL PLAIN authentication failed: unknown error" unless msg rescue Errno::ETIMEDOUT, EOFError => e raise Kafka::Error, "SASL PLAIN authentication failed: #{e.message}" end @logger.debug "SASL PLAIN authentication successful." end end end end
Version data entries
22 entries across 22 versions & 4 rubygems