You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/05/14 20:30:16 UTC

[GitHub] [incubator-druid] jon-wei commented on a change in pull request #7635: Add simpler permissions option to BasicAuthorizer GET APIs

jon-wei commented on a change in pull request #7635: Add simpler permissions option to BasicAuthorizer GET APIs
URL: https://github.com/apache/incubator-druid/pull/7635#discussion_r283986693
 
 

 ##########
 File path: extensions-core/druid-basic-security/src/main/java/org/apache/druid/security/basic/authorization/endpoint/CoordinatorBasicAuthorizerResourceHandler.java
 ##########
 @@ -353,25 +355,65 @@ private Response getUserFull(String authorizerName, String userName)
         throw new BasicSecurityDBResourceException("User [%s] does not exist.", userName);
       }
 
-      Set<BasicAuthorizerRole> roles = new HashSet<>();
-      for (String roleName : user.getRoles()) {
-        BasicAuthorizerRole role = roleMap.get(roleName);
-        if (role == null) {
-          log.error("User [%s] had role [%s], but role was not found.", userName, roleName);
-        } else {
-          roles.add(role);
-        }
+      if (simplifyPermissions) {
+        Set<BasicAuthorizerRoleSimplifiedPermissions> roles = getRolesForUserWithSimplifiedPermissions(user, roleMap);
+        BasicAuthorizerUserFullSimplifiedPermissions fullUser = new BasicAuthorizerUserFullSimplifiedPermissions(
+            userName,
+            roles
+        );
+        return Response.ok(fullUser).build();
+      } else {
+        Set<BasicAuthorizerRole> roles = getRolesForUser(user, roleMap);
+        BasicAuthorizerUserFull fullUser = new BasicAuthorizerUserFull(userName, roles);
+        return Response.ok(fullUser).build();
       }
-
-      BasicAuthorizerUserFull fullUser = new BasicAuthorizerUserFull(userName, roles);
-      return Response.ok(fullUser).build();
     }
     catch (BasicSecurityDBResourceException e) {
       return makeResponseForBasicSecurityDBResourceException(e);
     }
   }
 
-  private Response getRoleSimple(String authorizerName, String roleName)
+  private Set<BasicAuthorizerRoleSimplifiedPermissions> getRolesForUserWithSimplifiedPermissions(
+      BasicAuthorizerUser user,
+      Map<String, BasicAuthorizerRole> roleMap
+  )
+  {
+    Set<BasicAuthorizerRoleSimplifiedPermissions> roles = new HashSet<>();
+    for (String roleName : user.getRoles()) {
+      BasicAuthorizerRole role = roleMap.get(roleName);
+      if (role == null) {
+        log.error("User [%s] had role [%s], but role was not found.", user.getName(), roleName);
 
 Review comment:
   Updated message

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org