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

mcgilman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 5a6bee2154 NIFI-13602 Corrected Logout Supported Status for Clustered 
User (#9127)
5a6bee2154 is described below

commit 5a6bee2154c73eb542dc85271f276b5a4ce1e55c
Author: David Handermann <[email protected]>
AuthorDate: Wed Jul 31 10:06:25 2024 -0500

    NIFI-13602 Corrected Logout Supported Status for Clustered User (#9127)
    
    - Set CurrentUserEntity.logoutSupported based on local authentication 
instead of replicated and merged responses
    
    This closes #9127
---
 .../java/org/apache/nifi/web/api/FlowResource.java | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
index 4b29015ab3..dfe6399d11 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/FlowResource.java
@@ -144,7 +144,6 @@ import jakarta.ws.rs.Path;
 import jakarta.ws.rs.PathParam;
 import jakarta.ws.rs.Produces;
 import jakarta.ws.rs.QueryParam;
-import jakarta.ws.rs.WebApplicationException;
 import jakarta.ws.rs.core.HttpHeaders;
 import jakarta.ws.rs.core.MediaType;
 import jakarta.ws.rs.core.Response;
@@ -341,20 +340,19 @@ public class FlowResource extends ApplicationResource {
 
         authorizeFlow();
 
+        final CurrentUserEntity entity;
         if (isReplicateRequest()) {
-            return replicate(HttpMethod.GET);
-        }
-
-        // note that the cluster manager will handle this request directly
-        final NiFiUser user = NiFiUserUtils.getNiFiUser();
-        if (user == null) {
-            throw new WebApplicationException(new Throwable("Unable to access 
details for current user."));
+            try (Response replicatedResponse = replicate(HttpMethod.GET)) {
+                final CurrentUserEntity replicatedCurrentUserEntity = 
(CurrentUserEntity) replicatedResponse.getEntity();
+                final CurrentUserEntity currentUserEntity = 
serviceFacade.getCurrentUser();
+                // Set Logout Supported based on local client information 
instead of replicated and merged responses
+                
replicatedCurrentUserEntity.setLogoutSupported(currentUserEntity.isLogoutSupported());
+                entity = replicatedCurrentUserEntity;
+            }
+        } else {
+            entity = serviceFacade.getCurrentUser();
         }
 
-        // create the response entity
-        final CurrentUserEntity entity = serviceFacade.getCurrentUser();
-
-        // generate the response
         return generateOkResponse(entity).build();
     }
 

Reply via email to