From 129dc0a6a6e103082beea61f906cf99ae7daac61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rold=C3=A1n=20Betancort?= Date: Tue, 23 Jan 2024 09:29:24 +0000 Subject: [PATCH] fixes broken gRPC reflection many clients continue to issue reflection calls as v1alpha. The authless reflection logic made the assumption v1alpha was deprecated and shouldn't be used. This changes the code so both v1alpha and v1 continue to be supported for the foreseeable future. --- reflection.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/reflection.go b/reflection.go index fc6ef54..092b568 100644 --- a/reflection.go +++ b/reflection.go @@ -4,6 +4,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/reflection" rpbv1 "google.golang.org/grpc/reflection/grpc_reflection_v1" + "google.golang.org/grpc/reflection/grpc_reflection_v1alpha" ) // NewAuthlessReflectionInterceptor creates a proxy GRPCServer which automatically converts @@ -26,12 +27,15 @@ func (ir interceptingRegistrar) GetServiceInfo() map[string]grpc.ServiceInfo { } func (ir interceptingRegistrar) RegisterService(desc *grpc.ServiceDesc, impl interface{}) { - // NOTE: This method is now being invoked for both v1 (handled below) and v1alpha, which is formally deprecated. - // Since the v1alpha handler is now internally typed, we only wrap the V1. reflectionSrvv1, ok := impl.(rpbv1.ServerReflectionServer) if ok { ir.delegate.RegisterService(desc, &authlessReflectionV1{ServerReflectionServer: reflectionSrvv1}) } + + reflectionSrvv1alpha, ok := impl.(grpc_reflection_v1alpha.ServerReflectionServer) + if ok { + ir.delegate.RegisterService(desc, &authlessReflectionV1Alpha{ServerReflectionServer: reflectionSrvv1alpha}) + } } type authlessReflectionV1 struct { @@ -39,3 +43,9 @@ type authlessReflectionV1 struct { rpbv1.ServerReflectionServer } + +type authlessReflectionV1Alpha struct { + IgnoreAuthMixin + + grpc_reflection_v1alpha.ServerReflectionServer +}