From 12d9c72673973c62c1d45cf608988008e50d0abe Mon Sep 17 00:00:00 2001 From: pablodanswer Date: Wed, 4 Dec 2024 11:40:01 -0800 Subject: [PATCH] proper org --- backend/danswer/auth/users.py | 6 +----- backend/danswer/db/engine.py | 2 +- backend/danswer/main.py | 2 +- backend/danswer/server/manage/users.py | 2 +- backend/danswer/server/utils.py | 8 ++++++++ deployment/cloud_kubernetes/workers/beat.yaml | 2 +- deployment/cloud_kubernetes/workers/heavy_worker.yaml | 2 +- deployment/cloud_kubernetes/workers/indexing_worker.yaml | 2 +- deployment/cloud_kubernetes/workers/light_worker.yaml | 2 +- deployment/cloud_kubernetes/workers/primary.yaml | 2 +- 10 files changed, 17 insertions(+), 13 deletions(-) diff --git a/backend/danswer/auth/users.py b/backend/danswer/auth/users.py index cf3de018f4b..84f9d279174 100644 --- a/backend/danswer/auth/users.py +++ b/backend/danswer/auth/users.py @@ -87,6 +87,7 @@ from danswer.db.models import OAuthAccount from danswer.db.models import User from danswer.db.users import get_user_by_email +from danswer.server.utils import BasicAuthenticationError from danswer.utils.logger import setup_logger from danswer.utils.telemetry import optional_telemetry from danswer.utils.telemetry import RecordType @@ -99,11 +100,6 @@ logger = setup_logger() -class BasicAuthenticationError(HTTPException): - def __init__(self, detail: str): - super().__init__(status_code=status.HTTP_403_FORBIDDEN, detail=detail) - - def is_user_admin(user: User | None) -> bool: if AUTH_TYPE == AuthType.DISABLED: return True diff --git a/backend/danswer/db/engine.py b/backend/danswer/db/engine.py index 892448c2007..8ad8eca7a0f 100644 --- a/backend/danswer/db/engine.py +++ b/backend/danswer/db/engine.py @@ -23,7 +23,6 @@ from sqlalchemy.orm import Session from sqlalchemy.orm import sessionmaker -from danswer.auth.users import BasicAuthenticationError from danswer.configs.app_configs import LOG_POSTGRES_CONN_COUNTS from danswer.configs.app_configs import LOG_POSTGRES_LATENCY from danswer.configs.app_configs import POSTGRES_API_SERVER_POOL_OVERFLOW @@ -38,6 +37,7 @@ from danswer.configs.app_configs import POSTGRES_USER from danswer.configs.app_configs import USER_AUTH_SECRET from danswer.configs.constants import POSTGRES_UNKNOWN_APP_NAME +from danswer.server.utils import BasicAuthenticationError from danswer.utils.logger import setup_logger from shared_configs.configs import MULTI_TENANT from shared_configs.configs import POSTGRES_DEFAULT_SCHEMA diff --git a/backend/danswer/main.py b/backend/danswer/main.py index 571c884b3b0..752c5fbcaad 100644 --- a/backend/danswer/main.py +++ b/backend/danswer/main.py @@ -25,7 +25,6 @@ from danswer.auth.schemas import UserRead from danswer.auth.schemas import UserUpdate from danswer.auth.users import auth_backend -from danswer.auth.users import BasicAuthenticationError from danswer.auth.users import create_danswer_oauth_router from danswer.auth.users import fastapi_users from danswer.configs.app_configs import APP_API_PREFIX @@ -92,6 +91,7 @@ from danswer.server.token_rate_limits.api import ( router as token_rate_limit_settings_router, ) +from danswer.server.utils import BasicAuthenticationError from danswer.setup import setup_danswer from danswer.setup import setup_multitenant_danswer from danswer.utils.logger import setup_logger diff --git a/backend/danswer/server/manage/users.py b/backend/danswer/server/manage/users.py index 12fe7ef29dc..2199fd76666 100644 --- a/backend/danswer/server/manage/users.py +++ b/backend/danswer/server/manage/users.py @@ -26,7 +26,6 @@ from danswer.auth.noauth_user import set_no_auth_user_preferences from danswer.auth.schemas import UserRole from danswer.auth.schemas import UserStatus -from danswer.auth.users import BasicAuthenticationError from danswer.auth.users import current_admin_user from danswer.auth.users import current_curator_or_admin_user from danswer.auth.users import current_user @@ -60,6 +59,7 @@ from danswer.server.models import FullUserSnapshot from danswer.server.models import InvitedUserSnapshot from danswer.server.models import MinimalUserSnapshot +from danswer.server.utils import BasicAuthenticationError from danswer.server.utils import send_user_email_invite from danswer.utils.logger import setup_logger from danswer.utils.variable_functionality import fetch_ee_implementation_or_noop diff --git a/backend/danswer/server/utils.py b/backend/danswer/server/utils.py index 68e6dc8d0b8..f59066f9c72 100644 --- a/backend/danswer/server/utils.py +++ b/backend/danswer/server/utils.py @@ -6,6 +6,9 @@ from textwrap import dedent from typing import Any +from fastapi import HTTPException +from fastapi import status + from danswer.configs.app_configs import SMTP_PASS from danswer.configs.app_configs import SMTP_PORT from danswer.configs.app_configs import SMTP_SERVER @@ -14,6 +17,11 @@ from danswer.db.models import User +class BasicAuthenticationError(HTTPException): + def __init__(self, detail: str): + super().__init__(status_code=status.HTTP_403_FORBIDDEN, detail=detail) + + class DateTimeEncoder(json.JSONEncoder): """Custom JSON encoder that converts datetime objects to ISO format strings.""" diff --git a/deployment/cloud_kubernetes/workers/beat.yaml b/deployment/cloud_kubernetes/workers/beat.yaml index ecd5a121900..cfe7f79cd91 100644 --- a/deployment/cloud_kubernetes/workers/beat.yaml +++ b/deployment/cloud_kubernetes/workers/beat.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: celery-beat - image: danswer/danswer-backend-cloud:v0.12.0-cloud.beta.10 + image: danswer/danswer-backend-cloud:v0.14.0-cloud.beta.4 imagePullPolicy: IfNotPresent command: [ diff --git a/deployment/cloud_kubernetes/workers/heavy_worker.yaml b/deployment/cloud_kubernetes/workers/heavy_worker.yaml index 3a4ce1a3805..349ebb4f21e 100644 --- a/deployment/cloud_kubernetes/workers/heavy_worker.yaml +++ b/deployment/cloud_kubernetes/workers/heavy_worker.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: celery-worker-heavy - image: danswer/danswer-backend-cloud:v0.12.0-cloud.beta.12 + image: danswer/danswer-backend-cloud:v0.14.0-cloud.beta.4 imagePullPolicy: IfNotPresent command: [ diff --git a/deployment/cloud_kubernetes/workers/indexing_worker.yaml b/deployment/cloud_kubernetes/workers/indexing_worker.yaml index 36ce0da1400..443bf236e00 100644 --- a/deployment/cloud_kubernetes/workers/indexing_worker.yaml +++ b/deployment/cloud_kubernetes/workers/indexing_worker.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: celery-worker-indexing - image: danswer/danswer-backend-cloud:v0.12.0-cloud.beta.12 + image: danswer/danswer-backend-cloud:v0.14.0-cloud.beta.4 imagePullPolicy: IfNotPresent command: [ diff --git a/deployment/cloud_kubernetes/workers/light_worker.yaml b/deployment/cloud_kubernetes/workers/light_worker.yaml index 171aa284fa7..eaa2ad7b92c 100644 --- a/deployment/cloud_kubernetes/workers/light_worker.yaml +++ b/deployment/cloud_kubernetes/workers/light_worker.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: celery-worker-light - image: danswer/danswer-backend-cloud:v0.12.0-cloud.beta.12 + image: danswer/danswer-backend-cloud:v0.14.0-cloud.beta.4 imagePullPolicy: IfNotPresent command: [ diff --git a/deployment/cloud_kubernetes/workers/primary.yaml b/deployment/cloud_kubernetes/workers/primary.yaml index 3f30eeb0a26..ae365b1516c 100644 --- a/deployment/cloud_kubernetes/workers/primary.yaml +++ b/deployment/cloud_kubernetes/workers/primary.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: celery-worker-primary - image: danswer/danswer-backend-cloud:v0.12.0-cloud.beta.12 + image: danswer/danswer-backend-cloud:v0.14.0-cloud.beta.4 imagePullPolicy: IfNotPresent command: [