Skip to content

Commit ea0bfb2

Browse files
neuyilanxiaokang
authored andcommitted
[Fix](auth) fix revoke role operation cause fe down (#23852)
If there 3 above fe nodes, the following opeartions will cause all FE nodes down. DROP USER revoke_test_user DROP ROLE revoke_test_role DROP DATABASE IF EXISTS revoke_test_db CREATE DATABASE revoke_test_db CREATE ROLE revoke_test_role CREATE USER revoke_test_user IDENTIFIED BY 'revoke_test_pwd' GRANT SELECT_PRIV ON revoke_test_db.* TO ROLE 'revoke_test_role' GRANT 'revoke_test_role' TO revoke_test_user SHOW GRANTS FOR revoke_test_user REVOKE 'revoke_test_role' from revoke_test_user SHOW GRANTS FOR revoke_test_user DROP USER revoke_test_user DROP ROLE revoke_test_role DROP DATABASE revoke_test_db
1 parent 4ece7aa commit ea0bfb2

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ public void replayRevoke(PrivInfo info) {
711711
revokeInternal(info.getUserIdent(), info.getRole(), info.getWorkloadGroupPattern(), info.getPrivs(),
712712
true /* err on non exist */, true /* is replay */);
713713
} else {
714-
revokeInternal(info.getUserIdent(), info.getRoles(), false);
714+
revokeInternal(info.getUserIdent(), info.getRoles(), true /* is replay */);
715715
}
716716
} catch (DdlException e) {
717717
LOG.error("should not happened", e);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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_revoke_role", "account") {
19+
def role= 'revoke_test_role'
20+
def user = 'revoke_test_user'
21+
def dbName = 'revoke_test_db'
22+
def pwd = 'revoke_test_pwd'
23+
24+
try_sql("DROP ROLE ${role}")
25+
try_sql("DROP USER ${user}")
26+
try_sql("DROP ROLE ${role}")
27+
sql """DROP DATABASE IF EXISTS ${dbName}"""
28+
sql """CREATE DATABASE ${dbName}"""
29+
30+
sql """CREATE ROLE ${role}"""
31+
sql """CREATE USER ${user} IDENTIFIED BY '${pwd}'"""
32+
33+
sql """GRANT SELECT_PRIV ON ${dbName}.* TO ROLE '${role}'"""
34+
sql """GRANT '${role}' TO ${user}"""
35+
36+
def result = sql """ SHOW GRANTS FOR ${user} """
37+
assertEquals(result.size(), 1)
38+
assertTrue(result[0][5].contains("internal.default_cluster:${dbName}: Select_priv"))
39+
40+
sql """REVOKE '${role}' from ${user}"""
41+
result = sql """ SHOW GRANTS FOR ${user} """
42+
assertEquals(result.size(), 1)
43+
assertFalse(result[0][5].contains("internal.default_cluster:${dbName}: Select_priv"))
44+
45+
sql """DROP USER ${user}"""
46+
sql """DROP ROLE ${role}"""
47+
sql """DROP DATABASE ${dbName}"""
48+
}
49+

0 commit comments

Comments
 (0)