Skip to content

A simple and straight forward implementation of Shopify/sarama's AccessTokenProvider interface to be used for the SASL/OAUTHBEARER auth mechanism for Apache Kafka

License

damiannolan/sasl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SASL/OAUTHBEARER Access Token Provider

Overview

This package is intended to be used as a complement to Shopify/sarama. It provides an implementation of the sarama.AccessTokenProvider interface to be employed by clients using the SASL/OAUTHBEARER mechanism for Apache Kafka.

The very popular golang/oauth2 and golang/oauth2/clientcredentials are leveraged to perform the 2 legged client credentials flow to obtain an Access Token outside the context of a user.

Installation

go get github.com/damiannolan/sasl/oauthbearer

Usage

Configure sarama.Config as desired for producer/consumer clients and enable SASL/OAUTHBEARER with the appropriate settings. For production setups it is recommended to use this authentication mechanism over a secure connection. This can be achieved by setting Net.TLS.Enable to true and providing a *tls.Config through Net.TLS.Config.

import (
    "github.com/Shopify/sarama"
    "github.com/damiannolan/sasl/oauthbearer"
)

func main() {
    cfg := sarama.NewConfig()

    cfg.Net.SASL.Enable = true
    cfg.Net.SASL.Mechanism = sarama.SASLTypeOAuth
    cfg.Net.SASL.TokenProvider = oauthbearer.NewTokenProvider(clientID, clientSecret, tokenURL)
    ...
}

References

About

A simple and straight forward implementation of Shopify/sarama's AccessTokenProvider interface to be used for the SASL/OAUTHBEARER auth mechanism for Apache Kafka

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published