LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
V0.77.9 hotfix (#615)
alia3763c8fe4de
diff --git a/backend/account/custom_auth_middleware.py b/backend/account/custom_auth_middleware.pyindex 966583ef5..020f5f413 100644--- a/backend/account/custom_auth_middleware.py+++ b/backend/account/custom_auth_middleware.py@@ -4,6 +4,7 @@ from account.constants import Commonfrom django.conf import settingsfrom django.http import HttpRequest, HttpResponse, JsonResponsefrom utils.local_context import StateStore+from utils.user_session import UserSessionUtilsfrom backend.constants import RequestHeader@@ -34,8 +35,9 @@ class CustomAuthMiddleware:auth_service = AuthenticationService()is_authenticated = auth_service.is_authenticated(request)+ is_authorized = UserSessionUtils.is_authorized_path(request)- if is_authenticated:+ if is_authenticated and is_authorized:StateStore.set(Common.LOG_EVENTS_ID, request.session.session_key)response = self.get_response(request)StateStore.clear(Common.LOG_EVENTS_ID)diff --git a/backend/utils/user_session.py b/backend/utils/user_session.pyindex 888c6c353..e3cb36d0d 100644--- a/backend/utils/user_session.py+++ b/backend/utils/user_session.py@@ -1,5 +1,7 @@from typing import Optional+from django.conf import settings+from django.db import connectionfrom django.http import HttpRequestfrom tenant_account.models import OrganizationMemberfrom utils.constants import FeatureFlag@@ -34,3 +36,27 @@ class UserSessionUtils:@staticmethoddef get_organization_member_role(request: HttpRequest) -> Optional[str]:return request.session.get("role")++ @classmethod+ def is_authorized_path(cls, request: HttpRequest) -> bool:+ """Checks if the requested path is authorized based on the organization+ ID of user.++ Args:+ request (HttpRequest): The HTTP request containing session data,+ including the organization ID.++ Returns:+ bool: `True` if the path is authorized; `False` otherwise.+ """++ requested_organization_uid = connection.tenant.organization_id++ # Always authorize if the organization is public+ if requested_organization_uid == settings.PUBLIC_ORG_ID:+ return True++ # Get the session organization UID+ session_organization_uid = cls.get_organization_id(request=request)++ return requested_organization_uid == session_organization_uid