You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "takraj (via GitHub)" <gi...@apache.org> on 2026/08/13 08:51:22 UTC

[PR] NIFI-16191: Add OAuth support for ConfluentSchemaRegistry controller service [nifi]

takraj opened a new pull request, #11534:
URL: https://github.com/apache/nifi/pull/11534

   <!-- 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. -->
   
   # Summary
   
   [NIFI-16191](https://issues.apache.org/jira/browse/NIFI-16191)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   - Pull request contains [commits signed](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) with a registered key indicating `Verified` status
   
   ### Pull Request Formatting
   
   - Pull Request based on current revision of the `main` branch
   - Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [x] Build completed using `./mvnw clean install -P contrib-check`
     - [x] JDK 21
     - [ ] JDK 25
   
   ### Licensing
   
   - [x] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [x] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [x] Documentation formatting appears as expected in rendered files
   


-- 
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


Re: [PR] NIFI-16191: Add OAuth support for ConfluentSchemaRegistry controller service [nifi]

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory merged PR #11534:
URL: https://github.com/apache/nifi/pull/11534


-- 
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


Re: [PR] NIFI-16191: Add OAuth support for ConfluentSchemaRegistry controller service [nifi]

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #11534:
URL: https://github.com/apache/nifi/pull/11534#discussion_r3866207982


##########
nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java:
##########
@@ -98,16 +100,38 @@ public RestSchemaRegistryClient(final List<String> baseUrls,
                                     final String password,
                                     final ComponentLog logger,
                                     final Map<String, String> httpHeaders) {
-        this.baseUrls = new ArrayList<>(baseUrls);
-        this.httpHeaders = new HashMap<>(httpHeaders);
+        this(baseUrls, timeoutMillis, sslContextProvider, logger, httpHeaders);
 
         if (StringUtils.isNoneBlank(username, password)) {
             final String credentials = BASIC_CREDENTIALS_FORMAT.formatted(username, password);
             final byte[] credentialsEncoded = credentials.getBytes(StandardCharsets.UTF_8);
             final String authorization = Base64.getEncoder().encodeToString(credentialsEncoded);
             final String basicAuthorization = BASIC_AUTHORIZATION_FORMAT.formatted(authorization);
-            this.httpHeaders.put(HttpHeaderName.AUTHORIZATION.getHeaderName(), basicAuthorization);
+            this.httpHeaders.putIfAbsent(HttpHeaderName.AUTHORIZATION.getHeaderName(), basicAuthorization);
         }
+    }
+
+    public RestSchemaRegistryClient(final List<String> baseUrls,
+                                    final int timeoutMillis,
+                                    final SSLContextProvider sslContextProvider,
+                                    final OAuth2AccessTokenProvider oauth2AccessTokenProvider,
+                                    final ComponentLog logger,
+                                    final Map<String, String> httpHeaders) {
+        this(baseUrls, timeoutMillis, sslContextProvider, logger, httpHeaders);
+
+        if (oauth2AccessTokenProvider != null) {
+            final String accessToken = oauth2AccessTokenProvider.getAccessDetails().getAccessToken();

Review Comment:
   Retrieving the Access Token once in the constructor will run into expiration issues over the lifecycle, so a different approach is needed.



-- 
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


Re: [PR] NIFI-16191: Add OAuth support for ConfluentSchemaRegistry controller service [nifi]

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on PR #11534:
URL: https://github.com/apache/nifi/pull/11534#issuecomment-5440569892

   > LGTM +1 Tested token refresh working properly as well.
   
   The functional approach looks good now, but I would like to see successful workflow builds before approving and merging


-- 
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


Re: [PR] NIFI-16191: Add OAuth support for ConfluentSchemaRegistry controller service [nifi]

Posted by "takraj (via GitHub)" <gi...@apache.org>.
takraj commented on code in PR #11534:
URL: https://github.com/apache/nifi/pull/11534#discussion_r3870178840


##########
nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java:
##########
@@ -98,16 +100,38 @@ public RestSchemaRegistryClient(final List<String> baseUrls,
                                     final String password,
                                     final ComponentLog logger,
                                     final Map<String, String> httpHeaders) {
-        this.baseUrls = new ArrayList<>(baseUrls);
-        this.httpHeaders = new HashMap<>(httpHeaders);
+        this(baseUrls, timeoutMillis, sslContextProvider, logger, httpHeaders);
 
         if (StringUtils.isNoneBlank(username, password)) {
             final String credentials = BASIC_CREDENTIALS_FORMAT.formatted(username, password);
             final byte[] credentialsEncoded = credentials.getBytes(StandardCharsets.UTF_8);
             final String authorization = Base64.getEncoder().encodeToString(credentialsEncoded);
             final String basicAuthorization = BASIC_AUTHORIZATION_FORMAT.formatted(authorization);
-            this.httpHeaders.put(HttpHeaderName.AUTHORIZATION.getHeaderName(), basicAuthorization);
+            this.httpHeaders.putIfAbsent(HttpHeaderName.AUTHORIZATION.getHeaderName(), basicAuthorization);
         }
+    }
+
+    public RestSchemaRegistryClient(final List<String> baseUrls,
+                                    final int timeoutMillis,
+                                    final SSLContextProvider sslContextProvider,
+                                    final OAuth2AccessTokenProvider oauth2AccessTokenProvider,
+                                    final ComponentLog logger,
+                                    final Map<String, String> httpHeaders) {
+        this(baseUrls, timeoutMillis, sslContextProvider, logger, httpHeaders);
+
+        if (oauth2AccessTokenProvider != null) {
+            final String accessToken = oauth2AccessTokenProvider.getAccessDetails().getAccessToken();

Review Comment:
   @exceptionfactory Good catch. I'll move this part to the `applyRequestHeaders()` then...



-- 
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


Re: [PR] NIFI-16191: Add OAuth support for ConfluentSchemaRegistry controller service [nifi]

Posted by "takraj (via GitHub)" <gi...@apache.org>.
takraj commented on code in PR #11534:
URL: https://github.com/apache/nifi/pull/11534#discussion_r3871146223


##########
nifi-extension-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java:
##########
@@ -98,16 +100,38 @@ public RestSchemaRegistryClient(final List<String> baseUrls,
                                     final String password,
                                     final ComponentLog logger,
                                     final Map<String, String> httpHeaders) {
-        this.baseUrls = new ArrayList<>(baseUrls);
-        this.httpHeaders = new HashMap<>(httpHeaders);
+        this(baseUrls, timeoutMillis, sslContextProvider, logger, httpHeaders);
 
         if (StringUtils.isNoneBlank(username, password)) {
             final String credentials = BASIC_CREDENTIALS_FORMAT.formatted(username, password);
             final byte[] credentialsEncoded = credentials.getBytes(StandardCharsets.UTF_8);
             final String authorization = Base64.getEncoder().encodeToString(credentialsEncoded);
             final String basicAuthorization = BASIC_AUTHORIZATION_FORMAT.formatted(authorization);
-            this.httpHeaders.put(HttpHeaderName.AUTHORIZATION.getHeaderName(), basicAuthorization);
+            this.httpHeaders.putIfAbsent(HttpHeaderName.AUTHORIZATION.getHeaderName(), basicAuthorization);
         }
+    }
+
+    public RestSchemaRegistryClient(final List<String> baseUrls,
+                                    final int timeoutMillis,
+                                    final SSLContextProvider sslContextProvider,
+                                    final OAuth2AccessTokenProvider oauth2AccessTokenProvider,
+                                    final ComponentLog logger,
+                                    final Map<String, String> httpHeaders) {
+        this(baseUrls, timeoutMillis, sslContextProvider, logger, httpHeaders);
+
+        if (oauth2AccessTokenProvider != null) {
+            final String accessToken = oauth2AccessTokenProvider.getAccessDetails().getAccessToken();

Review Comment:
   Done in ffea1b0



-- 
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