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)
| 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. |
| 62 | func 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 | |
| 75 | func (m *mechanism) Name() string { |
| 76 | return m.algo.Name() |