class Kafka::Sasl::Plain
Constants
- PLAIN_IDENT
Public Class Methods
new(logger:, authzid:, username:, password:)
click to toggle source
# File lib/kafka/sasl/plain.rb, line 8 def initialize(logger:, authzid:, username:, password:) @logger = TaggedLogger.new(logger) @authzid = authzid @username = username @password = password end
Public Instance Methods
authenticate!(host, encoder, decoder)
click to toggle source
# File lib/kafka/sasl/plain.rb, line 23 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
configured?()
click to toggle source
# File lib/kafka/sasl/plain.rb, line 19 def configured? @authzid && @username && @password end
ident()
click to toggle source
# File lib/kafka/sasl/plain.rb, line 15 def ident PLAIN_IDENT end