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


##########
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java:
##########
@@ -99,13 +99,26 @@ public void doFilter(ServletRequest request, 
ServletResponse response, FilterCha
           resp.setHeader(AuthConstants.HTTP_CHALLENGE_HEADER, challenge);
         }
       }
-      resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, ue.getMessage());
+      sendAuthErrorResponse(resp, HttpServletResponse.SC_UNAUTHORIZED, 
ue.getMessage());
     } catch (Exception e) {
       HttpServletResponse resp = (HttpServletResponse) response;
-      resp.sendError(HttpServletResponse.SC_UNAUTHORIZED, e.getMessage());
+      sendAuthErrorResponse(resp, HttpServletResponse.SC_UNAUTHORIZED, 
e.getMessage());
     }
   }
 
+  /**
+   * Sends an error response when authentication fails. Subclasses can 
override this to customize
+   * the error response format (e.g., Iceberg REST server returns JSON error 
bodies).
+   *
+   * @param response the HTTP servlet response
+   * @param status the HTTP status code
+   * @param message the error message
+   */
+  protected void sendAuthErrorResponse(HttpServletResponse response, int 
status, String message)

Review Comment:
   Make this method abstract. Gravitino server should implement this method, 
too.
   You can refer to json format in the class Utils.



-- 
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