Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

cookie env

Mike Fortmana1c4c2f8849b
diff --git a/.env.example b/.env.example
index 4ad67a9f9..2fb9f3475 100644
--- a/.env.example
+++ b/.env.example
@@ -101,6 +101,8 @@ OPENSEARCH_INDEX_NAME=documents
IBM_AUTH_ENABLED=false
# URL to fetch IBM's JWT public key (used to validate ibm-lh-console-session tokens).
IBM_JWT_PUBLIC_KEY_URL=
+# Cookie name set by Traefik after successful IBM AMS authentication (default: ibm-openrag-session).
+IBM_SESSION_COOKIE_NAME=ibm-openrag-session
# make here https://console.cloud.google.com/apis/credentials
GOOGLE_OAUTH_CLIENT_ID=
diff --git a/src/api/auth.py b/src/api/auth.py
index 1071be2dd..f821b1212 100644
--- a/src/api/auth.py
+++ b/src/api/auth.py
@@ -143,15 +143,15 @@ async def ibm_login(request: Request):
Local dev (no Traefik): stores the Basic Auth header in ibm-auth-basic
cookie so subsequent requests can be authenticated by _get_ibm_user.
"""
- from config.settings import IBM_AUTH_ENABLED
+ from config.settings import IBM_AUTH_ENABLED, IBM_SESSION_COOKIE_NAME
if not IBM_AUTH_ENABLED:
raise HTTPException(status_code=404, detail="IBM auth is not enabled")
response = JSONResponse({"status": "ok"})
- # Local dev fallback only — in production Traefik sets ibm-openrag-session.
- if not request.cookies.get("ibm-openrag-session"):
+ # Local dev fallback only — in production Traefik sets the session cookie.
+ if not request.cookies.get(IBM_SESSION_COOKIE_NAME):
auth_header = request.headers.get("Authorization", "")
if auth_header.startswith("Basic "):
response.set_cookie(
diff --git a/src/config/settings.py b/src/config/settings.py
index 732c68940..0e14f743c 100644
--- a/src/config/settings.py
+++ b/src/config/settings.py
@@ -52,6 +52,7 @@ GOOGLE_OAUTH_CLIENT_SECRET = os.getenv("GOOGLE_OAUTH_CLIENT_SECRET")
# IBM AMS authentication (Watsonx Data embedded mode)
IBM_AUTH_ENABLED = os.getenv("IBM_AUTH_ENABLED", "false").lower() in ("true", "1", "yes")
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")
DOCLING_OCR_ENGINE = os.getenv("DOCLING_OCR_ENGINE")
IBM_AUTH_ENABLED = os.getenv("IBM_AUTH_ENABLED", "false").lower() in ("true", "1", "yes")
diff --git a/src/dependencies.py b/src/dependencies.py
index 04ddb6fa9..75108501a 100644
--- a/src/dependencies.py
+++ b/src/dependencies.py
@@ -102,9 +102,10 @@ def _get_ibm_user(request: Request, required: bool) -> Optional["User"]:
"""
import base64
import auth.ibm_auth as ibm_auth
+ from config.settings import IBM_SESSION_COOKIE_NAME
# ── Option 1: ibm-openrag-session cookie (production via Traefik) ───
- ibm_token = request.cookies.get("ibm-openrag-session")
+ ibm_token = request.cookies.get(IBM_SESSION_COOKIE_NAME)
if ibm_token:
claims = ibm_auth.decode_ibm_jwt(ibm_token)
if claims is not None: