You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
STAR-564 Check only MODIFY on base when updating table with MV (#17)
If a user has only MODIFY permission on a table and there is a
materialized view built on the same table an insert will fail
with the following error:
Unauthorized: Error from server: code=2100 [Unauthorized]
Only base MODIFY permission is required to update base with MV.
Co-authored-by: Zhao Yang <[email protected]>
(cherry picked from commit 55dad39)
cassandra.execute("GRANT ALTER ON ks.cf TO cathy")
566
572
cathy.execute(create_mv)
567
573
568
-
# TRY SELECT MV without SELECT permission on base table
569
-
assert_unauthorized(cathy, "SELECT * FROM ks.mv1", "User cathy has no SELECT permission on <table ks.cf> or any of its parents")
574
+
# Try MODIFY base without WRITE permission on base
575
+
assert_unauthorized(cathy, "INSERT INTO ks.cf(id, value) VALUES(1, '1')", "User cathy has no MODIFY permission on <table ks.cf> or any of its parents")
570
576
571
-
# Grant SELECT permission and CREATE MV
572
-
cassandra.execute("GRANT SELECT ON ks.cf TO cathy")
573
-
cathy.execute("SELECT * FROM ks.mv1")
577
+
ifself.cluster.version() >=LooseVersion('4.0'):
578
+
# From 4.0 onward, only base MODIFY permission is required to update base with MV
579
+
# Grant WRITE permission on Base
580
+
cassandra.execute("GRANT MODIFY ON ks.cf TO cathy")
581
+
cathy.execute("INSERT INTO ks.cf(id, value) VALUES(1, '1')")
582
+
583
+
# TRY SELECT MV without SELECT permission on base table
584
+
assert_unauthorized(cathy, "SELECT * FROM ks.cf", "User cathy has no SELECT permission on <table ks.cf> or any of its parents")
585
+
assert_unauthorized(cathy, "SELECT * FROM ks.mv1", "User cathy has no SELECT permission on <table ks.cf> or any of its parents")
586
+
587
+
# Grant SELECT permission
588
+
cassandra.execute("GRANT SELECT ON ks.cf TO cathy")
589
+
assert_one(cathy, "SELECT * FROM ks.cf", [1, '1'])
590
+
assert_one(cathy, "SELECT * FROM ks.mv1", ['1', 1])
591
+
else:
592
+
# Before 4.0, MODIFY on MV is required to insert to base
593
+
# Grant WRITE permission on Base
594
+
cassandra.execute("GRANT MODIFY ON ks.cf TO cathy")
595
+
assert_unauthorized(cathy, "INSERT INTO ks.cf(id, value) VALUES(1, '1')", "User cathy has no SELECT permission on <table ks.cf> or any of its parents")
596
+
cassandra.execute("GRANT SELECT ON ks.cf TO cathy")
597
+
assert_unauthorized(cathy, "INSERT INTO ks.cf(id, value) VALUES(1, '1')", "User cathy has no MODIFY permission on <table ks.mv1> or any of its parents")
598
+
599
+
# Grant WRITE permission on MV
600
+
cassandra.execute("GRANT MODIFY ON ks.mv1 TO cathy")
601
+
cathy.execute("INSERT INTO ks.cf(id, value) VALUES(1, '1')")
602
+
assert_one(cathy, "SELECT * FROM ks.cf", [1, '1'])
603
+
assert_one(cathy, "SELECT * FROM ks.mv1", ['1', 1])
574
604
575
605
# Revoke ALTER permission and try DROP MV
576
606
cassandra.execute("REVOKE ALTER ON ks.cf FROM cathy")
0 commit comments