feat: audit path filters also apply to the OpenAI and Ollama routes (#34665)

AUDIT_EXCLUDED_PATHS and AUDIT_INCLUDED_PATHS only matched paths under /api/ and /api/v1/, so the OpenAI and Ollama routes could not be left out of the audit log, and with an include list set they were never logged. Values are now matched against the path with or without that prefix, so openai or ollama cover those routes.

Part of #33249
This commit is contained in:
Classic298 authored and GitHub committed 2026-11-22 20:29:06 +04:00
1 parent 45f489bea8
commit d065a70483
1 file changed
+6 -2
+6 -2
View File
@@ -186,10 +186,14 @@ class AuditLoggingMiddleware:
# Paths are fixed for the process lifetime; compile once instead of
# per request. None means the corresponding mode has nothing to match.
self._included_pattern = (
re.compile(r'^/api(?:/v1)?/(' + '|'.join(self.included_paths) + r')\b') if self.included_paths else None
re.compile(r'^(?:/api(?:/v1)?)?/(' + '|'.join(self.included_paths) + r')\b')
if self.included_paths
else None
)
self._excluded_pattern = (
re.compile(r'^/api(?:/v1)?/(' + '|'.join(self.excluded_paths) + r')\b') if self.excluded_paths else None
re.compile(r'^(?:/api(?:/v1)?)?/(' + '|'.join(self.excluded_paths) + r')\b')
if self.excluded_paths
else None
)
if self.included_paths and self.excluded_paths: