Guest User

CassandraRolesCreation

a guest
Dec 5th, 2017
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. DROP KEYSPACE demodb;
  2. DROP USER dba;
  3. DROP USER dba_rw;
  4. DROP USER dba_ro;
  5. DROP USER dba_schema;
  6.  
  7. CREATE KEYSPACE demodb WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
  8.  
  9. CREATE TABLE demodb.users (name text PRIMARY KEY, password text);
  10. INSERT INTO demodb.users (name, password) values ('user1', 'password1');
  11. INSERT INTO demodb.users (name, password) values ('user2', 'password2');
  12. INSERT INTO demodb.users (name, password) values ('user3', 'password3');
  13. INSERT INTO demodb.users (name, password) values ('user4', 'password4');
  14.  
  15. //create a super user with "dba" name and password "super"
  16. CREATE ROLE dba WITH SUPERUSER = true AND LOGIN = true AND PASSWORD = 'super';
  17.  
  18. //create a RW user
  19. CREATE USER dba_rw WITH PASSWORD 'password';
  20. GRANT SELECT ON ALL KEYSPACES TO dba_rw;
  21. GRANT MODIFY ON ALL KEYSPACES TO dba_rw;
  22.  
  23. //create a R user
  24. CREATE USER dba_ro WITH PASSWORD 'password';
  25. GRANT SELECT ON ALL KEYSPACES TO dba_ro;
  26.  
  27. //create a SCHEMA Modifier
  28. CREATE USER dba_schema WITH PASSWORD 'password';
  29. GRANT ALTER ON ALL KEYSPACES TO dba_schema;
  30. GRANT MODIFY ON ALL KEYSPACES TO dba_schema;
  31. GRANT SELECT ON ALL KEYSPACES TO dba_schema;
  32. GRANT CREATE ON ALL KEYSPACES TO dba_schema;
  33. GRANT DROP ON ALL KEYSPACES TO dba_schema;
Add Comment
Please, Sign In to add comment