Skip to content

Commit eacc971

Browse files
committed
[fix](auth) after fe restarting, external permissions are lost (apache#43275)
cause by: apache#39597 This PR checks whether the authorized tableName exists. After restarting, when replaying the log, the metadata of the external cannot be obtained, so the replay will report an error, but it does not affect the startup, only printing the log. Solution: No longer verify during playback
1 parent 97a5b0d commit eacc971

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

fe/fe-core/src/main/java/org/apache/doris/mysql/privilege/Auth.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,9 @@ private void grantInternal(UserIdentity userIdent, String role, TablePattern tbl
582582
throws DdlException {
583583
writeLock();
584584
try {
585-
checkTablePatternExist(tblPattern);
585+
if (!isReplay) {
586+
checkTablePatternExist(tblPattern);
587+
}
586588
if (role == null) {
587589
if (!doesUserExist(userIdent)) {
588590
throw new DdlException("user " + userIdent + " does not exist");
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite("test_up_down_hive_prepare_auth","p0,auth,restart_fe,external,hive,external_docker,external_docker_hive") {
19+
String enabled = context.config.otherConfigs.get("enableHiveTest")
20+
if (enabled == null || !enabled.equalsIgnoreCase("true")) {
21+
logger.info("diable Hive test.")
22+
return;
23+
}
24+
String suiteName = "auth_up_down_hive"
25+
String hivePrefix = "hive2";
26+
String hms_port = context.config.otherConfigs.get(hivePrefix + "HmsPort")
27+
String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
28+
String catalogName = "${hivePrefix}_${suiteName}_catalog"
29+
String userName = "${hivePrefix}_${suiteName}_user"
30+
String pwd = 'C123_567p'
31+
32+
try_sql("DROP USER ${userName}")
33+
sql """CREATE USER '${userName}' IDENTIFIED BY '${pwd}'"""
34+
35+
sql """drop catalog if exists ${catalogName}"""
36+
sql """create catalog if not exists ${catalogName} properties (
37+
"type"="hms",
38+
'hive.metastore.uris' = 'thrift://${externalEnvIp}:${hms_port}'
39+
);"""
40+
sql """grant select_priv on ${catalogName}.tpch1_parquet.customer to ${userName}"""
41+
42+
def res = sql """show grants for ${userName}"""
43+
logger.info("res: " + res.toString())
44+
assertTrue(res.toString().contains("${catalogName}.tpch1_parquet.customer"))
45+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite("test_up_down_hive_auth","p0,mtmv,restart_fe,external,hive,external_docker,external_docker_hive") {
19+
String enabled = context.config.otherConfigs.get("enableHiveTest")
20+
if (enabled == null || !enabled.equalsIgnoreCase("true")) {
21+
logger.info("diable Hive test.")
22+
return;
23+
}
24+
String suiteName = "auth_up_down_hive"
25+
String hivePrefix = "hive2";
26+
String catalogName = "${hivePrefix}_${suiteName}_catalog"
27+
String userName = "${hivePrefix}_${suiteName}_user"
28+
29+
def res = sql """show grants for ${userName}"""
30+
logger.info("res: " + res.toString())
31+
assertTrue(res.toString().contains("${catalogName}.tpch1_parquet.customer"))
32+
}

0 commit comments

Comments
 (0)