drop AuthTLS option and use server TLSConfig option

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-04-20 12:22:43 +03:00
parent b0cad975e4
commit 683eb62973
2 changed files with 2 additions and 11 deletions

View File

@ -188,10 +188,8 @@ func (g *grpcServer) getMaxMsgSize() int {
} }
func (g *grpcServer) getCredentials() credentials.TransportCredentials { func (g *grpcServer) getCredentials() credentials.TransportCredentials {
if g.opts.Context != nil { if g.opts.TLSConfig != nil {
if v, ok := g.opts.Context.Value(tlsAuth{}).(*tls.Config); ok && v != nil { return credentials.NewTLS(g.opts.TLSConfig)
return credentials.NewTLS(v)
}
} }
return nil return nil
} }

View File

@ -2,7 +2,6 @@ package grpc
import ( import (
"context" "context"
"crypto/tls"
"github.com/unistack-org/micro/v3/server" "github.com/unistack-org/micro/v3/server"
"google.golang.org/grpc" "google.golang.org/grpc"
@ -12,7 +11,6 @@ import (
type codecsKey struct{} type codecsKey struct{}
type grpcOptions struct{} type grpcOptions struct{}
type maxMsgSizeKey struct{} type maxMsgSizeKey struct{}
type tlsAuth struct{}
type reflectionKey struct{} type reflectionKey struct{}
// gRPC Codec to be used to encode/decode requests for a given content type // 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 // Options to be used to configure gRPC options
func Options(opts ...grpc.ServerOption) server.Option { func Options(opts ...grpc.ServerOption) server.Option {
return setServerOption(grpcOptions{}, opts) return setServerOption(grpcOptions{}, opts)