Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept for having a request filter based on host and port for PL request filtering by access type info #2477

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/schema-registry.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# listeners = listener_name://host_name:port
# EXAMPLE:
# listeners = PLAINTEXT://your.host.name:9092
listeners=http://0.0.0.0:8081
listeners=http://0.0.0.0:8081,http://0.0.0.0:8084

# Use this setting to specify the bootstrap servers for your Kafka cluster and it
# will be used both for selecting the leader schema registry instance and for storing the data for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.confluent.kafka.schemaregistry.exceptions.SchemaRegistryException;
import io.confluent.kafka.schemaregistry.rest.extensions.SchemaRegistryResourceExtension;
import io.confluent.kafka.schemaregistry.rest.filters.ContextFilter;
import io.confluent.kafka.schemaregistry.rest.filters.PLReqFilter;
import io.confluent.kafka.schemaregistry.rest.filters.RestCallMetricFilter;
import io.confluent.kafka.schemaregistry.rest.resources.CompatibilityResource;
import io.confluent.kafka.schemaregistry.rest.resources.ConfigResource;
Expand Down Expand Up @@ -107,6 +108,7 @@ public void setupResources(Configurable<?> config, SchemaRegistryConfig schemaRe
config.register(new ModeResource(schemaRegistry));
config.register(new ServerMetadataResource(schemaRegistry));
config.register(new ContextFilter());
config.register(new PLReqFilter());
config.register(new RestCallMetricFilter(
schemaRegistry.getMetricsContainer().getApiCallsSuccess(),
schemaRegistry.getMetricsContainer().getApiCallsFailure()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.confluent.kafka.schemaregistry.rest.filters;


import javax.annotation.Priority;
import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import java.io.IOException;

@PreMatching
@Priority(Priorities.ENTITY_CODER)
public class PLReqFilter implements ContainerRequestFilter {
public PLReqFilter() {}
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
System.out.println(requestContext.getUriInfo().getRequestUri().getPort());
System.out.println(requestContext.getUriInfo().getRequestUri().getHost());
}
}