Repository navigation
feat: support kafka auth mechanism scram-sha-512 - #134
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for Kafka SASL/SCRAM-SHA-512 authentication by wiring a SCRAM client implementation into the Kafka publisher and exposing a mechanism selector via configuration/CLI.
Changes:
- Introduces an
xdg-go/scram→ SaramaSCRAMClientadapter plus a handshake test. - Adds
SASLMechanismto Kafka publisher config and CLI flag plumbed into app startup. - Updates Go module dependencies to include
github.com/xdg-go/scram(and indirect deps).
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/publisher/kafka/scram.go | Adds SCRAM client adapter used by Sarama for SCRAM auth. |
| pkg/publisher/kafka/scram_test.go | Adds end-to-end SCRAM-SHA-512 conversation test against a real scram server. |
| pkg/publisher/kafka/kafka.go | Wires SCRAM-SHA-512 into Sarama config based on SASLMechanism. |
| pkg/publisher/kafka/config.go | Extends publisher config with SASLMechanism. |
| internal/app/flags.go | Adds --kafka-sasl-mechanism / KAFKA_SASL_MECHANISM flag. |
| internal/app/app.go | Passes SASL mechanism from CLI into Kafka publisher config. |
| go.mod | Adds github.com/xdg-go/scram dependency (plus indirect deps). |
| go.sum | Records module checksums for the new dependencies. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+3
to
+23
| import ( | ||
| "github.com/xdg-go/scram" | ||
| ) | ||
|
|
||
| // XDGSCRAMClient adapts xdg-go/scram to sarama's SCRAMClient interface. | ||
| // Step and Done are satisfied via the embedded *scram.ClientConversation. | ||
| type XDGSCRAMClient struct { | ||
| *scram.Client | ||
| *scram.ClientConversation | ||
| scram.HashGeneratorFcn | ||
| } | ||
|
|
||
| func (x *XDGSCRAMClient) Begin(userName, password, authzID string) error { | ||
| client, err := x.NewClient(userName, password, authzID) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| x.Client = client | ||
| x.ClientConversation = x.NewConversation() | ||
| return nil | ||
| } |
Comment on lines
+39
to
+46
| if config.UseAuthentication && config.SASLMechanism == sarama.SASLTypeSCRAMSHA512 { | ||
| zap.S().Info("[kafka] using SASL/SCRAM-SHA-512 authentication") | ||
|
|
||
| c.Net.SASL.Mechanism = sarama.SASLTypeSCRAMSHA512 | ||
| c.Net.SASL.SCRAMClientGeneratorFunc = func() sarama.SCRAMClient { | ||
| return &XDGSCRAMClient{HashGeneratorFcn: scram.SHA512} | ||
| } | ||
| } |
Comment on lines
+39
to
+46
| if config.UseAuthentication && config.SASLMechanism == sarama.SASLTypeSCRAMSHA512 { | ||
| zap.S().Info("[kafka] using SASL/SCRAM-SHA-512 authentication") | ||
|
|
||
| c.Net.SASL.Mechanism = sarama.SASLTypeSCRAMSHA512 | ||
| c.Net.SASL.SCRAMClientGeneratorFunc = func() sarama.SCRAMClient { | ||
| return &XDGSCRAMClient{HashGeneratorFcn: scram.SHA512} | ||
| } | ||
| } |
Comment on lines
+150
to
+155
| kafkaSASLMechanismFlag = &cli.StringFlag{ | ||
| Name: "kafka-sasl-mechanism", | ||
| EnvVars: []string{"KAFKA_SASL_MECHANISM"}, | ||
| Value: "", | ||
| Usage: "SASL mechanism for authenticating with kafka brokers. Supports: `SCRAM-SHA-512`, PLAIN (default)", | ||
| } |
NgoKimPhu
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.