Skip to content

Commit

Permalink
Revert "Revert "Revert "fix: cors handling for precondition server (#…
Browse files Browse the repository at this point in the history
…9448) (#9456)"""

This reverts commit 511ecfe.
  • Loading branch information
rodesai committed Aug 25, 2022
1 parent cfae948 commit 8d258c9
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 361 deletions.
Expand Up @@ -37,7 +37,8 @@ public class KsqlCorsHandler implements Handler<RoutingContext> {
.asList("X-Requested-With", "Content-Type", "Accept", "Origin");
private static final List<String> EXCLUDED_PATH_PREFIXES = Collections.singletonList("/ws/");

static void setupCorsHandler(final KsqlRestConfig ksqlRestConfig, final Router router) {
static void setupCorsHandler(final Server server, final Router router) {
final KsqlRestConfig ksqlRestConfig = server.getConfig();
final String allowedOrigins = ksqlRestConfig
.getString(KsqlRestConfig.ACCESS_CONTROL_ALLOW_ORIGIN_CONFIG);
if (allowedOrigins.trim().isEmpty()) {
Expand Down
Expand Up @@ -18,7 +18,6 @@

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.confluent.ksql.api.util.ApiServerUtils;
import io.confluent.ksql.rest.server.KsqlRestConfig;
import io.confluent.ksql.rest.server.state.ServerState;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
Expand All @@ -36,17 +35,14 @@ public class PreconditionVerticle extends AbstractVerticle {
private final HttpServerOptions httpServerOptions;
private final ServerState serverState;
private HttpServer httpServer;
private KsqlRestConfig restConfig;

@SuppressFBWarnings(value = "EI_EXPOSE_REP2")
public PreconditionVerticle(
final HttpServerOptions httpServerOptions,
final ServerState serverState,
final KsqlRestConfig restConfig
final ServerState serverState
) {
this.httpServerOptions = Objects.requireNonNull(httpServerOptions);
this.serverState = Objects.requireNonNull(serverState, "serverState");
this.restConfig = Objects.requireNonNull(restConfig, "restConfig");
}

@Override
Expand All @@ -73,7 +69,6 @@ public void stop(final Promise<Void> stopPromise) {

private Router setupRouter() {
final Router router = Router.router(vertx);
KsqlCorsHandler.setupCorsHandler(restConfig, router);
router.route(HttpMethod.GET, "/chc/ready").handler(ApiServerUtils::chcHandler);
router.route(HttpMethod.GET, "/chc/live").handler(ApiServerUtils::chcHandler);
router.route().handler(new ServerStateHandler(serverState));
Expand Down
Expand Up @@ -121,7 +121,7 @@ private Router setupRouter() {
router.route().handler(new SniHandler());
}

KsqlCorsHandler.setupCorsHandler(server.getConfig(), router);
KsqlCorsHandler.setupCorsHandler(server, router);

// /chc endpoints need to be before server state handler but after CORS handler as they
// need to be usable from browser with cross origin policy
Expand Down
Expand Up @@ -83,8 +83,7 @@ public synchronized void start() {
createHttpServerOptions(config, listener.getHost(), listener.getPort(),
listener.getScheme().equalsIgnoreCase("https"),
idleConnectionTimeoutSeconds),
serverState,
config
serverState
);
vertx.deployVerticle(serverVerticle, vcf);
deployFutures.add(vcf);
Expand Down

0 comments on commit 8d258c9

Please sign in to comment.