Skip to content

fix(kafka): register SCRAMClientGeneratorFunc for SCRAM-SHA-256/512 auth#789

Open
AuburyEssentian wants to merge 1 commit intoethpandaops:masterfrom
AuburyEssentian:fix/kafka-scram-auth
Open

fix(kafka): register SCRAMClientGeneratorFunc for SCRAM-SHA-256/512 auth#789
AuburyEssentian wants to merge 1 commit intoethpandaops:masterfrom
AuburyEssentian:fix/kafka-scram-auth

Conversation

@AuburyEssentian
Copy link

Problem

Closes #726.

When configuring the Kafka output with SCRAM-SHA-256 or SCRAM-SHA-512 SASL authentication, InitSaramaConfig sets the mechanism name on the sarama config but never sets SCRAMClientGeneratorFunc. Sarama requires this function to perform the SCRAM challenge-response handshake — without it, the connection attempt fails with an authentication error even though the config looks correct.

Fix

Add an xdgSCRAMClient struct that wraps github.com/xdg-go/scram (already an indirect dependency) and implements the sarama.SCRAMClient interface (Begin, Step, Done). Wire up generator functions for SHA-256 and SHA-512 inside the SCRAM-SHA-256/SCRAM-SHA-512 switch cases in InitSaramaConfig.

github.com/xdg-go/scram is promoted from indirect to direct in go.mod since it is now explicitly used by this package.

Tests

Updated TestInitSaramaConfig/SASL mechanisms to assert that:

  • SCRAMClientGeneratorFunc is non-nil for SCRAM-SHA-256 and SCRAM-SHA-512
  • SCRAMClientGeneratorFunc is nil for all other mechanisms (PLAIN, OAUTH, GSSAPI)
  • The generated client implements sarama.SCRAMClient

SCRAM authentication requires sarama's SCRAMClientGeneratorFunc to be set
in addition to the mechanism name. Without it, the mechanism is declared
but the actual SCRAM handshake is never performed, causing authentication
to always fail.

Add an xdgSCRAMClient implementation backed by github.com/xdg-go/scram
(already an indirect dependency via sarama) and wire it up for both
SCRAM-SHA-256 and SCRAM-SHA-512 in InitSaramaConfig.

Add test assertions to verify SCRAMClientGeneratorFunc is non-nil for
SCRAM mechanisms and nil for all others.

Fixes ethpandaops#726
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kafka output SCRAM authentication not working - missing protocol handler

1 participant