Skip to content

Commit

Permalink
feat: add "disabled" auth class
Browse files Browse the repository at this point in the history
  • Loading branch information
flowchartsman committed Jul 27, 2023
1 parent 756acd8 commit feace75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ func NewClient(config ClientConfig) (Client, error) {
if err != nil {
return nil, fmt.Errorf("auth provider: %w", err)
}
clientTransport = authTransport
if authTransport != nil {
clientTransport = authTransport
}
}

return &pulsarClient{
Expand Down
16 changes: 10 additions & 6 deletions client_auth_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import (

// The following are the valid values for pluginName in calls to [AuthProviderPlugin]
const (
AuthPluginTLS = "tls"
AuthPluginClassTLS = "org.apache.pulsar.client.impl.auth.AuthenticationTls"
AuthPluginOAuth2 = "oauth2"
AuthPluginClassOAuth2 = "org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2"
AuthPluginToken = "token"
AuthPluginClassToken = "org.apache.pulsar.client.impl.auth.AuthenticationToken"
AuthPluginTLS = "tls"
AuthPluginClassTLS = "org.apache.pulsar.client.impl.auth.AuthenticationTls"
AuthPluginOAuth2 = "oauth2"
AuthPluginClassOAuth2 = "org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2"
AuthPluginToken = "token"
AuthPluginClassToken = "org.apache.pulsar.client.impl.auth.AuthenticationToken"
AuthPluginDisabled = "disabled"
AuthPluginClassDisabled = "org.apache.pulsar.client.impl.auth.AuthenticationDisabled"
)

// AuthProvider is a function that receives a default HTTP transport and returns
Expand Down Expand Up @@ -56,6 +58,8 @@ func AuthProviderPlugin(pluginName string, authParams string) AuthProvider {
}
return auth.NewOauth2Provider(params.IssuerURL, params.Audience,
params.Scope, params.ClientID, params.PrivateKey, transport)
case AuthPluginDisabled, AuthPluginClassDisabled:
return nil, nil
}
return nil, fmt.Errorf("unknown AuthPlugin %q", pluginName)
}
Expand Down

0 comments on commit feace75

Please sign in to comment.