imbajin commented on code in PR #3388: URL: https://github.com/apache/hugegraph/pull/3388#discussion_r4575460523
########## hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/gremlin/GremlinRestExecutorFactory.java: ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (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.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hugegraph.api.gremlin; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.URI; +import java.net.UnknownHostException; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; + +import org.apache.hugegraph.auth.StandardAuthenticator; +import org.apache.hugegraph.auth.WsAndHttpBasicAuthHandler; +import org.apache.hugegraph.config.HugeConfig; +import org.apache.hugegraph.config.ServerOptions; +import org.apache.hugegraph.server.HugeGraphWsAndHttpChannelizer; +import org.apache.hugegraph.util.Log; +import org.apache.tinkerpop.gremlin.server.GremlinServer; +import org.apache.tinkerpop.gremlin.server.Settings; +import org.apache.tinkerpop.gremlin.server.auth.AllowAllAuthenticator; +import org.apache.tinkerpop.gremlin.util.ser.MessageTextSerializer; +import org.slf4j.Logger; + +public final class GremlinRestExecutorFactory { + + private static final Logger LOG = Log.logger(GremlinRestExecutorFactory.class); + + private GremlinRestExecutorFactory() { + } + + public static GremlinRestExecutor standalone(HugeConfig config) { + return new ForwardGremlinRestExecutor(config); + } + + public static GremlinRestExecutor create(HugeConfig config, GremlinServer server, + String restConfigFile) throws IOException { + Settings settings = server.getServerGremlinExecutor().getSettings(); + URI target = URI.create(config.get(ServerOptions.GREMLIN_SERVER_URL)); + if (!targetsLocalServer(target, settings)) { + return new ForwardGremlinRestExecutor(config); + } + String unsupported = unsupportedConfiguration(config, settings, restConfigFile); Review Comment: **‼️ Preserve required client-certificate authentication** When a local HTTPS Gremlin listener sets `ssl.needClientAuth: REQUIRE`, this check still selects embedded execution because it only considers the channelizer and application authentication. The previous forwarding connection had to pass the Gremlin listener TLS handshake, but the embedded path skips that handshake, so a caller accepted by REST can execute queries even when the forwarding client has no trusted certificate. Please retain forwarding when client certificates are required, unless an equivalent certificate check is enforced before embedded execution. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
