refactor: use boolean instead of string
This commit is contained in:
parent
6a7660a7c1
commit
6572cf5cb9
3 changed files with 8 additions and 8 deletions
|
|
@ -43,9 +43,9 @@ def check_backend_access_control_mode():
|
||||||
# enable it by default if graph and vector DBs can support it, otherwise disable it
|
# enable it by default if graph and vector DBs can support it, otherwise disable it
|
||||||
multi_user_support = check_multi_user_support()
|
multi_user_support = check_multi_user_support()
|
||||||
if multi_user_support:
|
if multi_user_support:
|
||||||
return "true"
|
return True
|
||||||
else:
|
else:
|
||||||
return "false"
|
return False
|
||||||
elif backend_access_control.lower() == "true":
|
elif backend_access_control.lower() == "true":
|
||||||
# If enabled, ensure that the current graph and vector DBs can support it
|
# If enabled, ensure that the current graph and vector DBs can support it
|
||||||
multi_user_support = check_multi_user_support()
|
multi_user_support = check_multi_user_support()
|
||||||
|
|
@ -54,10 +54,10 @@ def check_backend_access_control_mode():
|
||||||
"ENABLE_BACKEND_ACCESS_CONTROL is set to true but the current graph and/or vector databases do not support multi-user access control. Please use supported databases or disable backend access control."
|
"ENABLE_BACKEND_ACCESS_CONTROL is set to true but the current graph and/or vector databases do not support multi-user access control. Please use supported databases or disable backend access control."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return "true"
|
return True
|
||||||
else:
|
else:
|
||||||
# If explicitly disabled, return false
|
# If explicitly disabled, return false
|
||||||
return "false"
|
return False
|
||||||
|
|
||||||
|
|
||||||
async def set_database_global_context_variables(dataset: Union[str, UUID], user_id: UUID):
|
async def set_database_global_context_variables(dataset: Union[str, UUID], user_id: UUID):
|
||||||
|
|
@ -81,7 +81,7 @@ async def set_database_global_context_variables(dataset: Union[str, UUID], user_
|
||||||
|
|
||||||
base_config = get_base_config()
|
base_config = get_base_config()
|
||||||
|
|
||||||
if not check_backend_access_control_mode() == "true":
|
if not check_backend_access_control_mode():
|
||||||
return
|
return
|
||||||
|
|
||||||
user = await get_user(user_id)
|
user = await get_user(user_id)
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ async def search(
|
||||||
)
|
)
|
||||||
|
|
||||||
# Use search function filtered by permissions if access control is enabled
|
# Use search function filtered by permissions if access control is enabled
|
||||||
if check_backend_access_control_mode() == "true":
|
if check_backend_access_control_mode():
|
||||||
search_results = await authorized_search(
|
search_results = await authorized_search(
|
||||||
query_type=query_type,
|
query_type=query_type,
|
||||||
query_text=query_text,
|
query_text=query_text,
|
||||||
|
|
@ -156,7 +156,7 @@ async def search(
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# This is for maintaining backwards compatibility
|
# This is for maintaining backwards compatibility
|
||||||
if check_backend_access_control_mode() == "true":
|
if check_backend_access_control_mode():
|
||||||
return_value = []
|
return_value = []
|
||||||
for search_result in search_results:
|
for search_result in search_results:
|
||||||
prepared_search_results = await prepare_search_result(search_result)
|
prepared_search_results = await prepare_search_result(search_result)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ logger = get_logger("get_authenticated_user")
|
||||||
# Check environment variable to determine authentication requirement
|
# Check environment variable to determine authentication requirement
|
||||||
REQUIRE_AUTHENTICATION = (
|
REQUIRE_AUTHENTICATION = (
|
||||||
os.getenv("REQUIRE_AUTHENTICATION", "false").lower() == "true"
|
os.getenv("REQUIRE_AUTHENTICATION", "false").lower() == "true"
|
||||||
or check_backend_access_control_mode() == "true"
|
or check_backend_access_control_mode()
|
||||||
)
|
)
|
||||||
|
|
||||||
fastapi_users = get_fastapi_users()
|
fastapi_users = get_fastapi_users()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue