Skip to content

Commit

Permalink
Support OAuth2 with scope field (#1097)
Browse files Browse the repository at this point in the history
### 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.
  • Loading branch information
labuladong authored Sep 25, 2023
1 parent 7cf643b commit ac9c1a6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pulsaradmin/pkg/admin/auth/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit ac9c1a6

Please sign in to comment.