kevdoran commented on code in PR #11094: URL: https://github.com/apache/nifi/pull/11094#discussion_r3028583958
########## nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/replication/ReplicationHeaderUtils.java: ########## @@ -0,0 +1,148 @@ +/* + * 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.nifi.cluster.coordination.http.replication; + +import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.authorization.user.NiFiUser; +import org.apache.nifi.web.security.ProxiedEntitiesUtils; +import org.apache.nifi.web.security.http.SecurityCookieName; +import org.apache.nifi.web.security.http.SecurityHeader; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Shared header-preparation logic for cluster request replication. Both {@link ThreadPoolRequestReplicator} + * and {@link StandardUploadRequestReplicator} use these utilities so that credential stripping, proxied-entity + * injection, and replication-header sanitisation follow the same policy. + */ +public final class ReplicationHeaderUtils { + + private static final Logger logger = LoggerFactory.getLogger(ReplicationHeaderUtils.class); + + private static final String COOKIE_HEADER = "Cookie"; + private static final String HOST_HEADER = "Host"; + + /** + * Headers that must not be forwarded because they are hop-by-hop or describe the original + * transport framing rather than the replicated request. + * + * <p>Must stay in sync with + * {@link org.apache.nifi.cluster.coordination.http.replication.client.StandardHttpReplicationClient#DISALLOWED_HEADERS StandardHttpReplicationClient.DISALLOWED_HEADERS}. + */ + static final Set<String> HOP_BY_HOP_HEADERS = Set.of( + "connection", "content-length", "transfer-encoding", "expect", "host", "upgrade" Review Comment: Good call, `content-encoding` and `te` (transfer encoding) headers from the original http request also need to be stripped when replicating. -- 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]
