sarankk commented on code in PR #179:
URL: https://github.com/apache/cassandra-sidecar/pull/179#discussion_r1943477391


##########
server/src/main/java/org/apache/cassandra/sidecar/acl/authorization/StandardPermission.java:
##########
@@ -47,13 +48,33 @@ public String name()
         return name;
     }
 
+    /**
+     * Sets resource scope for given permission.
+     *
+     * @param resourceScope scope of resource this permission checks or grants 
permission for.
+     * @return a reference to permission
+     */
+    public StandardPermission withScope(ResourceScope resourceScope)
+    {
+        this.resourceScope = resourceScope;
+        return this;
+    }
+
+    @Override
+    public ResourceScope resourceScope()
+    {
+        return resourceScope;
+    }
+
     @Override
     public Authorization toAuthorization(String resource)
     {
         PermissionBasedAuthorization authorization = 
PermissionBasedAuthorization.create(name);
         if (isNotEmpty(resource))
         {
-            authorization.setResource(resource);
+            ResourceScope resourceScope = resourceScope();
+            String resolvedResource = resourceScope != null ? 
resourceScope.resolveWithResource(resource) : resource;

Review Comment:
   When we read permissions from database we wont know the scope of permission, 
we will only know exact resource. Hence we should allow resource scope to be 
null, since we use same permission class on both verification and retrieval 
side. Also for `CompositePermission` I think we should allow scope to be `null`



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to