Skip to content

Commit

Permalink
Merge pull request #2899 from atlanhq/master
Browse files Browse the repository at this point in the history
Sync beta with master
  • Loading branch information
sumandas0 authored Mar 29, 2024
2 parents ded0e0b + fcaac1e commit 9b0c341
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class ActiveServerFilter implements Filter {
private static final Logger LOG = LoggerFactory.getLogger(ActiveServerFilter.class);
private static final String MIGRATION_STATUS_STATIC_PAGE = "migration-status.html";

private static final String[] WHITELISTED_APIS_SIGNATURE = {"search", "lineage", "auditSearch", "accessors"
, "evaluator"};

private final ActiveInstanceState activeInstanceState;
private ServiceState serviceState;

Expand Down Expand Up @@ -88,8 +91,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
// Block all the POST, PUT, DELETE operations
HttpServletRequest request = (HttpServletRequest) servletRequest;
HttpServletResponse response = (HttpServletResponse) servletResponse;
if (isBlockedMethod(request.getMethod()) && !request.getRequestURI().contains("search") &&
!request.getRequestURI().contains("lineage")) {
if (isBlockedMethod(request.getMethod()) && !isWhitelistedAPI(request.getRequestURI())) {
LOG.error("Maintenance mode enabled. Blocking request: {}", request.getRequestURI());
sendMaintenanceModeResponse(response);
return; // Stop further processing
Expand Down Expand Up @@ -148,6 +150,15 @@ private boolean isFilteredURI(ServletRequest servletRequest) {
}
}

private boolean isWhitelistedAPI(String requestURI) {
for (String api : WHITELISTED_APIS_SIGNATURE) {
if (requestURI.contains(api)) {
return true;
}
}
return false;
}

private void sendMaintenanceModeResponse(HttpServletResponse response) throws IOException {
response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
response.setContentType("application/json");
Expand Down

0 comments on commit 9b0c341

Please sign in to comment.