@@ -21,6 +21,7 @@ import (
2121 "errors"
2222 "github.com/grepplabs/kafka-proxy/pkg/apis"
2323 gatewayclient "github.com/grepplabs/kafka-proxy/plugin/gateway-client/shared"
24+ gatewayserver "github.com/grepplabs/kafka-proxy/plugin/gateway-server/shared"
2425 localauth "github.com/grepplabs/kafka-proxy/plugin/local-auth/shared"
2526 "github.com/hashicorp/go-hclog"
2627 "github.com/hashicorp/go-plugin"
@@ -161,7 +162,7 @@ func Run(_ *cobra.Command, _ []string) {
161162 var ok bool
162163 passwordAuthenticator , ok = raw .(apis.PasswordAuthenticator )
163164 if ! ok {
164- logrus .Fatal (errors .New ("unsupported plugin type" ))
165+ logrus .Fatal (errors .New ("unsupported PasswordAuthenticator plugin type" ))
165166 }
166167 }
167168
@@ -181,7 +182,27 @@ func Run(_ *cobra.Command, _ []string) {
181182 var ok bool
182183 tokenProvider , ok = raw .(apis.TokenProvider )
183184 if ! ok {
184- logrus .Fatal (errors .New ("unsupported plugin type" ))
185+ logrus .Fatal (errors .New ("unsupported TokenProvider plugin type" ))
186+ }
187+ }
188+
189+ var tokenInfo apis.TokenInfo
190+ if c .Auth .Gateway .Server .Enable {
191+ client := NewGatewayServerPluginClient ()
192+ defer client .Kill ()
193+
194+ rpcClient , err := client .Client ()
195+ if err != nil {
196+ logrus .Fatal (err )
197+ }
198+ raw , err := rpcClient .Dispense ("tokenInfo" )
199+ if err != nil {
200+ logrus .Fatal (err )
201+ }
202+ var ok bool
203+ tokenInfo , ok = raw .(apis.TokenInfo )
204+ if ! ok {
205+ logrus .Fatal (errors .New ("unsupported TokenInfo plugin type" ))
185206 }
186207 }
187208
@@ -198,7 +219,7 @@ func Run(_ *cobra.Command, _ []string) {
198219 if err != nil {
199220 logrus .Fatal (err )
200221 }
201- proxyClient , err := proxy .NewClient (connset , c , listeners .GetNetAddressMapping , passwordAuthenticator , tokenProvider )
222+ proxyClient , err := proxy .NewClient (connset , c , listeners .GetNetAddressMapping , passwordAuthenticator , tokenProvider , tokenInfo )
202223 if err != nil {
203224 logrus .Fatal (err )
204225 }
@@ -300,7 +321,9 @@ func SetLogger() {
300321func NewGatewayClientPluginClient () * plugin.Client {
301322 return NewPluginClient (gatewayclient .Handshake , gatewayclient .PluginMap , c .Auth .Gateway .Client .LogLevel , c .Auth .Gateway .Client .Command , c .Auth .Gateway .Client .Parameters )
302323}
303-
324+ func NewGatewayServerPluginClient () * plugin.Client {
325+ return NewPluginClient (gatewayserver .Handshake , gatewayserver .PluginMap , c .Auth .Gateway .Server .LogLevel , c .Auth .Gateway .Server .Command , c .Auth .Gateway .Server .Parameters )
326+ }
304327func NewLocalAuthPluginClient () * plugin.Client {
305328 return NewPluginClient (localauth .Handshake , localauth .PluginMap , c .Auth .Local .LogLevel , c .Auth .Local .Command , c .Auth .Local .Parameters )
306329}
0 commit comments