🔧 fix(endpoints.py): add current_user dependency to get_all endpoint to enforce authentication and authorization

🚀 feat(endpoints.py): import User model and get_current_active_user function to enable authentication and authorization in get_all endpoint
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-25 16:29:15 -03:00
commit 132642347f

View file

@ -1,9 +1,11 @@
from http import HTTPStatus
from typing import Annotated, Optional, Union
from langflow.services.auth.utils import get_current_active_user
from langflow.services.cache.utils import save_uploaded_file
from langflow.services.database.models.flow import Flow
from langflow.processing.process import process_graph_cached, process_tweaks
from langflow.services.database.models.user.user import User
from langflow.services.utils import get_settings_manager
from langflow.utils.logger import logger
from fastapi import APIRouter, Depends, HTTPException, UploadFile, Body
@ -33,7 +35,7 @@ router = APIRouter(tags=["Base"])
@router.get("/all")
def get_all():
def get_all(current_user: User = Depends(get_current_active_user)):
logger.debug("Building langchain types dict")
native_components = build_langchain_types_dict()
# custom_components is a list of dicts