예제 #1
0
class Prod(Common):
    DEBUG = True
    DOMAIN = "ec2-18-223-15-184.us-east-2.compute.amazonaws.com"
    #    Common.ALLOWED_HOSTS += ["18.223.15.184", "ec2-18-223-15-184.us-east-2.compute.amazonaws.com", "ec2-3-19-221-117.us-east-2.compute.amazonaws.com", "https://script.google.com"]
    PROTOCOL = "http"
    CORS_ALLOW_HEADERS = (
        "accept",
        "accept-encoding",
        "authorization",
        "content-type",
        "dnt",
        "origin",
        "user-agent",
        "x-csrftoken",
        "x-requested-with",
        "range",
    )
    CORS_ALLOW_CREDENTIALS = True
    SECURE_HSTS_SECONDS = 60
    SECURE_CONTENT_TYPE_NOSNIFF = False
    SESSION_COOKIE_SECURE = False
    CSRF_COOKIE_SECURE = False
    SECURE_BROWSER_XSS_FILTER = False
    SECURE_SSL_REDIRECT = False
    SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", PROTOCOL)
    CSRF_TRUSTED_ORIGINS = [DOMAIN]
    EMAIL_BACKEND = "django_ses.SESBackend"
    DEFAULT_FROM_EMAIL = "Test <*****@*****.**>"
    CORS_ALLOW_ALL_ORIGINS = True
    AWS_ACCESS_KEY_ID = get_secret("AWS_ACCESS_KEY_ID")
    AWS_SECRET_ACCESS_KEY = get_secret("AWS_SECRET_ACCESS_KEY")
예제 #2
0
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os

from manage import get_secret

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = get_secret("FEEDBACK_SECRET")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ["*"]

