Skip to content

Commit 61cfb52

Browse files
authored
[#6011] fix(authz): MODIFY_TABLE should contain the select table privilege (#6620)
### What changes were proposed in this pull request? `MODIFY_TABLE` should contain the select table privilege ### Why are the changes needed? More proper semantics Fix: #6011 ### Does this PR introduce _any_ user-facing change? Correct the document. ### How was this patch tested? Modify the UT.
1 parent 392cdd5 commit 61cfb52

File tree

7 files changed

+57
-56
lines changed

7 files changed

+57
-56
lines changed

authorizations/authorization-chain/src/test/java/org/apache/gravitino/authorization/chain/integration/test/TestChainedAuthorizationIT.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -320,22 +320,22 @@ void testCreateTable() throws InterruptedException {
320320
}
321321

322322
@Test
323-
void testReadWriteTableWithMetalakeLevelRole() throws InterruptedException {
323+
void testSelectModifyTableWithMetalakeLevelRole() throws InterruptedException {
324324
// TODO
325325
}
326326

327327
@Test
328-
void testReadWriteTableWithTableLevelRole() throws InterruptedException {
328+
void testSelectModifyTableWithTableLevelRole() throws InterruptedException {
329329
// TODO
330330
}
331331

332332
@Test
333-
void testReadOnlyTable() throws InterruptedException {
333+
void testSelectOnlyTable() throws InterruptedException {
334334
// TODO
335335
}
336336

337337
@Test
338-
void testWriteOnlyTable() throws InterruptedException {
338+
void testModifyOnlyTable() throws InterruptedException {
339339
// TODO
340340
}
341341

@@ -385,32 +385,32 @@ protected void checkTableAllPrivilegesExceptForCreating() {
385385
}
386386

387387
@Override
388-
protected void checkUpdateSQLWithReadWritePrivileges() {
388+
protected void checkUpdateSQLWithSelectModifyPrivileges() {
389389
// TODO
390390
}
391391

392392
@Override
393-
protected void checkUpdateSQLWithReadPrivileges() {
393+
protected void checkUpdateSQLWithSelectPrivileges() {
394394
// TODO
395395
}
396396

397397
@Override
398-
protected void checkUpdateSQLWithWritePrivileges() {
398+
protected void checkUpdateSQLWithModifyPrivileges() {
399399
// TODO
400400
}
401401

402402
@Override
403-
protected void checkDeleteSQLWithReadWritePrivileges() {
403+
protected void checkDeleteSQLWithSelectModifyPrivileges() {
404404
// TODO
405405
}
406406

407407
@Override
408-
protected void checkDeleteSQLWithReadPrivileges() {
408+
protected void checkDeleteSQLWithSelectPrivileges() {
409409
// TODO
410410
}
411411

412412
@Override
413-
protected void checkDeleteSQLWithWritePrivileges() {
413+
protected void checkDeleteSQLWithModifyPrivileges() {
414414
// TODO
415415
}
416416

authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationHadoopSQLPlugin.java

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public Map<Privilege.Name, Set<AuthorizationPrivilege>> privilegesMappingRule()
7878
ImmutableSet.of(RangerHadoopSQLPrivilege.CREATE),
7979
Privilege.Name.MODIFY_TABLE,
8080
ImmutableSet.of(
81+
RangerHadoopSQLPrivilege.READ,
82+
RangerHadoopSQLPrivilege.SELECT,
8183
RangerHadoopSQLPrivilege.UPDATE,
8284
RangerHadoopSQLPrivilege.ALTER,
8385
RangerHadoopSQLPrivilege.WRITE),

authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerBaseE2EIT.java

+20-21
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,17 @@ protected static void waitForUpdatingPolicies() {
191191

192192
protected abstract void checkTableAllPrivilegesExceptForCreating();
193193

194-
protected abstract void checkUpdateSQLWithReadWritePrivileges();
194+
protected abstract void checkUpdateSQLWithSelectModifyPrivileges();
195195

196-
protected abstract void checkUpdateSQLWithReadPrivileges();
196+
protected abstract void checkUpdateSQLWithSelectPrivileges();
197197

198-
protected abstract void checkUpdateSQLWithWritePrivileges();
198+
protected abstract void checkUpdateSQLWithModifyPrivileges();
199199

200-
protected abstract void checkDeleteSQLWithReadWritePrivileges();
200+
protected abstract void checkDeleteSQLWithSelectModifyPrivileges();
201201

202-
protected abstract void checkDeleteSQLWithReadPrivileges();
202+
protected abstract void checkDeleteSQLWithSelectPrivileges();
203203

204-
protected abstract void checkDeleteSQLWithWritePrivileges();
204+
protected abstract void checkDeleteSQLWithModifyPrivileges();
205205

206206
protected abstract void useCatalog();
207207

@@ -313,7 +313,7 @@ void testCreateTable() throws InterruptedException {
313313
}
314314

315315
@Test
316-
void testReadWriteTableWithMetalakeLevelRole() throws InterruptedException {
316+
void testSelectModifyTableWithMetalakeLevelRole() throws InterruptedException {
317317
// Choose a catalog
318318
useCatalog();
319319

@@ -346,10 +346,10 @@ void testReadWriteTableWithMetalakeLevelRole() throws InterruptedException {
346346
sparkSession.sql(SQL_SELECT_TABLE).collectAsList();
347347

348348
// case 3: Update data in the table
349-
checkUpdateSQLWithReadWritePrivileges();
349+
checkUpdateSQLWithSelectModifyPrivileges();
350350

351351
// case 4: Delete data from the table.
352-
checkDeleteSQLWithReadWritePrivileges();
352+
checkDeleteSQLWithSelectModifyPrivileges();
353353

354354
// case 5: Succeed to alter the table
355355
testAlterTable();
@@ -368,7 +368,7 @@ void testReadWriteTableWithMetalakeLevelRole() throws InterruptedException {
368368
}
369369

370370
@Test
371-
void testReadWriteTableWithTableLevelRole() throws InterruptedException {
371+
void testSelectModifyTableWithTableLevelRole() throws InterruptedException {
372372
// Choose a catalog
373373
useCatalog();
374374

@@ -410,10 +410,10 @@ void testReadWriteTableWithTableLevelRole() throws InterruptedException {
410410
sparkSession.sql(SQL_SELECT_TABLE).collectAsList();
411411

412412
// case 3: Update data in the table.
413-
checkUpdateSQLWithReadWritePrivileges();
413+
checkUpdateSQLWithSelectModifyPrivileges();
414414

415415
// case 4: Delete data from the table.
416-
checkDeleteSQLWithReadWritePrivileges();
416+
checkDeleteSQLWithSelectModifyPrivileges();
417417

418418
// case 5: Succeed to alter the table
419419
testAlterTable();
@@ -432,7 +432,7 @@ void testReadWriteTableWithTableLevelRole() throws InterruptedException {
432432
}
433433

434434
@Test
435-
void testReadOnlyTable() throws InterruptedException {
435+
void testSelectOnlyTable() throws InterruptedException {
436436
// Choose a catalog
437437
useCatalog();
438438

@@ -464,10 +464,10 @@ void testReadOnlyTable() throws InterruptedException {
464464
sparkSession.sql(SQL_SELECT_TABLE).collectAsList();
465465

466466
// case 3: Update data in the table
467-
checkUpdateSQLWithReadPrivileges();
467+
checkUpdateSQLWithSelectPrivileges();
468468

469469
// case 4: Delete data from the table
470-
checkDeleteSQLWithReadPrivileges();
470+
checkDeleteSQLWithSelectPrivileges();
471471

472472
// case 5: Fail to alter the table
473473
Assertions.assertThrows(AccessControlException.class, () -> sparkSession.sql(SQL_ALTER_TABLE));
@@ -486,7 +486,7 @@ void testReadOnlyTable() throws InterruptedException {
486486
}
487487

488488
@Test
489-
void testWriteOnlyTable() throws InterruptedException {
489+
void testModifyOnlyTable() throws InterruptedException {
490490
// Choose a catalog
491491
useCatalog();
492492

@@ -514,15 +514,14 @@ void testWriteOnlyTable() throws InterruptedException {
514514
// case 1: Succeed to insert data into the table
515515
sparkSession.sql(SQL_INSERT_TABLE);
516516

517-
// case 2: Fail to select data from the table
518-
Assertions.assertThrows(
519-
AccessControlException.class, () -> sparkSession.sql(SQL_SELECT_TABLE).collectAsList());
517+
// case 2: Succeed to select data from the table
518+
sparkSession.sql(SQL_SELECT_TABLE).collectAsList();
520519

521520
// case 3: Update data in the table
522-
checkUpdateSQLWithWritePrivileges();
521+
checkUpdateSQLWithModifyPrivileges();
523522

524523
// case 4: Delete data from the table
525-
checkDeleteSQLWithWritePrivileges();
524+
checkDeleteSQLWithModifyPrivileges();
526525

527526
// case 5: Succeed to alter the table
528527
testAlterTable();

authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerHiveE2EIT.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -133,35 +133,35 @@ protected void checkWithoutPrivileges() {
133133
}
134134

135135
@Override
136-
protected void checkUpdateSQLWithReadWritePrivileges() {
136+
protected void checkUpdateSQLWithSelectModifyPrivileges() {
137137
Assertions.assertThrows(
138138
SparkUnsupportedOperationException.class, () -> sparkSession.sql(SQL_UPDATE_TABLE));
139139
}
140140

141141
@Override
142-
protected void checkUpdateSQLWithReadPrivileges() {
142+
protected void checkUpdateSQLWithSelectPrivileges() {
143143
Assertions.assertThrows(
144144
SparkUnsupportedOperationException.class, () -> sparkSession.sql(SQL_UPDATE_TABLE));
145145
}
146146

147147
@Override
148-
protected void checkUpdateSQLWithWritePrivileges() {
148+
protected void checkUpdateSQLWithModifyPrivileges() {
149149
Assertions.assertThrows(
150150
SparkUnsupportedOperationException.class, () -> sparkSession.sql(SQL_UPDATE_TABLE));
151151
}
152152

153153
@Override
154-
protected void checkDeleteSQLWithReadWritePrivileges() {
154+
protected void checkDeleteSQLWithSelectModifyPrivileges() {
155155
Assertions.assertThrows(AnalysisException.class, () -> sparkSession.sql(SQL_DELETE_TABLE));
156156
}
157157

158158
@Override
159-
protected void checkDeleteSQLWithReadPrivileges() {
159+
protected void checkDeleteSQLWithSelectPrivileges() {
160160
Assertions.assertThrows(AnalysisException.class, () -> sparkSession.sql(SQL_DELETE_TABLE));
161161
}
162162

163163
@Override
164-
protected void checkDeleteSQLWithWritePrivileges() {
164+
protected void checkDeleteSQLWithModifyPrivileges() {
165165
Assertions.assertThrows(AnalysisException.class, () -> sparkSession.sql(SQL_DELETE_TABLE));
166166
}
167167

authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerIcebergE2EIT.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -111,33 +111,33 @@ protected String testUserName() {
111111
return System.getenv(HADOOP_USER_NAME);
112112
}
113113

114-
public void checkUpdateSQLWithReadWritePrivileges() {
114+
public void checkUpdateSQLWithSelectModifyPrivileges() {
115115
sparkSession.sql(SQL_UPDATE_TABLE);
116116
}
117117

118118
@Override
119-
public void checkUpdateSQLWithReadPrivileges() {
119+
public void checkUpdateSQLWithSelectPrivileges() {
120120
Assertions.assertThrows(AccessControlException.class, () -> sparkSession.sql(SQL_UPDATE_TABLE));
121121
}
122122

123123
@Override
124-
public void checkUpdateSQLWithWritePrivileges() {
125-
Assertions.assertThrows(AccessControlException.class, () -> sparkSession.sql(SQL_UPDATE_TABLE));
124+
public void checkUpdateSQLWithModifyPrivileges() {
125+
sparkSession.sql(SQL_UPDATE_TABLE);
126126
}
127127

128128
@Override
129-
public void checkDeleteSQLWithReadWritePrivileges() {
129+
public void checkDeleteSQLWithSelectModifyPrivileges() {
130130
sparkSession.sql(SQL_DELETE_TABLE);
131131
}
132132

133133
@Override
134-
public void checkDeleteSQLWithReadPrivileges() {
134+
public void checkDeleteSQLWithSelectPrivileges() {
135135
Assertions.assertThrows(AccessControlException.class, () -> sparkSession.sql(SQL_DELETE_TABLE));
136136
}
137137

138138
@Override
139-
public void checkDeleteSQLWithWritePrivileges() {
140-
Assertions.assertThrows(AccessControlException.class, () -> sparkSession.sql(SQL_DELETE_TABLE));
139+
public void checkDeleteSQLWithModifyPrivileges() {
140+
sparkSession.sql(SQL_DELETE_TABLE);
141141
}
142142

143143
public void checkWithoutPrivileges() {

authorizations/authorization-ranger/src/test/java/org/apache/gravitino/authorization/ranger/integration/test/RangerPaimonE2EIT.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -130,32 +130,32 @@ protected void useCatalog() {
130130
}
131131

132132
@Override
133-
protected void checkUpdateSQLWithReadWritePrivileges() {
133+
protected void checkUpdateSQLWithSelectModifyPrivileges() {
134134
// Kyuubi Paimon Ranger plugin doesn't support to update yet.
135135
}
136136

137137
@Override
138-
protected void checkUpdateSQLWithReadPrivileges() {
138+
protected void checkUpdateSQLWithSelectPrivileges() {
139139
// Kyuubi Paimon Ranger plugin doesn't support to update yet.
140140
}
141141

142142
@Override
143-
protected void checkUpdateSQLWithWritePrivileges() {
143+
protected void checkUpdateSQLWithModifyPrivileges() {
144144
// Kyuubi Paimon Ranger plugin doesn't support to update yet.
145145
}
146146

147147
@Override
148-
protected void checkDeleteSQLWithReadWritePrivileges() {
148+
protected void checkDeleteSQLWithSelectModifyPrivileges() {
149149
// Kyuubi Paimon Ranger plugin doesn't support to delete yet.
150150
}
151151

152152
@Override
153-
protected void checkDeleteSQLWithReadPrivileges() {
153+
protected void checkDeleteSQLWithSelectPrivileges() {
154154
// Kyuubi Paimon Ranger plugin doesn't support to delete yet.
155155
}
156156

157157
@Override
158-
protected void checkDeleteSQLWithWritePrivileges() {
158+
protected void checkDeleteSQLWithModifyPrivileges() {
159159
// Kyuubi Paimon Ranger plugin doesn't support to delete yet.
160160
}
161161

docs/security/access-control.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,11 @@ and `USE_SCHEMA` privileges on its parent schema.
202202

203203
### Table privileges
204204

205-
| Name | Supports Securable Object | Operation |
206-
|--------------|-----------------------------------|--------------------------------------------------|
207-
| CREATE_TABLE | Metalake, Catalog, Schema | Create a table |
208-
| MODIFY_TABLE | Metalake, Catalog, Schema, Table | Write data to a table or modify the table schema |
209-
| SELECT_TABLE | Metalake, Catalog, Schema, Table | Select data from a table |
205+
| Name | Supports Securable Object | Operation |
206+
|--------------|-----------------------------------|---------------------------------------------------------------------------|
207+
| CREATE_TABLE | Metalake, Catalog, Schema | Create a table |
208+
| MODIFY_TABLE | Metalake, Catalog, Schema, Table | Select data from a data, write data to a table or modify the table schema |
209+
| SELECT_TABLE | Metalake, Catalog, Schema, Table | Select data from a table |
210210

211211
### Topic privileges
212212

0 commit comments

Comments
 (0)