From dbb26617dc51c171e959bc5975a96a1f13f072f0 Mon Sep 17 00:00:00 2001 From: johnabass Date: Thu, 21 Nov 2024 11:45:26 -0800 Subject: [PATCH 1/3] added tlsState to every log message --- xhttp/xhttpserver/server.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xhttp/xhttpserver/server.go b/xhttp/xhttpserver/server.go index d6edc1e..02cd1fa 100644 --- a/xhttp/xhttpserver/server.go +++ b/xhttp/xhttpserver/server.go @@ -58,6 +58,9 @@ func NewServerChain(o Options, l *zap.Logger, fbs ...sallusthttp.FieldBuilder) a bs.Add(func(r *http.Request, l *zap.Logger) *zap.Logger { return l.With(zap.String("userAgent", r.UserAgent())) }) + bs.Add(func(r *http.Request, l *zap.Logger) *zap.Logger { + return l.With(connectionStateField("state", r.TLS)) + }) chain := alice.New( ResponseHeaders{Header: o.Header}.Then, @@ -73,10 +76,7 @@ func NewServerChain(o Options, l *zap.Logger, fbs ...sallusthttp.FieldBuilder) a func(next http.Handler) http.Handler { return http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) { requestLogger := bs.Build(request, l) - requestLogger.Info( - "tls info", - connectionStateField("state", request.TLS), - ) + requestLogger.Info("request received") next.ServeHTTP( response, From b35e293cf253ceeea9155f6e0f8928a9cf5954b7 Mon Sep 17 00:00:00 2001 From: johnabass Date: Thu, 21 Nov 2024 11:49:03 -0800 Subject: [PATCH 2/3] added trust output to new token generation --- token/factory.go | 1 + 1 file changed, 1 insertion(+) diff --git a/token/factory.go b/token/factory.go index 9ee6c6e..84160e3 100644 --- a/token/factory.go +++ b/token/factory.go @@ -68,6 +68,7 @@ func (f *factory) NewToken(ctx context.Context, r *Request) (string, error) { return "", err } + r.Logger.Info("new token", zap.Any("trust", merged[ClaimTrust])) token := jwt.NewWithClaims(f.method, jwt.MapClaims(merged)) pair := f.pair.Load().(key.Pair) token.Header["kid"] = pair.KID() From f2211d40ed969df251d44f62974825443820204b Mon Sep 17 00:00:00 2001 From: johnabass Date: Thu, 21 Nov 2024 11:50:31 -0800 Subject: [PATCH 3/3] chore: fixed panic in unit test --- token/factory_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/token/factory_test.go b/token/factory_test.go index 56b6851..d9f9a66 100644 --- a/token/factory_test.go +++ b/token/factory_test.go @@ -9,6 +9,7 @@ import ( "github.com/xmidt-org/themis/key" "github.com/xmidt-org/themis/random" + "go.uber.org/zap" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -72,7 +73,7 @@ func testNewFactorySuccess(t *testing.T) { require.NoError(err) require.NotNil(factory) - token, err := factory.NewToken(context.Background(), new(Request)) + token, err := factory.NewToken(context.Background(), &Request{Logger: zap.NewNop()}) require.NoError(err) assert.True(len(token) > 0) }