You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/01/01 17:31:21 UTC
[GitHub] [nifi] exceptionfactory opened a new pull request #5624: NIFI-7835 Add authenticated SOCKS and HTTP proxy support for SFTP
exceptionfactory opened a new pull request #5624:
URL: https://github.com/apache/nifi/pull/5624
#### Description of PR
NIFI-7835 Adds support for accessing SFTP servers through SOCKS 5 proxy servers that require authentication. Support for authenticated proxy server access also applies to HTTP proxy servers, resolving NIFI-7749.
NiFi SFTP components use SSHJ since version 1.10.0. SSHJ does not provide direct support for authenticated proxy server access, and the current NiFi implementation supports SOCKS and HTTP proxy access without authentication using a custom `ProxySocketFactory`. The `java.net.Authenticator` class does not support providing proxy username and password credentials for single instances of `java.net.Proxy`, instead requiring the use an `Authenticator` instance for the entire JVM using the `Authenticator.setDefault()` method. This approach is not suitable for NiFi components that may require different sets of credentials for different component instances.
This pull request integrates the [BrokeredSocketFactory](https://javadoc.io/doc/com.exceptionfactory.socketbroker/socketbroker/latest/com/exceptionfactory/socketbroker/BrokeredSocketFactory.html) from the [socketbroker](https://github.com/exceptionfactory/socketbroker) library to support authenticated access to SOCKS and HTTP proxy servers from NiFi SFTP components.
Runtime configurations can be tested using proxy servers that implement standard SOCKS 5 and HTTP CONNECT protocols. The following open source proxy servers can be configured with authentication for testing:
- [Dante](https://hub.docker.com/r/wernight/dante) SOCKS 5 Proxy
- [Tinyproxy](https://hub.docker.com/r/monokal/tinyproxy) HTTP Proxy
- [Squid](https://hub.docker.com/r/ubuntu/squid) HTTP Proxy
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [X] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [X] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [X] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
- [X] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
### For code changes:
- [X] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
- [X] Have you written or updated unit tests to verify your changes?
- [X] Have you verified that the full build is successful on JDK 8?
- [X] Have you verified that the full build is successful on JDK 11?
- [X] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
- [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
- [ ] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] exceptionfactory commented on a change in pull request #5624: NIFI-7835 Add authenticated SOCKS and HTTP proxy support for SFTP
Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5624:
URL: https://github.com/apache/nifi/pull/5624#discussion_r783195369
##########
File path: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
##########
@@ -141,6 +141,11 @@
<groupId>com.hierynomus</groupId>
<artifactId>sshj</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.exceptionfactory.socketbroker</groupId>
Review comment:
Thanks for checking. The library uses the standard Apache Software License 2.0 and does not include a separate NOTICE. According to the Apache Infrastructure guidelines, additional NOTICE details should not be necessary:
https://infra.apache.org/licensing-howto.html
> The NOTICE file is reserved for a certain subset of legally required notifications which are not satisfied by either the text of LICENSE or the presence of licensing information embedded within the bundled dependency. Aside from Apache-licensed dependencies which supply NOTICE files of their own, it is uncommon for a dependency to require additions to NOTICE.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] gresockj commented on a change in pull request #5624: NIFI-7835 Add authenticated SOCKS and HTTP proxy support for SFTP
Posted by GitBox <gi...@apache.org>.
gresockj commented on a change in pull request #5624:
URL: https://github.com/apache/nifi/pull/5624#discussion_r783188306
##########
File path: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/pom.xml
##########
@@ -141,6 +141,11 @@
<groupId>com.hierynomus</groupId>
<artifactId>sshj</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.exceptionfactory.socketbroker</groupId>
Review comment:
Is a NOTICE needed for this library?
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] greyp9 commented on a change in pull request #5624: NIFI-7835 Add authenticated SOCKS and HTTP proxy support for SFTP
Posted by GitBox <gi...@apache.org>.
greyp9 commented on a change in pull request #5624:
URL: https://github.com/apache/nifi/pull/5624#discussion_r780556770
##########
File path: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/socket/StandardSocketFactoryProvider.java
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.processors.standard.socket;
+
+import com.exceptionfactory.socketbroker.BrokeredSocketFactory;
+import com.exceptionfactory.socketbroker.configuration.AuthenticationCredentials;
+import com.exceptionfactory.socketbroker.configuration.BrokerConfiguration;
+import com.exceptionfactory.socketbroker.configuration.ProxyType;
+import com.exceptionfactory.socketbroker.configuration.StandardBrokerConfiguration;
+import com.exceptionfactory.socketbroker.configuration.StandardUsernamePasswordAuthenticationCredentials;
+import org.apache.nifi.proxy.ProxyConfiguration;
+
+import javax.net.SocketFactory;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.util.Objects;
+
+/**
+ * Standard implementation of Socket Factory Provider support authenticated or unauthenticated SOCKS or HTTP proxies
+ */
+public class StandardSocketFactoryProvider implements SocketFactoryProvider {
+ /**
+ * Get Socket Factory returns ProxySocketFactory without credentials and BrokeredSocketFactory with credentials
+ *
+ * @param proxyConfiguration Proxy Configuration required
+ * @return Socket Factory
+ */
+ @Override
+ public SocketFactory getSocketFactory(final ProxyConfiguration proxyConfiguration) {
+ Objects.requireNonNull(proxyConfiguration, "Proxy Configuration required");
+
+ final String userName = proxyConfiguration.getProxyUserName();
+ final SocketFactory socketFactory;
+ if (userName == null) {
+ final Proxy proxy = proxyConfiguration.createProxy();
+ socketFactory = new ProxySocketFactory(proxy);
+ } else {
+ final Proxy.Type proxyType = proxyConfiguration.getProxyType();
+ final ProxyType brokerProxyType = Proxy.Type.SOCKS == proxyType ? ProxyType.SOCKS5 : ProxyType.HTTP_CONNECT;
Review comment:
Would it make sense to extract a function here? Now there are two types; could others be added?
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] exceptionfactory commented on a change in pull request #5624: NIFI-7835 Add authenticated SOCKS and HTTP proxy support for SFTP
Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5624:
URL: https://github.com/apache/nifi/pull/5624#discussion_r780566046
##########
File path: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/socket/StandardSocketFactoryProvider.java
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.processors.standard.socket;
+
+import com.exceptionfactory.socketbroker.BrokeredSocketFactory;
+import com.exceptionfactory.socketbroker.configuration.AuthenticationCredentials;
+import com.exceptionfactory.socketbroker.configuration.BrokerConfiguration;
+import com.exceptionfactory.socketbroker.configuration.ProxyType;
+import com.exceptionfactory.socketbroker.configuration.StandardBrokerConfiguration;
+import com.exceptionfactory.socketbroker.configuration.StandardUsernamePasswordAuthenticationCredentials;
+import org.apache.nifi.proxy.ProxyConfiguration;
+
+import javax.net.SocketFactory;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.util.Objects;
+
+/**
+ * Standard implementation of Socket Factory Provider support authenticated or unauthenticated SOCKS or HTTP proxies
+ */
+public class StandardSocketFactoryProvider implements SocketFactoryProvider {
+ /**
+ * Get Socket Factory returns ProxySocketFactory without credentials and BrokeredSocketFactory with credentials
+ *
+ * @param proxyConfiguration Proxy Configuration required
+ * @return Socket Factory
+ */
+ @Override
+ public SocketFactory getSocketFactory(final ProxyConfiguration proxyConfiguration) {
+ Objects.requireNonNull(proxyConfiguration, "Proxy Configuration required");
+
+ final String userName = proxyConfiguration.getProxyUserName();
+ final SocketFactory socketFactory;
+ if (userName == null) {
+ final Proxy proxy = proxyConfiguration.createProxy();
+ socketFactory = new ProxySocketFactory(proxy);
+ } else {
+ final Proxy.Type proxyType = proxyConfiguration.getProxyType();
+ final ProxyType brokerProxyType = Proxy.Type.SOCKS == proxyType ? ProxyType.SOCKS5 : ProxyType.HTTP_CONNECT;
Review comment:
The `java.net.Proxy.Type` enumeration has `SOCKS`, `HTTP`, or `DIRECT`. The `DIRECT` case is handled above, so this block is limited to `SOCKS` or `HTTP`. For that reason, this approach should cover all cases for now.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] asfgit closed pull request #5624: NIFI-7835 Add authenticated SOCKS and HTTP proxy support for SFTP
Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #5624:
URL: https://github.com/apache/nifi/pull/5624
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] exceptionfactory commented on a change in pull request #5624: NIFI-7835 Add authenticated SOCKS and HTTP proxy support for SFTP
Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5624:
URL: https://github.com/apache/nifi/pull/5624#discussion_r780566046
##########
File path: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/socket/StandardSocketFactoryProvider.java
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.processors.standard.socket;
+
+import com.exceptionfactory.socketbroker.BrokeredSocketFactory;
+import com.exceptionfactory.socketbroker.configuration.AuthenticationCredentials;
+import com.exceptionfactory.socketbroker.configuration.BrokerConfiguration;
+import com.exceptionfactory.socketbroker.configuration.ProxyType;
+import com.exceptionfactory.socketbroker.configuration.StandardBrokerConfiguration;
+import com.exceptionfactory.socketbroker.configuration.StandardUsernamePasswordAuthenticationCredentials;
+import org.apache.nifi.proxy.ProxyConfiguration;
+
+import javax.net.SocketFactory;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.util.Objects;
+
+/**
+ * Standard implementation of Socket Factory Provider support authenticated or unauthenticated SOCKS or HTTP proxies
+ */
+public class StandardSocketFactoryProvider implements SocketFactoryProvider {
+ /**
+ * Get Socket Factory returns ProxySocketFactory without credentials and BrokeredSocketFactory with credentials
+ *
+ * @param proxyConfiguration Proxy Configuration required
+ * @return Socket Factory
+ */
+ @Override
+ public SocketFactory getSocketFactory(final ProxyConfiguration proxyConfiguration) {
+ Objects.requireNonNull(proxyConfiguration, "Proxy Configuration required");
+
+ final String userName = proxyConfiguration.getProxyUserName();
+ final SocketFactory socketFactory;
+ if (userName == null) {
+ final Proxy proxy = proxyConfiguration.createProxy();
+ socketFactory = new ProxySocketFactory(proxy);
+ } else {
+ final Proxy.Type proxyType = proxyConfiguration.getProxyType();
+ final ProxyType brokerProxyType = Proxy.Type.SOCKS == proxyType ? ProxyType.SOCKS5 : ProxyType.HTTP_CONNECT;
Review comment:
The `java.net.Proxy.Type` enumeration has `SOCKS`, `HTTP`, or `DIRECT`. The `DIRECT` case is handled above, so this block is limited to `SOCKS` or `HTTP`. For that reason, this approach should cover all cases for now.
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] greyp9 commented on a change in pull request #5624: NIFI-7835 Add authenticated SOCKS and HTTP proxy support for SFTP
Posted by GitBox <gi...@apache.org>.
greyp9 commented on a change in pull request #5624:
URL: https://github.com/apache/nifi/pull/5624#discussion_r780556770
##########
File path: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/socket/StandardSocketFactoryProvider.java
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.processors.standard.socket;
+
+import com.exceptionfactory.socketbroker.BrokeredSocketFactory;
+import com.exceptionfactory.socketbroker.configuration.AuthenticationCredentials;
+import com.exceptionfactory.socketbroker.configuration.BrokerConfiguration;
+import com.exceptionfactory.socketbroker.configuration.ProxyType;
+import com.exceptionfactory.socketbroker.configuration.StandardBrokerConfiguration;
+import com.exceptionfactory.socketbroker.configuration.StandardUsernamePasswordAuthenticationCredentials;
+import org.apache.nifi.proxy.ProxyConfiguration;
+
+import javax.net.SocketFactory;
+import java.net.InetSocketAddress;
+import java.net.Proxy;
+import java.util.Objects;
+
+/**
+ * Standard implementation of Socket Factory Provider support authenticated or unauthenticated SOCKS or HTTP proxies
+ */
+public class StandardSocketFactoryProvider implements SocketFactoryProvider {
+ /**
+ * Get Socket Factory returns ProxySocketFactory without credentials and BrokeredSocketFactory with credentials
+ *
+ * @param proxyConfiguration Proxy Configuration required
+ * @return Socket Factory
+ */
+ @Override
+ public SocketFactory getSocketFactory(final ProxyConfiguration proxyConfiguration) {
+ Objects.requireNonNull(proxyConfiguration, "Proxy Configuration required");
+
+ final String userName = proxyConfiguration.getProxyUserName();
+ final SocketFactory socketFactory;
+ if (userName == null) {
+ final Proxy proxy = proxyConfiguration.createProxy();
+ socketFactory = new ProxySocketFactory(proxy);
+ } else {
+ final Proxy.Type proxyType = proxyConfiguration.getProxyType();
+ final ProxyType brokerProxyType = Proxy.Type.SOCKS == proxyType ? ProxyType.SOCKS5 : ProxyType.HTTP_CONNECT;
Review comment:
Would it make sense to extract a function here? Now there are two types; could others be added?
--
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: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org