Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ public void rolePrivilegeTest() throws SQLException {
adminStmt.execute("CREATE ROLE admin");
adminStmt.execute("GRANT MANAGE_DATABASE,WRITE_SCHEMA,WRITE_DATA on root.** TO ROLE admin");
adminStmt.execute("GRANT ROLE admin TO tempuser");
adminStmt.execute("CREATE ROLE admin_temp");

// tempuser can get privileges of his role
userStmt.execute("LIST PRIVILEGES OF ROLE admin");
Assert.assertThrows(
SQLException.class, () -> userStmt.execute("LIST PRIVILEGS OF ROLE admin_temp"));

userStmt.execute("CREATE DATABASE root.a");
userStmt.execute("CREATE TIMESERIES root.a.b WITH DATATYPE=INT32,ENCODING=PLAIN");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ public void refreshToken() {
if (currentTime - heartBeatTimeStamp > CONFIG.getDatanodeTokenTimeoutMS()) {
cacheOutDate = true;
}
heartBeatTimeStamp = currentTime;
}

private void checkCacheAvailable() {
Expand Down Expand Up @@ -430,7 +431,7 @@ public boolean checkRole(String userName, String roleName) {
checkCacheAvailable();
User user = iAuthorCache.getUserCache(userName);
if (user != null) {
return user.isOpenIdUser() || user.getRoleList().contains(userName);
return user.isOpenIdUser() || user.getRoleList().contains(roleName);
} else {
return checkRoleFromConfigNode(userName, roleName);
}
Expand Down Expand Up @@ -485,6 +486,13 @@ private List<Integer> checkPathFromConfigNode(

private boolean checkRoleFromConfigNode(String username, String rolename) {
TAuthorizerReq req = new TAuthorizerReq();
// just reuse authorizer request. only need username and rolename field.
req.setAuthorType(0);
req.setPassword("");
req.setNewPassword("");
req.setNodeNameList(AuthUtils.serializePartialPathList(Collections.emptyList()));
req.setPermissions(Collections.emptySet());
req.setGrantOpt(false);
req.setUserName(username);
req.setRoleName(rolename);
TPermissionInfoResp permissionInfoResp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ public TSStatus checkPermissionBeforeProcess(String userName) {
}
return AuthorityChecker.getOptTSStatus(
AuthorityChecker.checkGrantOption(userName, privilegeList, nodeNameList),
"Has no permission to "
"Has no permission to execute"
+ authorType
+ ", please ensure you have these privileges and the grant option is TRUE when granted");

Expand All @@ -326,7 +326,7 @@ public TSStatus checkPermissionBeforeProcess(String userName) {
}
return AuthorityChecker.getOptTSStatus(
AuthorityChecker.checkGrantOption(userName, privilegeList, nodeNameList),
"Has no permission to "
"Has no permission to execute "
+ authorType
+ ", please ensure you have these privileges and the grant option is TRUE when granted");
default:
Expand Down