Skip to content

Commit

Permalink
Merge pull request #64 from authzed/fix-broken-v1alpha-grpc-reflection
Browse files Browse the repository at this point in the history
fixes broken gRPC reflection
  • Loading branch information
vroldanbet authored Jan 23, 2024
2 parents 4286bb1 + 129dc0a commit 2ea1e3d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions reflection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,16 +27,25 @@ 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 {
IgnoreAuthMixin

rpbv1.ServerReflectionServer
}

type authlessReflectionV1Alpha struct {
IgnoreAuthMixin

grpc_reflection_v1alpha.ServerReflectionServer
}

0 comments on commit 2ea1e3d

Please sign in to comment.