# Application definition

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
예제 #3
0
파일: asgi.py 프로젝트: ptuckett86/calendar
"""
ASGI config for calendar_events 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/3.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application
from manage import get_secret

env = get_secret("ENVIRONMENT").capitalize()

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "calendar_events.config")
os.environ.setdefault("DJANGO_CONFIGURATION", env)

application = get_asgi_application()
예제 #4
0
class Common(Configuration):

    # Build paths inside the project like this: BASE_DIR / 'subdir'.
    BASE_DIR = Path(__file__).resolve().parent.parent

    # Quick-start development settings - unsuitable for production
    # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

    # SECURITY WARNING: keep the secret key used in production secret!
    SECRET_KEY = get_secret("SECRET_KEY")
    DATABASES = {"default": get_secret("secret_DB")}
    LOGIN_URL = "/api/v1/auth/login/"
    ALLOWED_HOSTS = ["*"]
    ASGI_APPLICATION = "calendar_events.routing.application"
    WSGI_APPLICATION = "calendar_events.wsgi.application"
    LOGIN_REDIRECT_URL = "/"
    LANGUAGE_CODE = "en-us"
    TIME_ZONE = "UTC"
    USE_I18N = True
    USE_L10N = True
    USE_TZ = True
    AUTH_USER_MODEL = "core.AuthUser"
    # SECURITY WARNING: don't run with debug turned on in production!

    # Application definition

    INSTALLED_APPS = [
        "django.contrib.admin",
        "django.contrib.auth",
        "django.contrib.contenttypes",
        "django.contrib.sessions",
        "django.contrib.messages",
        "django.contrib.staticfiles",
        "django_filters",
        "rest_framework",
        "corsheaders",
        "calendar_events.core",
        "calendar_events.events",
    ]

    MIDDLEWARE = [
        #"corsheaders.middleware.CorsPostCsrfMiddleware",
        "django.middleware.security.SecurityMiddleware",
        "django.contrib.sessions.middleware.SessionMiddleware",
        "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",
        "calendar_events.middleware.AuthenticationMiddlewareJWT",
    ]

    ROOT_URLCONF = "calendar_events.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",
            ]
        },
    }]

    # Password validation
    # https://docs.djangoproject.com/en/3.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/3.2/topics/i18n/

    LANGUAGE_CODE = "en-us"

    TIME_ZONE = "UTC"

    USE_I18N = True

    USE_L10N = True

    USE_TZ = True

    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/3.2/howto/static-files/

    STATIC_URL = "/static/"

    # Default primary key field type
    # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

    DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
    REST_FRAMEWORK = {
        "DEFAULT_PAGINATION_CLASS":
        "calendar_events.core.pagination.CustomPagination",
        "PAGE_SIZE":
        10,
        "DATETIME_FORMAT":
        "%Y-%m-%dT%H:%M:%S%z",
        "DEFAULT_RENDERER_CLASSES": (
            "rest_framework.renderers.JSONRenderer",
            "rest_framework.renderers.BrowsableAPIRenderer",
        ),
        "DEFAULT_PERMISSION_CLASSES": [
            # 'rest_framework.permissions.IsAuthenticated',
        ],
        "DEFAULT_AUTHENTICATION_CLASSES": (
            "rest_framework_jwt.authentication.JSONWebTokenAuthentication",
            # "rest_framework.authentication.BasicAuthentication",
        ),
        "DEFAULT_FILTER_BACKENDS":
        ("django_filters.rest_framework.DjangoFilterBackend", ),
        "DEFAULT_THROTTLE_CLASSES": [
            "rest_framework.throttling.ScopedRateThrottle",
            "rest_framework.throttling.AnonRateThrottle",
        ],
        "DEFAULT_THROTTLE_RATES": {
            "anon": "5000/day",
            "user_throttle": "5000/day"
        },
    }

    JWT_AUTH = {
        "JWT_ENCODE_HANDLER": "rest_framework_jwt.utils.jwt_encode_handler",
        "JWT_DECODE_HANDLER": "rest_framework_jwt.utils.jwt_decode_handler",
        "JWT_PAYLOAD_HANDLER": "rest_framework_jwt.utils.jwt_payload_handler",
        # 'JWT_PAYLOAD_GET_USER_ID_HANDLER':
        #   'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler',
        "JWT_RESPONSE_PAYLOAD_HANDLER":
        "calendar_events.core.jwt_overrides.jwt_response_payload_handler",
        # "JWT_RESPONSE_PAYLOAD_HANDLER": "rest_framework_jwt.utils.jwt_response_payload_handler",
        "JWT_SECRET_KEY": SECRET_KEY,
        "JWT_PUBLIC_KEY": None,
        "JWT_PRIVATE_KEY": None,
        "JWT_ALGORITHM": "HS256",
        "JWT_VERIFY": True,
        "JWT_VERIFY_EXPIRATION": True,
        "JWT_LEEWAY": 0,
        "JWT_EXPIRATION_DELTA": datetime.timedelta(hours=1),
        "JWT_AUDIENCE": None,
        "JWT_ISSUER": None,
        "JWT_ALLOW_REFRESH": True,
        "JWT_REFRESH_EXPIRATION_DELTA": datetime.timedelta(days=7),
        # 'JWT_AUTH_HEADER_PREFIX': 'JWT',
        "JWT_AUTH_COOKIE": "jwt",
    }

    # Static files (CSS, JavaScript, Images)
    # https://docs.djangoproject.com/en/3.1/howto/static-files/

    STATIC_ROOT = join(os.path.dirname(BASE_DIR), "static")
    STATIC_URL = "/static/"
    STATICFILES_DIRS = ["calendar_events/static/templates"]
    STATICFILES_FINDERS = (
        "django.contrib.staticfiles.finders.FileSystemFinder",
        "django.contrib.staticfiles.finders.AppDirectoriesFinder",
    )
    MEDIA_ROOT = join(os.path.dirname(BASE_DIR), "media")
    MEDIA_URL = "/media/"
    TEMPLATES = [{
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": STATICFILES_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",
            ]
        },
    }]