mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-12-18 20:04:17 +01:00
fix: use stricter URL matching in enterprise filter
This commit is contained in:
parent
27068593d6
commit
cce97dbe46
@ -28,11 +28,19 @@ public class EnterpriseEndpointFilter extends OncePerRequestFilter {
|
||||
if (!runningProOrHigher && isPrometheusEndpointRequest(request)) {
|
||||
// Allow only health checks to pass through for non-pro users
|
||||
String uri = request.getRequestURI();
|
||||
|
||||
// Strip the context path
|
||||
String contextPath = request.getContextPath();
|
||||
String trimmedUri =
|
||||
(contextPath != null && uri.startsWith(contextPath))
|
||||
? uri.substring(contextPath.length())
|
||||
: uri;
|
||||
|
||||
boolean isHealthCheck =
|
||||
uri.contains("/actuator/health")
|
||||
|| uri.contains("/healthz")
|
||||
|| uri.contains("/liveness")
|
||||
|| uri.contains("/readiness");
|
||||
trimmedUri.startsWith("/actuator/health")
|
||||
|| "/healthz".equals(trimmedUri)
|
||||
|| "/liveness".equals(trimmedUri)
|
||||
|| "/readiness".equals(trimmedUri);
|
||||
|
||||
if (!isHealthCheck) {
|
||||
response.setStatus(HttpStatus.NOT_FOUND.value());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user