From 683eb62973072a5457ea93d00552b7d513b5e772 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Tue, 20 Apr 2021 12:22:43 +0300 Subject: [PATCH] drop AuthTLS option and use server TLSConfig option Signed-off-by: Vasiliy Tolstov --- grpc.go | 6 ++---- options.go | 7 ------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/grpc.go b/grpc.go index 4130515..a4a267c 100644 --- a/grpc.go +++ b/grpc.go @@ -188,10 +188,8 @@ func (g *grpcServer) getMaxMsgSize() int { } func (g *grpcServer) getCredentials() credentials.TransportCredentials { - if g.opts.Context != nil { - if v, ok := g.opts.Context.Value(tlsAuth{}).(*tls.Config); ok && v != nil { - return credentials.NewTLS(v) - } + if g.opts.TLSConfig != nil { + return credentials.NewTLS(g.opts.TLSConfig) } return nil } diff --git a/options.go b/options.go index 3b086f5..d121476 100644 --- a/options.go +++ b/options.go @@ -2,7 +2,6 @@ package grpc import ( "context" - "crypto/tls" "github.com/unistack-org/micro/v3/server" "google.golang.org/grpc" @@ -12,7 +11,6 @@ import ( type codecsKey struct{} type grpcOptions struct{} type maxMsgSizeKey struct{} -type tlsAuth struct{} type reflectionKey struct{} // gRPC Codec to be used to encode/decode requests for a given content type @@ -30,11 +28,6 @@ func Codec(contentType string, c encoding.Codec) server.Option { } } -// AuthTLS should be used to setup a secure authentication using TLS -func AuthTLS(t *tls.Config) server.Option { - return setServerOption(tlsAuth{}, t) -} - // Options to be used to configure gRPC options func Options(opts ...grpc.ServerOption) server.Option { return setServerOption(grpcOptions{}, opts)