Skip to content

Commit 5d6609c

Browse files
authored
Add auth check for show related
1 parent 13afc03 commit 5d6609c

File tree

6 files changed

+124
-125
lines changed

6 files changed

+124
-125
lines changed

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,25 +143,25 @@ public static Iterator<TsBlock> getSupplier(
143143
case InformationSchema.PIPE_PLUGINS:
144144
return new PipePluginSupplier(dataTypes);
145145
case InformationSchema.TOPICS:
146-
return new TopicSupplier(dataTypes, userEntity.getUsername());
146+
return new TopicSupplier(dataTypes, userEntity);
147147
case InformationSchema.SUBSCRIPTIONS:
148-
return new SubscriptionSupplier(dataTypes, userEntity.getUsername());
148+
return new SubscriptionSupplier(dataTypes, userEntity);
149149
case InformationSchema.VIEWS:
150150
return new ViewsSupplier(dataTypes, userEntity);
151151
case InformationSchema.MODELS:
152152
return new ModelsSupplier(dataTypes);
153153
case InformationSchema.FUNCTIONS:
154154
return new FunctionsSupplier(dataTypes);
155155
case InformationSchema.CONFIGURATIONS:
156-
return new ConfigurationsSupplier(dataTypes, userEntity.getUsername());
156+
return new ConfigurationsSupplier(dataTypes, userEntity);
157157
case InformationSchema.KEYWORDS:
158158
return new KeywordsSupplier(dataTypes);
159159
case InformationSchema.NODES:
160-
return new NodesSupplier(dataTypes, userEntity.getUsername());
160+
return new NodesSupplier(dataTypes, userEntity);
161161
case InformationSchema.CONFIG_NODES:
162-
return new ConfigNodesSupplier(dataTypes, userEntity.getUsername());
162+
return new ConfigNodesSupplier(dataTypes, userEntity);
163163
case InformationSchema.DATA_NODES:
164-
return new DataNodesSupplier(dataTypes, userEntity.getUsername());
164+
return new DataNodesSupplier(dataTypes, userEntity);
165165
default:
166166
throw new UnsupportedOperationException("Unknown table: " + tableName);
167167
}
@@ -181,7 +181,7 @@ private QueriesSupplier(final List<TSDataType> dataTypes, final UserEntity userE
181181
super(dataTypes);
182182
queryExecutions = Coordinator.getInstance().getAllQueryExecutions();
183183
try {
184-
accessControl.checkUserGlobalSysPrivilege(userEntity.getUsername(), userEntity);
184+
accessControl.checkUserGlobalSysPrivilege(userEntity);
185185
} catch (final AccessDeniedException e) {
186186
queryExecutions =
187187
queryExecutions.stream()
@@ -490,7 +490,7 @@ private static class RegionSupplier extends TsBlockSupplier {
490490
private RegionSupplier(final List<TSDataType> dataTypes, final UserEntity userEntity)
491491
throws Exception {
492492
super(dataTypes);
493-
accessControl.checkUserIsAdmin(userEntity.getUsername());
493+
accessControl.checkUserGlobalSysPrivilege(userEntity);
494494
try (final ConfigNodeClient client =
495495
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
496496
iterator =
@@ -640,10 +640,10 @@ public boolean hasNext() {
640640
private static class TopicSupplier extends TsBlockSupplier {
641641
private final Iterator<TShowTopicInfo> iterator;
642642

643-
private TopicSupplier(final List<TSDataType> dataTypes, final String userName)
643+
private TopicSupplier(final List<TSDataType> dataTypes, final UserEntity userEntity)
644644
throws Exception {
645645
super(dataTypes);
646-
accessControl.checkUserIsAdmin(userName);
646+
accessControl.checkUserGlobalSysPrivilege(userEntity);
647647
try (final ConfigNodeClient client =
648648
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
649649
iterator =
@@ -673,10 +673,10 @@ public boolean hasNext() {
673673
private static class SubscriptionSupplier extends TsBlockSupplier {
674674
private final Iterator<TShowSubscriptionInfo> iterator;
675675

676-
private SubscriptionSupplier(final List<TSDataType> dataTypes, final String userName)
676+
private SubscriptionSupplier(final List<TSDataType> dataTypes, final UserEntity userEntity)
677677
throws Exception {
678678
super(dataTypes);
679-
accessControl.checkUserIsAdmin(userName);
679+
accessControl.checkUserGlobalSysPrivilege(userEntity);
680680
try (final ConfigNodeClient client =
681681
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
682682
iterator =
@@ -955,10 +955,10 @@ public boolean hasNext() {
955955
private static class ConfigurationsSupplier extends TsBlockSupplier {
956956
private final Iterator<Pair<Binary, Binary>> resultIterator;
957957

958-
private ConfigurationsSupplier(final List<TSDataType> dataTypes, final String userName)
958+
private ConfigurationsSupplier(final List<TSDataType> dataTypes, final UserEntity userEntity)
959959
throws Exception {
960960
super(dataTypes);
961-
accessControl.checkUserIsAdmin(userName);
961+
accessControl.checkUserGlobalSysPrivilege(userEntity);
962962
try (final ConfigNodeClient client =
963963
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
964964
final TClusterParameters parameters = client.showVariables().getClusterParameters();
@@ -1062,10 +1062,10 @@ private static class NodesSupplier extends TsBlockSupplier {
10621062
private final Iterator<TDataNodeLocation> dataNodeIterator;
10631063
private final Iterator<TAINodeLocation> aiNodeIterator;
10641064

1065-
private NodesSupplier(final List<TSDataType> dataTypes, final String userName)
1065+
private NodesSupplier(final List<TSDataType> dataTypes, final UserEntity userEntity)
10661066
throws Exception {
10671067
super(dataTypes);
1068-
accessControl.checkUserIsAdmin(userName);
1068+
accessControl.checkUserGlobalSysPrivilege(userEntity);
10691069
try (final ConfigNodeClient client =
10701070
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
10711071
showClusterResp = client.showCluster();
@@ -1156,10 +1156,10 @@ public boolean hasNext() {
11561156
private static class ConfigNodesSupplier extends TsBlockSupplier {
11571157
private final Iterator<TConfigNodeInfo4InformationSchema> configNodeIterator;
11581158

1159-
private ConfigNodesSupplier(final List<TSDataType> dataTypes, final String userName)
1159+
private ConfigNodesSupplier(final List<TSDataType> dataTypes, final UserEntity userEntity)
11601160
throws Exception {
11611161
super(dataTypes);
1162-
accessControl.checkUserIsAdmin(userName);
1162+
accessControl.checkUserGlobalSysPrivilege(userEntity);
11631163
try (final ConfigNodeClient client =
11641164
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
11651165
configNodeIterator =
@@ -1187,10 +1187,10 @@ public boolean hasNext() {
11871187
private static class DataNodesSupplier extends TsBlockSupplier {
11881188
private final Iterator<TDataNodeInfo4InformationSchema> dataNodeIterator;
11891189

1190-
private DataNodesSupplier(final List<TSDataType> dataTypes, final String userName)
1190+
private DataNodesSupplier(final List<TSDataType> dataTypes, final UserEntity userEntity)
11911191
throws Exception {
11921192
super(dataTypes);
1193-
accessControl.checkUserIsAdmin(userName);
1193+
accessControl.checkUserGlobalSysPrivilege(userEntity);
11941194
try (final ConfigNodeClient client =
11951195
ConfigNodeClientManager.getInstance().borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
11961196
dataNodeIterator = client.showDataNodes4InformationSchema().getDataNodesInfoListIterator();

0 commit comments

Comments
 (0)