From b5035621a9edb3df5460dc6c1e9a000c0d70ff71 Mon Sep 17 00:00:00 2001 From: aloftus23 Date: Thu, 14 Nov 2024 13:07:14 -0500 Subject: [PATCH] Remove unneeded django components b/c only using ORM --- .github/workflows/backend.yml | 2 +- backend/env.yml | 4 ++ backend/src/xfd_django/xfd_api/admin.py | 4 -- .../xfd_api/schema_models/api_key.py | 2 +- backend/src/xfd_django/xfd_api/tests.py | 4 -- backend/src/xfd_django/xfd_django/settings.py | 53 ++----------------- backend/src/xfd_django/xfd_django/urls.py | 23 -------- dev.env.example | 1 + 8 files changed, 10 insertions(+), 83 deletions(-) delete mode 100644 backend/src/xfd_django/xfd_api/admin.py delete mode 100644 backend/src/xfd_django/xfd_api/tests.py delete mode 100644 backend/src/xfd_django/xfd_django/urls.py diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index b60a974f..a42ba710 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -197,7 +197,7 @@ jobs: AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} deploy_integration: - needs: [build_worker, lint, test, test_worker] + needs: [build_worker, test_worker] runs-on: ubuntu-latest environment: integration concurrency: '1' diff --git a/backend/env.yml b/backend/env.yml index 8f604f8a..74e084f5 100644 --- a/backend/env.yml +++ b/backend/env.yml @@ -21,6 +21,7 @@ staging-cd: COGNITO_URL: https://cognito-idp.us-east-1.amazonaws.com BACKEND_DOMAIN: https://api.staging-cd.crossfeed.cyber.dhs.gov EMAIL_REGION: us-east-1 + DJANGO_KEY: ${ssm:/crossfeed/staging/DJANGO_KEY} DB_DIALECT: postgres DB_PORT: 5432 DB_HOST: ${ssm:/crossfeed/staging/DATABASE_HOST} @@ -91,6 +92,7 @@ integration: COGNITO_URL: https://cognito-idp.us-east-1.amazonaws.com BACKEND_DOMAIN: https://api.integration.crossfeed.cyber.dhs.gov EMAIL_REGION: us-east-1 + DJANGO_KEY: ${ssm:/crossfeed/integration/DJANGO_KEY} DB_DIALECT: postgres DB_PORT: 5432 DB_HOST: ${ssm:/crossfeed/integration/DATABASE_HOST} @@ -152,6 +154,7 @@ staging: COGNITO_URL: https://cognito-idp.us-gov-west-1.amazonaws.com BACKEND_DOMAIN: https://api.staging.crossfeed.cyber.dhs.gov EMAIL_REGION: us-gov-west-1 + DJANGO_KEY: ${ssm:/crossfeed/staging/DJANGO_KEY} DB_DIALECT: postgres DB_PORT: 5432 DB_HOST: ${ssm:/crossfeed/staging/DATABASE_HOST} @@ -207,6 +210,7 @@ prod: COGNITO_URL: https://cognito-idp.us-gov-west-1.amazonaws.com BACKEND_DOMAIN: https://api.crossfeed.cyber.dhs.gov EMAIL_REGION: us-gov-west-1 + DJANGO_KEY: ${ssm:/crossfeed/prod/DJANGO_KEY} DB_DIALECT: postgres DB_PORT: 5432 DB_HOST: ${ssm:/crossfeed/prod/DATABASE_HOST} diff --git a/backend/src/xfd_django/xfd_api/admin.py b/backend/src/xfd_django/xfd_api/admin.py deleted file mode 100644 index cd6162ad..00000000 --- a/backend/src/xfd_django/xfd_api/admin.py +++ /dev/null @@ -1,4 +0,0 @@ -# Third-Party Libraries -from django.contrib import admin - -# Register your models here. diff --git a/backend/src/xfd_django/xfd_api/schema_models/api_key.py b/backend/src/xfd_django/xfd_api/schema_models/api_key.py index 84df02af..df72342c 100644 --- a/backend/src/xfd_django/xfd_api/schema_models/api_key.py +++ b/backend/src/xfd_django/xfd_api/schema_models/api_key.py @@ -11,7 +11,7 @@ class ApiKey(BaseModel): """Pydantic model for the ApiKey model.""" - id: UUID + id: str createdAt: datetime updatedAt: datetime lastUsed: Optional[datetime] diff --git a/backend/src/xfd_django/xfd_api/tests.py b/backend/src/xfd_django/xfd_api/tests.py deleted file mode 100644 index 2884d116..00000000 --- a/backend/src/xfd_django/xfd_api/tests.py +++ /dev/null @@ -1,4 +0,0 @@ -# Third-Party Libraries -from django.test import TestCase - -# Create your tests here. diff --git a/backend/src/xfd_django/xfd_django/settings.py b/backend/src/xfd_django/xfd_django/settings.py index 6c6a4c00..18970a42 100644 --- a/backend/src/xfd_django/xfd_django/settings.py +++ b/backend/src/xfd_django/xfd_django/settings.py @@ -32,15 +32,15 @@ # SECURITY WARNING: keep the secret key used in production secret! # TODO: GET THAT LATER -SECRET_KEY = "django-insecure-255j80npx26z%x0@-7p@(qs9(yvtuuln#xuhxt_x$bbevvxnm!" +SECRET_KEY = os.getenv("DJANGO_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = [ ".execute-api.us-east-1.amazonaws.com", - "https://api.staging-cd.crossfeed.cyber.dhs.gov", - "http://localhost:3000", + os.getenv('BACKEND_DOMAIN'), + os.getenv('REACT_APP_API_URL'), "http://localhost", ] @@ -55,45 +55,17 @@ # Application definition INSTALLED_APPS = [ - "django.contrib.admin", - "django.contrib.auth", "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", "xfd_api.apps.XfdApiConfig", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", - "django.contrib.sessions.middleware.SessionMiddleware", - "django.middleware.common.CommonMiddleware", - "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = "xfd_django.urls" - -TEMPLATES = [ - { - "BACKEND": "django.template.backends.django.DjangoTemplates", - "DIRS": [], - "APP_DIRS": True, - "OPTIONS": { - "context_processors": [ - "django.template.context_processors.debug", - "django.template.context_processors.request", - "django.contrib.auth.context_processors.auth", - "django.contrib.messages.context_processors.messages", - ], - }, - }, -] - -WSGI_APPLICATION = "xfd_django.wsgi.application" - # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases @@ -112,25 +84,6 @@ } } -# Password validation -# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", - }, - { - "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", - }, -] - - # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ diff --git a/backend/src/xfd_django/xfd_django/urls.py b/backend/src/xfd_django/xfd_django/urls.py deleted file mode 100644 index 523c0b8e..00000000 --- a/backend/src/xfd_django/xfd_django/urls.py +++ /dev/null @@ -1,23 +0,0 @@ -""" -URL configuration for xfd_django project. - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/4.2/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -# Third-Party Libraries -from django.contrib import admin -from django.urls import path - -urlpatterns = [ - path("admin/", admin.site.urls), -] diff --git a/dev.env.example b/dev.env.example index 057610ff..b156f869 100644 --- a/dev.env.example +++ b/dev.env.example @@ -111,3 +111,4 @@ PE_FARGATE_TASK_DEFINITION_NAME=pe-staging-worker PYTHONPATH=src/xfd_django DJANGO_SETTINGS_MODULE=xfd_django.settings +DJANGO_KEY=CHANGE_ME