From d065a70483ec82fe8fc5b55ebcbff7cfda3c5c43 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sun, 22 Nov 2026 17:29:06 +0100 Subject: [PATCH] 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 --- backend/open_webui/utils/audit.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/audit.py b/backend/open_webui/utils/audit.py index edd0cbffe4..1edf9d5d63 100644 --- a/backend/open_webui/utils/audit.py +++ b/backend/open_webui/utils/audit.py @@ -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: