2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Cassandraのユーザーパーミッションの挙動

Posted at

ユーザーAliceを作成

$ cqlsh -u admin -p <password>

# ユーザーAliceを作成
cqlsh> create user Alice with password 'alice';

# キースペースAliceDBを作成し、AliceにALL権限を与える
cqlsh> create keyspace AliceDB with replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
cqlsh> grant all PERMISSIONS ON KEYSPACE alicedb TO 'Alice';

# bobdbを作成、データを挿入
cqlsh> create keyspace AliceDB with replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
cqlsh> use bobdb;
cqlsh:bobdb> create table BobTable(id varchar PRIMARY KEY, var varchar );
cqlsh:bobdb> insert into bobtable (id,var) values ('key-1','a');

作成されたユーザーAlice(AliceDBにALL権限を持つ)でログインし、挙動を調査する

$ ./bin/cqlsh -u Alice -p alice;

# 新規Keyspaceの作成に失敗する
cqlsh:alicedb> create keyspace AliceDB2 with replication = {'class': 'SimpleStrategy', 'replication_factor': 1};                          
Bad Request: User Alice has no CREATE permission on <all keyspaces> or any of its parents

# alicedb上での新規Table作成に成功する
cqlsh> use alicedb;
cqlsh:alicedb> create table AliceTable(id varchar PRIMARY KEY );

# bobdb Keyspaceでの新規Table作成とSELECTに失敗する。
cqlsh:alicedb> use bobdb ;
cqlsh:bobdb> create table AliceTable(id varchar PRIMARY KEY );
Bad Request: User Alice has no CREATE permission on <keyspace bobdb> or any of its parents
cqlsh:bobdb> select * from bobtable ;
Bad Request: User Alice has no SELECT permission on <table bobdb.bobtable> or any of its parents

期待通りのパーミッション動作になっていることを確認した

  • ALL KEYSPACESリソースでのCREATE権限を持っていない限り新規KeySpaceは作れない
  • CREATE権限を持っているKeySpace上では自由にTableが作れる
  • SELECT権限を持っていないKeySpace上のリソースは参照できない
  • describe keyspacesすると全てのKeyspaceの全てのTableのスキーマが取れるようなので、ACLでスキーマ情報を隠蔽することは出来ない。
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?