30
30
import org .apache .doris .common .proc .ProcNodeInterface ;
31
31
import org .apache .doris .common .proc .ProcResult ;
32
32
import org .apache .doris .common .proc .ProcService ;
33
+ import org .apache .doris .datasource .InternalCatalog ;
33
34
import org .apache .doris .ha .HAProtocol ;
34
35
import org .apache .doris .httpv2 .entity .ResponseEntityBuilder ;
35
36
import org .apache .doris .mysql .privilege .PrivPredicate ;
@@ -214,16 +215,23 @@ public Object show_data(HttpServletRequest request, HttpServletResponse response
214
215
public Object show_table_data (HttpServletRequest request , HttpServletResponse response ) {
215
216
if (Config .enable_all_http_auth ) {
216
217
executeCheckPassword (request , response );
217
- checkGlobalAuth (ConnectContext .get ().getCurrentUserIdentity (), PrivPredicate .ADMIN );
218
218
}
219
-
220
219
String dbName = request .getParameter (DB_KEY );
221
220
String tableName = request .getParameter (TABLE_KEY );
221
+
222
+ if (StringUtils .isEmpty (dbName ) && StringUtils .isEmpty (tableName )) {
223
+ return ResponseEntityBuilder .okWithCommonError ("db and table cannot be empty at the same time" );
224
+ }
225
+
222
226
String singleReplica = request .getParameter (SINGLE_REPLICA_KEY );
223
227
boolean singleReplicaBool = Boolean .parseBoolean (singleReplica );
224
228
Map <String , Map <String , Long >> oneEntry = Maps .newHashMap ();
225
229
if (dbName != null ) {
226
230
String fullDbName = getFullDbName (dbName );
231
+ if (!StringUtils .isEmpty (tableName ) && Config .enable_all_http_auth ) {
232
+ checkTblAuth (ConnectContext .get ().getCurrentUserIdentity (), fullDbName , tableName , PrivPredicate .SHOW );
233
+ }
234
+
227
235
DatabaseIf db = Env .getCurrentInternalCatalog ().getDbNullable (fullDbName );
228
236
if (db == null ) {
229
237
return ResponseEntityBuilder .okWithCommonError ("database " + fullDbName + " not found." );
@@ -236,6 +244,12 @@ public Object show_table_data(HttpServletRequest request, HttpServletResponse re
236
244
if (db == null || !(db instanceof Database ) || ((Database ) db ) instanceof MysqlCompatibleDatabase ) {
237
245
continue ;
238
246
}
247
+ if (Config .enable_all_http_auth && !Env .getCurrentEnv ().getAccessManager ()
248
+ .checkTblPriv (ConnectContext .get ().getCurrentUserIdentity (),
249
+ InternalCatalog .INTERNAL_CATALOG_NAME , db .getFullName (), tableName ,
250
+ PrivPredicate .SHOW )) {
251
+ continue ;
252
+ }
239
253
Map <String , Long > tablesEntry = getDataSizeOfTables (db , tableName , singleReplicaBool );
240
254
oneEntry .put (ClusterNamespace .getNameFromFullName (db .getFullName ()), tablesEntry );
241
255
}
@@ -331,6 +345,12 @@ private Map<String, Long> getDataSizeOfTables(DatabaseIf db, String tableName, b
331
345
if (Strings .isNullOrEmpty (tableName )) {
332
346
List <Table > tables = db .getTables ();
333
347
for (Table table : tables ) {
348
+ if (Config .enable_all_http_auth && !Env .getCurrentEnv ().getAccessManager ()
349
+ .checkTblPriv (ConnectContext .get (), InternalCatalog .INTERNAL_CATALOG_NAME , db .getFullName (),
350
+ table .getName (),
351
+ PrivPredicate .SHOW )) {
352
+ continue ;
353
+ }
334
354
Map <String , Long > tableEntry = getDataSizeOfTable (table , singleReplica );
335
355
oneEntry .putAll (tableEntry );
336
356
}
0 commit comments