You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ex...@apache.org on 2023/08/23 21:26:44 UTC

[nifi] branch support/nifi-1.x updated (e99a4259f3 -> 85ec0d9163)

This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a change to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git


    from e99a4259f3 NIFI-11480 add option to group PutElasticsearchRecord errors by Elasticsearch _bulk error type
     new e3bead383c NIFI-11924 Removed unused import in HDFSResourceInputStream
     new 85ec0d9163 NIFI-11912 Added Proxy support to StandardOauth2AccessTokenProvider

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../resource/hadoop/HDFSResourceInputStream.java   |  1 -
 .../nifi-oauth2-provider-service/pom.xml           |  5 +++++
 .../oauth2/StandardOauth2AccessTokenProvider.java  | 25 +++++++++++++++++++++-
 3 files changed, 29 insertions(+), 2 deletions(-)


[nifi] 02/02: NIFI-11912 Added Proxy support to StandardOauth2AccessTokenProvider

Posted by ex...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git

commit 85ec0d91637ffa7ae7aba744a529a0bb1f866997
Author: Nandor Soma Abonyi <ns...@apache.org>
AuthorDate: Sat Aug 5 01:33:04 2023 +0200

    NIFI-11912 Added Proxy support to StandardOauth2AccessTokenProvider
    
    This closes #7609
    
    Signed-off-by: David Handermann <ex...@apache.org>
    (cherry picked from commit e9b62f7b835569e2ee29e00aa897a3fb2ccf2688)
---
 .../nifi-oauth2-provider-service/pom.xml           |  5 +++++
 .../oauth2/StandardOauth2AccessTokenProvider.java  | 25 +++++++++++++++++++++-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/pom.xml b/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/pom.xml
index c8b2b21e90..154b764f32 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/pom.xml
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/pom.xml
@@ -35,6 +35,11 @@
             <artifactId>nifi-api</artifactId>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.nifi</groupId>
+            <artifactId>nifi-proxy-configuration-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
         <dependency>
             <groupId>org.apache.nifi</groupId>
             <artifactId>nifi-utils</artifactId>
diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java b/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java
index 3062e887ad..599bab079a 100644
--- a/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java
+++ b/nifi-nar-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java
@@ -42,12 +42,15 @@ import org.apache.nifi.expression.ExpressionLanguageScope;
 import org.apache.nifi.logging.ComponentLog;
 import org.apache.nifi.processor.exception.ProcessException;
 import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.proxy.ProxyConfiguration;
+import org.apache.nifi.proxy.ProxySpec;
 import org.apache.nifi.ssl.SSLContextService;
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.X509TrustManager;
 import java.io.IOException;
 import java.io.UncheckedIOException;
+import java.net.Proxy;
 import java.time.Instant;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -205,6 +208,8 @@ public class StandardOauth2AccessTokenProvider extends AbstractControllerService
         .dependsOn(SSL_CONTEXT)
         .build();
 
+    private static final ProxySpec[] PROXY_SPECS = { ProxySpec.HTTP_AUTH };
+
     private static final List<PropertyDescriptor> PROPERTIES = Collections.unmodifiableList(Arrays.asList(
         AUTHORIZATION_SERVER_URL,
         CLIENT_AUTHENTICATION_STRATEGY,
@@ -219,7 +224,8 @@ public class StandardOauth2AccessTokenProvider extends AbstractControllerService
         AUDIENCE,
         REFRESH_WINDOW,
         SSL_CONTEXT,
-        HTTP_PROTOCOL_STRATEGY
+        HTTP_PROTOCOL_STRATEGY,
+        ProxyConfiguration.createProxyConfigPropertyDescriptor(false, PROXY_SPECS)
     ));
 
     private static final String AUTHORIZATION_HEADER = "Authorization";
@@ -302,6 +308,8 @@ public class StandardOauth2AccessTokenProvider extends AbstractControllerService
                 .build());
         }
 
+        ProxyConfiguration.validateProxySpec(validationContext, validationResults, PROXY_SPECS);
+
         return validationResults;
     }
 
@@ -315,6 +323,21 @@ public class StandardOauth2AccessTokenProvider extends AbstractControllerService
             clientBuilder.sslSocketFactory(sslContext.getSocketFactory(), trustManager);
         }
 
+        final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context);
+
+        final Proxy proxy = proxyConfig.createProxy();
+        if (!Proxy.Type.DIRECT.equals(proxy.type())) {
+            clientBuilder.proxy(proxy);
+            if (proxyConfig.hasCredential()) {
+                clientBuilder.proxyAuthenticator((route, response) -> {
+                    final String credential = Credentials.basic(proxyConfig.getProxyUserName(), proxyConfig.getProxyUserPassword());
+                    return response.request().newBuilder()
+                                   .header("Proxy-Authorization", credential)
+                                   .build();
+                });
+            }
+        }
+
         final HttpProtocolStrategy httpProtocolStrategy = HttpProtocolStrategy.valueOf(context.getProperty(HTTP_PROTOCOL_STRATEGY).getValue());
         clientBuilder.protocols(httpProtocolStrategy.getProtocols());
 


[nifi] 01/02: NIFI-11924 Removed unused import in HDFSResourceInputStream

Posted by ex...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git

commit e3bead383c8a39357f5a273b6762ad147f561dea
Author: exceptionfactory <ex...@apache.org>
AuthorDate: Wed Aug 23 16:25:48 2023 -0500

    NIFI-11924 Removed unused import in HDFSResourceInputStream
    
    Signed-off-by: David Handermann <ex...@apache.org>
---
 .../org/apache/nifi/flow/resource/hadoop/HDFSResourceInputStream.java    | 1 -
 1 file changed, 1 deletion(-)

diff --git a/nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/flow/resource/hadoop/HDFSResourceInputStream.java b/nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/flow/resource/hadoop/HDFSResourceInputStream.java
index 8003207c20..67d458bcc4 100644
--- a/nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/flow/resource/hadoop/HDFSResourceInputStream.java
+++ b/nifi-nar-bundles/nifi-hadoop-bundle/nifi-hdfs-processors/src/main/java/org/apache/nifi/flow/resource/hadoop/HDFSResourceInputStream.java
@@ -22,7 +22,6 @@ import org.apache.nifi.processors.hadoop.HDFSResourceHelper;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.OutputStream;
 
 final class HDFSResourceInputStream extends InputStream {
     private final FileSystem fileSystem;