You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/05/19 06:26:19 UTC
[GitHub] [iotdb] RYH61 commented on a diff in pull request #5943: [IOTDB-3083] DataNode AuthorInfo cache
RYH61 commented on code in PR #5943:
URL: https://github.com/apache/iotdb/pull/5943#discussion_r876652293
##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/Manager.java:
##########
@@ -183,11 +184,19 @@ public interface Manager {
*/
DataSet queryPermission(ConfigRequest configRequest);
- /** login */
- TSStatus login(String username, String password);
+ /**
+ * login
+ *
+ * @return PermissionCacheInfo
+ */
Review Comment:
fix~
##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/Manager.java:
##########
@@ -183,11 +184,19 @@ public interface Manager {
*/
DataSet queryPermission(ConfigRequest configRequest);
- /** login */
- TSStatus login(String username, String password);
+ /**
+ * login
+ *
+ * @return PermissionCacheInfo
+ */
+ TPermissionInfoResp login(String username, String password);
- /** Check User Privileges */
- TSStatus checkUserPrivileges(String username, List<String> paths, int permission);
+ /**
+ * Check User Privileges
+ *
+ * @return PermissionCacheInfo
+ */
Review Comment:
fix~
##########
confignode/src/main/java/org/apache/iotdb/confignode/manager/PermissionManager.java:
##########
@@ -44,7 +57,21 @@ public PermissionManager(Manager configManager, AuthorInfo authorInfo) {
* @return TSStatus
*/
public TSStatus operatePermission(AuthorReq authorReq) {
- return getConsensusManager().write(authorReq).getStatus();
+ TSStatus status = getConsensusManager().write(authorReq).getStatus();
+ if (status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ try {
+ // If the permissions change, clear the cache content affected by the operation
+ if (authorReq.getAuthorType() != ConfigRequestType.CreateUser
+ || authorReq.getAuthorType() != ConfigRequestType.CreateRole) {
+ authorInfo.invalidateCache(env, authorReq.getUserName(), authorReq.getRoleName());
+ }
+ } catch (IOException | TException e) {
+ logger.error(
+ "Failed to initialize cache,the initialization operation is {}",
+ authorReq.getAuthorType());
Review Comment:
fix~
##########
confignode/src/main/java/org/apache/iotdb/confignode/persistence/AuthorInfo.java:
##########
@@ -362,4 +384,70 @@ public void clear() throws AuthException {
}
authorizer.reset();
}
+
+ /**
+ * When the permission information of a user or role is changed, the permission cache information
+ * of all datanode is initialized, and only the affected cache is initialized.
+ *
+ * @param env
+ * @param username
+ * @param roleName
+ * @throws IOException
+ * @throws TException
Review Comment:
fix~
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org