You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by zi...@apache.org on 2023/09/25 01:38:45 UTC
[pulsar-client-go] branch master updated: Support OAuth2 with scope field (#1097)
This is an automated email from the ASF dual-hosted git repository.
zike pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new ac9c1a63 Support OAuth2 with scope field (#1097)
ac9c1a63 is described below
commit ac9c1a6399336461d2d3ce1cdd31cac6debd5ed5
Author: Donglai Fu <la...@foxmail.com>
AuthorDate: Mon Sep 25 09:38:39 2023 +0800
Support OAuth2 with scope field (#1097)
### Motivation
Current `pulsaradmin` OAuth2 params don't support to input the scope field. Add a function to implement it. `ClientCredentialsFlowOptions` has a `AdditionalScopes` field to set scopes.
---
pulsaradmin/pkg/admin/auth/oauth2.go | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/pulsaradmin/pkg/admin/auth/oauth2.go b/pulsaradmin/pkg/admin/auth/oauth2.go
index 2864eae2..4bd15461 100644
--- a/pulsaradmin/pkg/admin/auth/oauth2.go
+++ b/pulsaradmin/pkg/admin/auth/oauth2.go
@@ -73,10 +73,15 @@ func NewAuthenticationOAuth2(issuer oauth2.Issuer, store store.Store) (*OAuth2Pr
// NewAuthenticationOAuth2WithDefaultFlow uses memory to save the grant
func NewAuthenticationOAuth2WithDefaultFlow(issuer oauth2.Issuer, keyFile string) (Provider, error) {
- st := store.NewMemoryStore()
- flow, err := oauth2.NewDefaultClientCredentialsFlow(oauth2.ClientCredentialsFlowOptions{
+ return NewAuthenticationOAuth2WithFlow(issuer, oauth2.ClientCredentialsFlowOptions{
KeyFile: keyFile,
})
+}
+
+func NewAuthenticationOAuth2WithFlow(
+ issuer oauth2.Issuer, flowOptions oauth2.ClientCredentialsFlowOptions) (Provider, error) {
+ st := store.NewMemoryStore()
+ flow, err := oauth2.NewDefaultClientCredentialsFlow(flowOptions)
if err != nil {
return nil, err
}