From 0e38e5716e8b9aaf0de3d9e22828276e200b5d01 Mon Sep 17 00:00:00 2001 From: bachmanity1 Date: Fri, 1 Mar 2024 19:02:54 +0900 Subject: [PATCH] allow specifying scopes in oauth config --- cmd/kaf/oauth.go | 1 + examples/sasl_ssl_oauth.yaml | 3 +++ pkg/config/config.go | 17 +++++++++-------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cmd/kaf/oauth.go b/cmd/kaf/oauth.go index ba2c1354..3a753d25 100644 --- a/cmd/kaf/oauth.go +++ b/cmd/kaf/oauth.go @@ -55,6 +55,7 @@ func newTokenProvider() *tokenProvider { ClientID: cluster.SASL.ClientID, ClientSecret: cluster.SASL.ClientSecret, TokenURL: cluster.SASL.TokenURL, + Scopes: cluster.SASL.Scopes, }, staticToken: false, } diff --git a/examples/sasl_ssl_oauth.yaml b/examples/sasl_ssl_oauth.yaml index bab63af9..cc25ac21 100644 --- a/examples/sasl_ssl_oauth.yaml +++ b/examples/sasl_ssl_oauth.yaml @@ -7,6 +7,9 @@ clusters: clientID: my_client_oauth clientSecret: my_secret_oauth tokenURL: https//some.token.endpoint.com/token + scopes: + - scope1 + - scope2 TLS: insecure: true security-protocol: SASL_SSL diff --git a/pkg/config/config.go b/pkg/config/config.go index aaec6c5f..20935098 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -10,14 +10,15 @@ import ( ) type SASL struct { - Mechanism string `yaml:"mechanism"` - Username string `yaml:"username"` - Password string `yaml:"password"` - ClientID string `yaml:"clientID"` - ClientSecret string `yaml:"clientSecret"` - TokenURL string `yaml:"tokenURL"` - Token string `yaml:"token"` - Version int16 `yaml:"version"` + Mechanism string `yaml:"mechanism"` + Username string `yaml:"username"` + Password string `yaml:"password"` + ClientID string `yaml:"clientID"` + ClientSecret string `yaml:"clientSecret"` + TokenURL string `yaml:"tokenURL"` + Scopes []string `yaml:"scopes"` + Token string `yaml:"token"` + Version int16 `yaml:"version"` } type TLS struct {