diff --git a/core/__init__.py b/core/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/core/asgi.py b/core/asgi.py deleted file mode 100644 index 3b8cfe2..0000000 --- a/core/asgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -ASGI config for core project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ -""" - -import os -from core.config.base import RUNTIME_ENVIRON -from django.core.asgi import get_asgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", RUNTIME_ENVIRON) - -application = get_asgi_application() diff --git a/core/config/__init__.py b/core/config/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/core/config/base.py b/core/config/base.py deleted file mode 100644 index 173a7d5..0000000 --- a/core/config/base.py +++ /dev/null @@ -1,198 +0,0 @@ -""" -Django settings for core project. - -Generated by 'django-admin startproject' using Django 4.1. - -For more information on this file, see -https://docs.djangoproject.com/en/4.1/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/4.1/ref/settings/ -""" - -from datetime import timedelta -from pathlib import Path -from decouple import config -import dj_database_url -import os - - -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve().parent.parent.parent - -# Runtime Environment -RUNTIME_ENVIRON = "core.config.development" # when serving to production, change to '.production' - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = config("SECRET_KEY") - - -# Application definition -LOCAL_APPS = [ - "django.contrib.admin", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", -] - -OWN_APPS = [ - "authentication_service.apps.AuthenticationServiceConfig", -] - -THIRD_PARTY_APPS = [ - "rest_framework", - "rest_framework.authtoken", - "rest_framework_simplejwt", - "corsheaders", - "drf_yasg", -] - -INSTALLED_APPS = LOCAL_APPS + OWN_APPS + THIRD_PARTY_APPS - -MIDDLEWARE = [ - "django.middleware.security.SecurityMiddleware", - "django.contrib.sessions.middleware.SessionMiddleware", - - # Cors Middleware - "corsheaders.middleware.CorsMiddleware", - - "django.middleware.common.CommonMiddleware", - "django.middleware.csrf.CsrfViewMiddleware", - "django.contrib.auth.middleware.AuthenticationMiddleware", - "django.contrib.messages.middleware.MessageMiddleware", - "django.middleware.clickjacking.XFrameOptionsMiddleware", -] - -REST_FRAMEWORK = { - "DEFAULT_SCHEMA_CLASS": "rest_framework.schemas.coreapi.AutoSchema", - "DEFAULT_AUTHENTICATION_CLASSES": ( - "rest_framework.authentication.BasicAuthentication", - "rest_framework_simplejwt.authentication.JWTAuthentication", - ), -} - -SIMPLE_JWT = { - "ACCESS_TOKEN_LIFETIME": timedelta(minutes=10), - "REFRESH_TOKEN_LIFETIME": timedelta(days=1), - "ROTATE_REFRESH_TOKENS": False, - "BLACKLIST_AFTER_ROTATION": False, - "UPDATE_LAST_LOGIN": False, - "ALGORITHM": "HS256", - "SIGNING_KEY": SECRET_KEY, - "VERIFYING_KEY": None, - "AUDIENCE": None, - "ISSUER": None, - "AUTH_HEADER_TYPES": ( - "Bearer", - "JWT", - ), - "AUTH_HEADER_NAME": "HTTP_AUTHORIZATION", - "USER_ID_FIELD": "id", - "USER_ID_CLAIM": "user_id", - "USER_AUTHENTICATION_RULE": "rest_framework_simplejwt.authentication.default_user_authentication_rule", - "AUTH_TOKEN_CLASSES": ("rest_framework_simplejwt.tokens.AccessToken",), - "TOKEN_TYPE_CLAIM": "token_type", - "JTI_CLAIM": "jti", - "SLIDING_TOKEN_REFRESH_EXP_CLAIM": "refresh_exp", - "SLIDING_TOKEN_LIFETIME": timedelta(minutes=10), - "SLIDING_TOKEN_REFRESH_LIFETIME": timedelta(days=1), -} - -CORS_ALLOW_ALL_ORIGINS = ( - True # If this is used then `CORS_ALLOWED_ORIGINS` will not have any effect -) - -# CORS_ALLOW_CREDENTIALS = True -CORS_ALLOWED_ORIGINS = [ - 'http://127.0.0.1:8000', -] # If this is used, then not need to use `CORS_ALLOW_ALL_ORIGINS = True` - -ROOT_URLCONF = "core.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 = "core.wsgi.application" - - - -# Password validation -# https://docs.djangoproject.com/en/4.1/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.1/topics/i18n/ - -LANGUAGE_CODE = "en-us" - -TIME_ZONE = "UTC" - -USE_I18N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/4.1/howto/static-files/ - -STATIC_URL = "static/" - -# Default primary key field type -# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field - -DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" - -# Register custom user model -AUTH_USER_MODEL = "authentication_service.AccountUser" -# Register custom user model in admin -REGISTER_USER_MODEL = True - -# Email Backend Definition -EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" -EMAIL_HOST = "smtp.gmail.com" -EMAIL_USE_TLS = True -EMAIL_PORT = 587 -EMAIL_HOST_USER = "admin@gmail.com" -EMAIL_HOST_PASSWORD = config("EMAIL_HOST_PASSWORD") - -DEFAULT_FROM_EMAIL = 'noreply@admin.com' - - -SITE_ID = 1 - -# GOOGLE_OAUTH2_CLIENT_ID Definition -GOOGLE_OAUTH2_CLIENT_ID = config("GOOGLE_OAUTH2_CLIENT_ID") - -# Authentication Service Definition -AUTHENTICATION_SERVICE = { - "site_name": "Authentication Service", - "contact_email": "contact@authentication-service.com" -} \ No newline at end of file diff --git a/core/config/development.py b/core/config/development.py deleted file mode 100644 index d8cb7c8..0000000 --- a/core/config/development.py +++ /dev/null @@ -1,24 +0,0 @@ -from core.config.base import * #noqa - - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = config("DEBUG", cast=bool) - -ALLOWED_HOSTS = ["127.0.0.1"] - - -THIRD_PARTY_APPS += [] - -# Middleware Definition -MIDDLEWARE += [] - - -# Database -# https://docs.djangoproject.com/en/4.0/ref/settings/#databases - -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", - } -} \ No newline at end of file diff --git a/core/config/production.py b/core/config/production.py deleted file mode 100644 index 99df42b..0000000 --- a/core/config/production.py +++ /dev/null @@ -1,14 +0,0 @@ -from core.config.base import * #noqa - - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = config("DEBUG", cast=bool) - -ALLOWED_HOSTS = ["*"] - -# Database -# https://docs.djangoproject.com/en/4.0/ref/settings/#databases - -DATABASES = { - "default": dj_database_url.parse(config("DATABASE_URL")), -} \ No newline at end of file diff --git a/core/urls.py b/core/urls.py deleted file mode 100644 index 357ec9a..0000000 --- a/core/urls.py +++ /dev/null @@ -1,41 +0,0 @@ -# Django Imports -from django.contrib import admin -from django.urls import path, include, re_path -from django.conf import settings -from django.conf.urls.static import static - -# DRF YASG Imports -from drf_yasg.views import get_schema_view -from drf_yasg import openapi - -# Rest Framework Imports -from rest_framework import permissions - - -# Schema Definition -schema_view = get_schema_view( - openapi.Info( - title="Authentication Service Backend", - default_version='v1', - description="Handles storage of users and authentication of their identities.", - terms_of_service="https://www.google.com/policies/terms/", - contact=openapi.Contact(email="israelvictory87@gmail.com"), - ), - public=True, - permission_classes=(permissions.AllowAny,), -) - -urlpatterns = [ - path("admin/", admin.site.urls), - - # api version 1 routes - path("api/v1/", include("authentication_service.urls")), - - # api documentation routes - re_path(r'^swagger(?P\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'), - re_path(r'^api-doc-swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='api_doc_swagger'), - re_path(r'^api-doc-redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='api_doc_redoc'), -] - -if settings.DEBUG: - urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) \ No newline at end of file diff --git a/core/wsgi.py b/core/wsgi.py deleted file mode 100644 index cba575a..0000000 --- a/core/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for core project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ -""" - -import os -from core.config.base import RUNTIME_ENVIRON -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", RUNTIME_ENVIRON) - -application = get_wsgi_application()