roryqi commented on code in PR #11226:
URL: https://github.com/apache/gravitino/pull/11226#discussion_r3311645816


##########
plugins/idp-basic/src/main/java/org/apache/gravitino/idp/IdpUserGroupManager.java:
##########
@@ -96,8 +148,21 @@ public boolean removeUser(String username) {
    * @return The built-in IdP user.
    */
   public IdpUser getUser(String username) {
-    IdpUserPO userPO = USER_SERVICE.getIdpUserByUsername(username);
-    return new IdpUser(userPO.getUsername(), 
USER_SERVICE.listGroupNamesByUsername(username));
+    return USER_SERVICE.getIdpUser(username);
+  }
+
+  public IdpUser authenticate(String username, String password) {
+    try {
+      IdpUserPO userPO = USER_SERVICE.getIdpUserByUsername(username);
+      if (!passwordHasher.verify(password, userPO.getPasswordHash())) {
+        throw new UnauthorizedException(
+            "Invalid username or password", 
AuthConstants.AUTHORIZATION_BASIC_HEADER.trim());
+      }
+      return getUser(username);

Review Comment:
   Two IO operations. Could u optimize?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to