Path: blob/main/component/loki/source/internal/kafkatarget/authentication.go
4096 views
package kafkatarget12// This code is copied from Promtail. The herokutarget package is used to3// configure and run the targets that can read heroku entries and forward them4// to other loki components.56import (7"crypto/sha256"8"crypto/sha512"910"github.com/xdg-go/scram"11)1213// copied from https://github.com/Shopify/sarama/blob/44627b731c60bb90efe25573e7ef2b3f8df3fa23/examples/sasl_scram_client/scram_client.go14var (15SHA256 scram.HashGeneratorFcn = sha256.New16SHA512 scram.HashGeneratorFcn = sha512.New17)1819// XDGSCRAMClient implements sarama.SCRAMClient20type XDGSCRAMClient struct {21*scram.Client22*scram.ClientConversation23scram.HashGeneratorFcn24}2526func (x *XDGSCRAMClient) Begin(userName, password, authzID string) (err error) {27x.Client, err = x.HashGeneratorFcn.NewClient(userName, password, authzID)28if err != nil {29return err30}31x.ClientConversation = x.Client.NewConversation()32return nil33}3435func (x *XDGSCRAMClient) Step(challenge string) (response string, err error) {36response, err = x.ClientConversation.Step(challenge)37return38}3940func (x *XDGSCRAMClient) Done() bool {41return x.ClientConversation.Done()42}434445