OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
chore: Remove platform authentication (#2136)
Edwin Jose1f02aad4a394
diff --git a/docker-compose.yml b/docker-compose.ymlindex 3fbdd9a66..2b8a9e7f7 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -122,8 +122,6 @@ services:- IBM_AUTH_ENABLED=${IBM_AUTH_ENABLED:-false}- OPENRAG_AZURE_BLOB_ENABLED=${OPENRAG_AZURE_BLOB_ENABLED:-true}- PLATFORM_AUTH_DEV_MODE=${PLATFORM_AUTH_DEV_MODE:-false}- - PLATFORM_USERNAME=${PLATFORM_USERNAME}- - PLATFORM_PASSWORD=${PLATFORM_PASSWORD}- DOCLING_SERVE_URL=${DOCLING_SERVE_URL:-http://host.docker.internal:5001}- DOCLING_SERVE_VERIFY_SSL=${DOCLING_SERVE_VERIFY_SSL:-true}volumes:diff --git a/src/auth/request_identity.py b/src/auth/request_identity.pyindex da6b4cebc..11014f91e 100644--- a/src/auth/request_identity.py+++ b/src/auth/request_identity.py@@ -206,7 +206,6 @@ async def _get_ibm_user(request: Request, required: bool) -> Optional["User"]:1. Configured session cookie. When JWT-role sync is enabled, the JWT isinstead read from the gateway-forwarded header named by ``get_jwt_auth_header()``;identity and roles both come from that token.- 2. Local dev basic-auth cookie.If *required* is True, raises HTTP 401 when none is present.If *required* is False, returns None instead of raising.@@ -214,33 +213,9 @@ async def _get_ibm_user(request: Request, required: bool) -> Optional["User"]:import auth.ibm_auth as ibm_authfrom auth.ibm_auth import extract_ibm_credentialsfrom auth.jwt_roles import jwt_roles_enabled- from config.settings import (- IBM_SESSION_COOKIE_NAME,- PLATFORM_PASSWORD,- PLATFORM_USERNAME,- get_jwt_auth_header,- )+ from config.settings import IBM_SESSION_COOKIE_NAME, get_jwt_auth_headerfrom config.utils import resolve_jwt_claims- # ── Option -1: Environment variable override (local dev/calls) ───────-- if PLATFORM_USERNAME and PLATFORM_PASSWORD:- logger.debug("[AUTH] Using PLATFORM_USERNAME and PLATFORM_PASSWORD from environment")- creds = f"{PLATFORM_USERNAME}:{PLATFORM_PASSWORD}"- lh_credentials = base64.b64encode(creds.encode()).decode()- user = User(- user_id=PLATFORM_USERNAME,- email=PLATFORM_USERNAME,- name=PLATFORM_USERNAME,- picture=None,- provider="ibm_ams_env",- jwt_token=f"Basic {lh_credentials}",- opensearch_username=PLATFORM_USERNAME,- opensearch_credentials=lh_credentials,- )- request.state.user = user- return user-# When RBAC/JWT-role sync is on, the gateway forwards the end-user JWT in the# configured header; use it as the source of identity and roles. When RBAC is# off, preserve the existing ibm-openrag-session cookie flow.diff --git a/src/config/settings.py b/src/config/settings.pyindex 6d88c1cc5..637e91388 100644--- a/src/config/settings.py+++ b/src/config/settings.py@@ -196,8 +196,6 @@ MICROSOFT_ALLOWED_TENANT_IDS: set[str] | None = get_env_set("MICROSOFT_ALLOWED_T# IBM AMS authentication (Watsonx Data embedded mode)IBM_AUTH_ENABLED = os.getenv("IBM_AUTH_ENABLED", "false").lower() in ("true", "1", "yes")-PLATFORM_USERNAME = os.getenv("PLATFORM_USERNAME")-PLATFORM_PASSWORD = os.getenv("PLATFORM_PASSWORD")OPENRAG_TENANT_ID = os.getenv("OPENRAG_TENANT_ID", "openrag")IBM_JWT_PUBLIC_KEY_URL = os.getenv("IBM_JWT_PUBLIC_KEY_URL", "")IBM_SESSION_COOKIE_NAME = os.getenv("IBM_SESSION_COOKIE_NAME", "ibm-openrag-session")diff --git a/src/services/auth_service.py b/src/services/auth_service.pyindex 4bdadb75d..bcf30daa4 100644--- a/src/services/auth_service.py+++ b/src/services/auth_service.py@@ -504,7 +504,7 @@ class AuthService:# IBM auth mode: user is set by get_optional_user from IBM cookieif IBM_AUTH_ENABLED:user = getattr(request.state, "user", None)- if user and user.provider in ("ibm_ams", "ibm_ams_basic", "ibm_ams_env"):+ if user and user.provider in ("ibm_ams", "ibm_ams_basic"):return {"authenticated": True,"ibm_auth_mode": True,diff --git a/tests/unit/dependencies/test_ibm_auth.py b/tests/unit/dependencies/test_ibm_auth.pyindex c41dc90be..8fe9e72da 100644--- a/tests/unit/dependencies/test_ibm_auth.py+++ b/tests/unit/dependencies/test_ibm_auth.py@@ -17,8 +17,6 @@ from auth.request_identity import _get_ibm_user # noqa: E402async def test_ibm_header_auth_uses_opensearch_username_without_session_cookie(monkeypatch):monkeypatch.setattr("config.settings.IBM_CREDENTIALS_HEADER", "X-Test-IBM-Credentials")monkeypatch.setattr("config.settings.IBM_SESSION_COOKIE_NAME", "ibm-openrag-session")- monkeypatch.setattr("config.settings.PLATFORM_USERNAME", "")- monkeypatch.setattr("config.settings.PLATFORM_PASSWORD", "")class ConnectionManager:def __init__(self):diff --git a/tests/unit/dependencies/test_ibm_header_auth.py b/tests/unit/dependencies/test_ibm_header_auth.pyindex aed572a47..0f3a9d580 100644--- a/tests/unit/dependencies/test_ibm_header_auth.py+++ b/tests/unit/dependencies/test_ibm_header_auth.py@@ -20,7 +20,6 @@ if str(SRC) not in sys.path:sys.path.insert(0, str(SRC))import auth.ibm_auth as ibm_auth # noqa: E402-import config.settings as app_settings # noqa: E402from auth.request_identity import _get_ibm_user # noqa: E402COOKIE_NAME = "ibm-openrag-session"@@ -45,9 +44,6 @@ def _env(monkeypatch):monkeypatch.setenv("OPENRAG_ROLE_CLAIM_USER", "user")monkeypatch.delenv("OPENRAG_ROLE_CLAIM_VIEWER", raising=False)monkeypatch.setenv("OPENRAG_JWT_AUTH_HEADER", "X-OpenRAG-JWT")- # Keep the Option -1 env override from short-circuiting the function.- monkeypatch.setattr(app_settings, "PLATFORM_USERNAME", None)- monkeypatch.setattr(app_settings, "PLATFORM_PASSWORD", None)@pytest.mark.asyncio