hazmat345 commented on code in PR #9566:
URL: https://github.com/apache/nifi/pull/9566#discussion_r1881033400


##########
nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/security/authentication/jwt/JwtService.java:
##########
@@ -34,11 +34,13 @@
 import org.apache.nifi.registry.security.key.KeyService;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.GrantedAuthority;
 import org.springframework.stereotype.Service;
 
 import java.nio.charset.StandardCharsets;
-import java.util.Calendar;
+import java.util.*;

Review Comment:
   Sorry, IntelliJ insists on reverting this every time I update it. Fixed.



##########
nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/security/authentication/jwt/JwtService.java:
##########
@@ -82,6 +85,27 @@ public String getUserIdentityFromToken(final String 
base64EncodedToken) throws J
         }
     }
 
+    public Set<String> getUserGroupsFromToken(final String base64EncodedToken) 
throws JwtException {
+        // The library representations of the JWT should be kept internal to 
this service.
+        try {
+            final Jws<Claims> jws = 
parseTokenFromBase64EncodedString(base64EncodedToken);
+
+            if (jws == null) {
+                throw new JwtException("Unable to parse token");
+            }
+
+            @SuppressWarnings("unchecked")
+            ArrayList<String> groupsString = 
jws.getPayload().get(GROUPS_CLAIM, ArrayList.class);
+
+            return new HashSet<>(groupsString);
+        } catch (JwtException e) {
+            logger.debug("The Base64 encoded JWT: " + base64EncodedToken);

Review Comment:
   👍🏼 



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

Reply via email to