feat: add authentication requirement toggle in environment configuration

This commit is contained in:
Daulet Amirkhanov 2025-08-27 16:38:24 +01:00
parent 1b643c8355
commit 10364382eb
2 changed files with 7 additions and 1 deletions

View file

@ -124,6 +124,9 @@ ALLOW_HTTP_REQUESTS=True
# When set to False errors during data processing will be returned as info but not raised to allow handling of faulty documents
RAISE_INCREMENTAL_LOADING_ERRORS=True
# When set to True, the Cognee backend will require authentication for requests to the API.
REQUIRE_AUTHENTICATION=False
# Set this variable to True to enforce usage of backend access control for Cognee
# Note: This is only currently supported by the following databases:
# Relational: SQLite, Postgres

View file

@ -6,7 +6,10 @@ from ..get_fastapi_users import get_fastapi_users
from .get_default_user import get_default_user
# Check environment variable to determine authentication requirement
REQUIRE_AUTHENTICATION = os.getenv("REQUIRE_AUTHENTICATION", "false").lower() == "true"
REQUIRE_AUTHENTICATION = (
os.getenv("REQUIRE_AUTHENTICATION", "false").lower() == "true"
or os.getenv("ENABLE_BACKEND_ACCESS_CONTROL", "false").lower() == "true"
)
fastapi_users = get_fastapi_users()