MCPcopy
hub / github.com/segmentio/kafka-go / Mechanism

Function Mechanism

sasl/scram/scram.go:62–73  ·  view source on GitHub ↗

Mechanism returns a new sasl.Mechanism that will use SCRAM with the provided Algorithm to securely transmit the provided credentials to Kafka. SCRAM-SHA-256 and SCRAM-SHA-512 were added to Kafka in 0.10.2.0. These mechanisms will not work with older versions.

(algo Algorithm, username, password string)

Source from the content-addressed store, hash-verified

60// SCRAM-SHA-256 and SCRAM-SHA-512 were added to Kafka in 0.10.2.0. These
61// mechanisms will not work with older versions.
62func Mechanism(algo Algorithm, username, password string) (sasl.Mechanism, error) {
63 hashGen := scram.HashGeneratorFcn(algo.Hash)
64 client, err := hashGen.NewClient(username, password, "")
65 if err != nil {
66 return nil, err
67 }
68
69 return &mechanism{
70 algo: algo,
71 client: client,
72 }, nil
73}
74
75func (m *mechanism) Name() string {
76 return m.algo.Name()

Callers 1

TestSASLFunction · 0.92

Calls

no outgoing calls

Tested by 1

TestSASLFunction · 0.74