OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.
Python
feat(backend): Re-implement support for the JWT_SIGNING_KEY environment variable for auth...
Mike Pawlowskib64f8ee2255a
diff --git a/docker-compose.yml b/docker-compose.ymlindex b1a5c175d..494689578 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -107,6 +107,7 @@ services:- LOG_FORMAT=${LOG_FORMAT}- SERVICE_NAME=${SERVICE_NAME}- SESSION_SECRET=${SESSION_SECRET}+ - JWT_SIGNING_KEY=${JWT_SIGNING_KEY}- OPENRAG_ENCRYPTION_KEY=${OPENRAG_ENCRYPTION_KEY}- LOG_LEVEL=${LOG_LEVEL:-INFO}- NO_COLOR=${NO_COLOR:-}diff --git a/src/main.py b/src/main.pyindex eba62dc7f..86246ad96 100644--- a/src/main.py+++ b/src/main.py@@ -404,13 +404,7 @@ def generate_jwt_keys():)raiseelse:- # Ensure correct permissions on existing keys- try:- os.chmod(private_key_path, 0o600)- os.chmod(public_key_path, 0o644)- logger.info("RSA keys already exist, ensured correct permissions")- except OSError as e:- logger.error("Failed to set permissions on existing keys", error=str(e))+ logger.info("RSA keys already exist")def _get_documents_dir():@@ -1397,8 +1391,9 @@ async def initialize_services():await TelemetryClient.send_event(Category.SERVICE_INITIALIZATION, MessageId.ORB_SVC_INIT_START)- # Generate JWT keys if they don't exist- generate_jwt_keys()+ # Generate JWT keys if they don't exist and a JWT signing key isn't specified+ if not os.getenv("JWT_SIGNING_KEY"):+ generate_jwt_keys()from config.settings import IBM_AUTH_ENABLED@@ -1509,7 +1504,7 @@ async def create_app():app = FastAPI(title="OpenRAG API", version=OPENRAG_VERSION, debug=True)app.state.services = services # Store services for cleanupapp.state.background_tasks = set()-+try:Instrumentator().instrument(app).expose(app)except Exception as e:@@ -2069,14 +2064,14 @@ async def create_app():Category.APPLICATION_SHUTDOWN, MessageId.ORB_APP_SHUTDOWN)logger.info("Application shutdown initiated")-+# Gracefully shutdown OpenSearch connection firsttry:from utils.opensearch_utils import graceful_opensearch_shutdownawait graceful_opensearch_shutdown(clients.opensearch)except Exception as e:logger.error("Error during graceful OpenSearch shutdown", error=str(e))-+await cleanup_subscriptions_proper(services)# Cleanup task service (cancels background tasks and process pool)await services["task_service"].shutdown()