From a2b420c3642a3e4dfefccf3a2ef5b57906206ed9 Mon Sep 17 00:00:00 2001 From: Sam Batschelet Date: Wed, 2 Jan 2019 15:54:40 -0500 Subject: [PATCH] auth: disable CommonName auth for gRPC-gateway Signed-off-by: Sam Batschelet --- auth/store.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/auth/store.go b/auth/store.go index 3fac7f5a6..2e07897da 100644 --- a/auth/store.go +++ b/auth/store.go @@ -981,10 +981,23 @@ func (as *authStore) AuthInfoFromTLS(ctx context.Context) *AuthInfo { cn := chain.Subject.CommonName plog.Debugf("found common name %s", cn) - return &AuthInfo{ + ai := &AuthInfo{ Username: cn, Revision: as.Revision(), } + md, ok := metadata.FromIncomingContext(ctx) + if !ok { + return nil + } + + // gRPC-gateway proxy request to etcd server includes Grpcgateway-Accept + // header. The proxy uses etcd client server certificate. If the certificate + // has a CommonName we should never use this for authentication. + if gw := md["grpcgateway-accept"]; len(gw) > 0 { + plog.Warningf("ignoring common name in gRPC-gateway proxy request %s", ai.Username) + return nil + } + return ai } }