Skip to content

Commit

Permalink
Add support for confluent.cloud bearer token authentication (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpanetti authored Jun 22, 2024
1 parent cf0552b commit f0b70c2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion schemaRegistryClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net/url"
"regexp"
"strconv"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -739,7 +740,11 @@ func (client *SchemaRegistryClient) httpRequest(method, uri string, payload io.R
if len(client.credentials.username) > 0 && len(client.credentials.password) > 0 {
req.SetBasicAuth(client.credentials.username, client.credentials.password)
} else if len(client.credentials.bearerToken) > 0 {
req.Header.Add("Authorization", "Bearer "+client.credentials.bearerToken)
if strings.Contains(strings.ToLower(uri), "confluent.cloud") {
req.Header.Add("Authorization", "Basic "+client.credentials.bearerToken)
} else {
req.Header.Add("Authorization", "Bearer "+client.credentials.bearerToken)
}
}
}
req.Header.Set("Content-Type", contentType)
Expand Down

0 comments on commit f0b70c2

Please sign in to comment.