Skip to content

Commit

Permalink
Remove redundant audit logging (flyteorg#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
katrogan authored Mar 15, 2022
1 parent 735b59c commit 09db4d3
Show file tree
Hide file tree
Showing 16 changed files with 14 additions and 797 deletions.
18 changes: 14 additions & 4 deletions auth/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (

"golang.org/x/oauth2"

"github.com/flyteorg/flyteadmin/pkg/audit"
"github.com/flyteorg/flyteadmin/pkg/common"
"google.golang.org/grpc/peer"

Expand All @@ -35,6 +34,13 @@ const (

type HTTPRequestToMetadataAnnotator func(ctx context.Context, request *http.Request) metadata.MD

type AuthenticatedClientMeta struct {
ClientIds []string
TokenIssuedAt time.Time
ClientIP string
Subject string
}

func RegisterHandlers(ctx context.Context, handler interfaces.HandlerRegisterer, authCtx interfaces.AuthenticationContext) {
// Add HTTP handlers for OAuth2 endpoints
handler.HandleFunc("/login", RefreshTokensIfExists(ctx, authCtx,
Expand Down Expand Up @@ -180,7 +186,11 @@ func AuthenticationLoggingInterceptor(ctx context.Context, req interface{}, info
// Invoke 'handler' to use your gRPC server implementation and get
// the response.
identityContext := IdentityContextFromContext(ctx)
logger.Debugf(ctx, "gRPC server info in logging interceptor [%s] method [%s]\n", identityContext.UserID(), info.FullMethod)
var emailPlaceholder string
if len(identityContext.UserInfo().GetEmail()) > 0 {
emailPlaceholder = fmt.Sprintf(" (%s) ", identityContext.UserInfo().GetEmail())
}
logger.Debugf(ctx, "gRPC server info in logging interceptor [%s]%smethod [%s]\n", identityContext.UserID(), emailPlaceholder, info.FullMethod)
return handler(ctx, req)
}

Expand Down Expand Up @@ -214,7 +224,7 @@ func SetContextForIdentity(ctx context.Context, identityContext interfaces.Ident
email := identityContext.UserInfo().GetEmail()
newCtx := identityContext.WithContext(ctx)
if len(email) > 0 {
newCtx = WithUserEmail(newCtx, identityContext.UserID())
newCtx = WithUserEmail(newCtx, email)
}

return WithAuditFields(newCtx, identityContext.UserID(), []string{identityContext.AppID()}, identityContext.AuthenticatedAt())
Expand Down Expand Up @@ -263,7 +273,7 @@ func WithAuditFields(ctx context.Context, subject string, clientIds []string, to
if ok {
clientIP = peerInfo.Addr.String()
}
return context.WithValue(ctx, common.AuditFieldsContextKey, audit.AuthenticatedClientMeta{
return context.WithValue(ctx, common.AuditFieldsContextKey, AuthenticatedClientMeta{
ClientIds: clientIds,
TokenIssuedAt: tokenIssuedAt,
ClientIP: clientIP,
Expand Down
12 changes: 0 additions & 12 deletions pkg/audit/common.go

This file was deleted.

96 changes: 0 additions & 96 deletions pkg/audit/log.go

This file was deleted.

36 changes: 0 additions & 36 deletions pkg/audit/log_test.go

This file was deleted.

55 changes: 0 additions & 55 deletions pkg/audit/message.go

This file was deleted.

93 changes: 0 additions & 93 deletions pkg/audit/util.go

This file was deleted.

Loading

0 comments on commit 09db4d3

Please sign in to comment.