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


##########
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:
   For cassandra permissions I think we don't want to set scope upfront in 
`CassandraPermissions`. Since we could grant `CREATE` keyspace scoped or table 
scoped. Instead we can use those permissions as baseline and recreate with 
their name `new StandardPermission(SELECT.name(), TABLE_SCOPE)` when required, 
wdyt



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