Skip to content

Commit

Permalink
Allow Logging Interceptor to be toggled by Message Logging Enabled Fl…
Browse files Browse the repository at this point in the history
…ag (#940)

* Update audit.logging.messageLoggingEnabled to be able to enable/disable logging interceptor

Previously the flag only toggled AuditLogger codebase

* Remove disable at AuditLogger for messageLoggingEnabled as it already disabled at the GrpcMessageInterceptor

* Remove legacy logging config file.
  • Loading branch information
mrzzy authored Sep 8, 2020
1 parent e58022a commit dfff314
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 0 additions & 5 deletions common/src/main/java/feast/common/logging/AuditLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import feast.common.logging.config.LoggingProperties.AuditLogProperties;
import feast.common.logging.entry.ActionAuditLogEntry;
import feast.common.logging.entry.AuditLogEntry;
import feast.common.logging.entry.AuditLogEntryKind;
import feast.common.logging.entry.LogResource;
import feast.common.logging.entry.LogResource.ResourceType;
import feast.common.logging.entry.MessageAuditLogEntry;
Expand Down Expand Up @@ -112,10 +111,6 @@ private static void log(Level level, AuditLogEntry entry) {
if (!properties.isEnabled()) {
return;
}
if (entry.getKind().equals(AuditLogEntryKind.MESSAGE)
&& !properties.isMessageLoggingEnabled()) {
return;
}

// Log event to audit log through enabled formats
String entryJSON = entry.toJSON();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import feast.common.auth.config.SecurityProperties.AuthenticationProperties;
import feast.common.auth.utils.AuthUtils;
import feast.common.logging.AuditLogger;
import feast.common.logging.config.LoggingProperties;
import feast.common.logging.entry.MessageAuditLogEntry;
import io.grpc.ForwardingServerCall.SimpleForwardingServerCall;
import io.grpc.ForwardingServerCallListener.SimpleForwardingServerCallListener;
Expand All @@ -48,18 +49,30 @@
@Component
public class GrpcMessageInterceptor implements ServerInterceptor {
private SecurityProperties securityProperties;
private LoggingProperties loggingProperties;

/**
* Construct GrpcMessageIntercetor. If provided securityProperties, will output the subject claim
* specified in securityProperties as identity in {@link MessageAuditLogEntry} instead.
* Construct GrpcMessageIntercetor.
*
* @param loggingProperties properties used to configure logging interceptor.
* @param securityProperties If provided, will output the subject claim specified in
* securityProperties as identity in {@link MessageAuditLogEntry} instead.
*/
@Autowired
public GrpcMessageInterceptor(@Nullable SecurityProperties securityProperties) {
public GrpcMessageInterceptor(
LoggingProperties loggingProperties, @Nullable SecurityProperties securityProperties) {
this.securityProperties = securityProperties;
this.loggingProperties = loggingProperties;
}

@Override
public <ReqT, RespT> Listener<ReqT> interceptCall(
ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
// Disable the message logging interceptor entirely if message logging is disabled.
if (!loggingProperties.getAudit().isMessageLoggingEnabled()) {
return next.startCall(call, headers);
}

MessageAuditLogEntry.Builder entryBuilder = MessageAuditLogEntry.newBuilder();
// default response/request message to empty proto in log entry.
// request could be empty when the client closes the connection before sending a request
Expand Down

0 comments on commit dfff314

Please sign in to comment.