Skip to content

Instantly share code, notes, and snippets.

@purplefox
Created May 12, 2020 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purplefox/99d387a4c8ebafdc8fe7ca37a819cd7f to your computer and use it in GitHub Desktop.
Save purplefox/99d387a4c8ebafdc8fe7ca37a819cd7f to your computer and use it in GitHub Desktop.
/*
* Copyright 2020 Confluent Inc.
*
* Licensed under the Confluent Community License (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.confluent.io/confluent-community-license
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package io.confluent.ksql.api.server;
import io.vertx.core.Handler;
import io.vertx.core.net.SocketAddress;
import io.vertx.ext.web.RoutingContext;
public class InternalEndpointHandler implements Handler<RoutingContext> {
@Override
public void handle(final RoutingContext routingContext) {
final SocketAddress localAddress = routingContext.request().connection().localAddress();
if (!isFromInternalListener(localAddress)) {
routingContext.fail(400,
new KsqlApiException("Can't call internal endpoint on public listener",
ErrorCodes.ERROR_CODE_INTERNAL_ONLY));
} else {
routingContext.next();
}
}
private boolean isFromInternalListener(final SocketAddress socketAddress) {
// TODO check address against set of internal listeners
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment