Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/backend/base/langflow/services/auth/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from __future__ import annotations

from functools import lru_cache
from typing import TYPE_CHECKING, Annotated

from fastapi import Depends, Request, Security, WebSocket
from fastapi.security import APIKeyHeader, APIKeyQuery, OAuth2PasswordBearer
from lfx.services.deps import injectable_session_scope
from sqlmodel.ext.asyncio.session import AsyncSession

Check failure on line 9 in src/backend/base/langflow/services/auth/utils.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (TC002)

src/backend/base/langflow/services/auth/utils.py:9:42: TC002 Move third-party import `sqlmodel.ext.asyncio.session.AsyncSession` into a type-checking block

from langflow.services.auth.service import (
AUTO_LOGIN_ERROR as SERVICE_AUTO_LOGIN_ERROR,
Expand All @@ -13,7 +14,7 @@
from langflow.services.auth.service import (
AUTO_LOGIN_WARNING as SERVICE_AUTO_LOGIN_WARNING,
)
from langflow.services.database.models.user.model import User, UserRead

Check failure on line 17 in src/backend/base/langflow/services/auth/utils.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (TC001)

src/backend/base/langflow/services/auth/utils.py:17:64: TC001 Move application import `langflow.services.database.models.user.model.UserRead` into a type-checking block

Check failure on line 17 in src/backend/base/langflow/services/auth/utils.py

View workflow job for this annotation

GitHub Actions / Ruff Style Check (3.13)

Ruff (TC001)

src/backend/base/langflow/services/auth/utils.py:17:58: TC001 Move application import `langflow.services.database.models.user.model.User` into a type-checking block
from langflow.services.deps import get_auth_service

if TYPE_CHECKING:
Expand Down Expand Up @@ -155,7 +156,7 @@


def decrypt_api_key(encrypted_api_key: str) -> str:
return _auth_service().decrypt_api_key(encrypted_api_key)
return _cached_auth_service().decrypt_api_key(encrypted_api_key)


async def get_current_user_mcp(
Expand All @@ -169,3 +170,11 @@

async def get_current_active_user_mcp(current_user: Annotated[User, Depends(get_current_user_mcp)]) -> User:
return await _auth_service().get_current_active_user_mcp(current_user)


@lru_cache(maxsize=1)
def _cached_auth_service():
# Caches the auth service instance for faster access
from langflow.services.deps import get_auth_service

return get_auth_service()
2 changes: 1 addition & 1 deletion src/lfx/src/lfx/_assets/component_index.json

Large diffs are not rendered by default.

Loading