@@ -23,34 +23,39 @@ import (
2323 "github.com/confluentinc/confluent-kafka-go/v2/schemaregistry"
2424)
2525
26- var srUrl = "https://psrc-1234.us-east-1.aws.confluent.cloud"
27- var tokenUrl = "your-token-url"
28- var clientId = "your-client-id"
26+ var srURL = "https://psrc-1234.us-east-1.aws.confluent.cloud"
27+ var tokenURL = "your-token-url"
28+ var clientID = "your-client-id"
2929var clientSecret = "your-client-secret"
3030var scopes = []string {"schema_registry" }
3131var identityPoolID = "pool-1234"
3232var schemaRegistryLogicalCluster = "lsrc-abcd"
3333
34+ // CustomHeaderProvider is a custom header provider that implements the AuthenticationHeaderProvider interface
3435type CustomHeaderProvider struct {
3536 token string
3637 schemaRegistryLogicalCluster string
3738 identityPoolID string
3839}
3940
41+ // GetAuthenticationHeader returns the authentication header for the custom header provider
4042func (p * CustomHeaderProvider ) GetAuthenticationHeader () (string , error ) {
4143 return "Bearer " + p .token , nil
4244}
4345
46+ // GetLogicalCluster returns the logical cluster for the custom header provider
4447func (p * CustomHeaderProvider ) GetLogicalCluster () (string , error ) {
4548 return p .schemaRegistryLogicalCluster , nil
4649}
50+
51+ // GetIdentityPoolID returns the identity pool ID for the custom header provider
4752func (p * CustomHeaderProvider ) GetIdentityPoolID () (string , error ) {
4853 return p .identityPoolID , nil
4954}
5055
5156func main () {
5257 // Static token
53- staticConf := schemaregistry .NewConfigWithBearerAuthentication (srUrl , "token" , schemaRegistryLogicalCluster , identityPoolID )
58+ staticConf := schemaregistry .NewConfigWithBearerAuthentication (srURL , "token" , schemaRegistryLogicalCluster , identityPoolID )
5459 staticClient , _ := schemaregistry .NewClient (staticConf )
5560
5661 subjects , err := staticClient .GetAllSubjects ()
@@ -61,13 +66,13 @@ func main() {
6166 fmt .Println ("Static token subjects:" , subjects )
6267
6368 //OAuthBearer
64- ClientCredentialsConf := schemaregistry .NewConfig (srUrl )
69+ ClientCredentialsConf := schemaregistry .NewConfig (srURL )
6570 ClientCredentialsConf .BearerAuthCredentialsSource = "OAUTHBEARER"
6671 ClientCredentialsConf .BearerAuthToken = "token"
6772 ClientCredentialsConf .BearerAuthIdentityPoolID = identityPoolID
6873 ClientCredentialsConf .BearerAuthLogicalCluster = schemaRegistryLogicalCluster
69- ClientCredentialsConf .BearerAuthIssuerEndpointURL = tokenUrl
70- ClientCredentialsConf .BearerAuthClientID = clientId
74+ ClientCredentialsConf .BearerAuthIssuerEndpointURL = tokenURL
75+ ClientCredentialsConf .BearerAuthClientID = clientID
7176 ClientCredentialsConf .BearerAuthClientSecret = clientSecret
7277 ClientCredentialsConf .BearerAuthScopes = scopes
7378
@@ -80,7 +85,7 @@ func main() {
8085 fmt .Println ("OAuthBearer subjects:" , subjects )
8186
8287 // Custom
83- customConf := schemaregistry .NewConfig (srUrl )
88+ customConf := schemaregistry .NewConfig (srURL )
8489 customConf .BearerAuthCredentialsSource = "CUSTOM"
8590 customConf .AuthenticationHeaderProvider = & CustomHeaderProvider {
8691 token : "customToken" ,
0 commit comments