· 4 years ago · May 13, 2021, 03:34 AM
1"""
2Django settings for auth_demo project.
3
4Generated by 'django-admin startproject' using Django 3.2.
5
6For more information on this file, see
7https://docs.djangoproject.com/en/3.2/topics/settings/
8
9For the full list of settings and their values, see
10https://docs.djangoproject.com/en/3.2/ref/settings/
11"""
12
13from pathlib import Path
14import os
15
16# Build paths inside the project like this: BASE_DIR / 'subdir'.
17BASE_DIR = Path(__file__).resolve().parent.parent
18
19
20# Quick-start development settings - unsuitable for production
21# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
22
23# SECURITY WARNING: keep the secret key used in production secret!
24SECRET_KEY = 'django-insecure-w*_xkt3@$i2y&73rvkek&4&gu=o$+mp+xhovj1y*a4a56@+@_u'
25
26# SECURITY WARNING: don't run with debug turned on in production!
27DEBUG = True
28
29ALLOWED_HOSTS = []
30
31
32# Application definition
33
34INSTALLED_APPS = [
35 'django.contrib.admin',
36 'django.contrib.auth',
37 'django.contrib.contenttypes',
38 'django.contrib.sessions',
39 'django.contrib.messages',
40 'django.contrib.staticfiles',
41 'shopify_auth',
42]
43
44MIDDLEWARE = [
45 'django.middleware.security.SecurityMiddleware',
46 'django.contrib.sessions.middleware.SessionMiddleware',
47 'django.middleware.common.CommonMiddleware',
48 'django.middleware.csrf.CsrfViewMiddleware',
49 'django.contrib.auth.middleware.AuthenticationMiddleware',
50 'django.contrib.messages.middleware.MessageMiddleware',
51 'django.middleware.clickjacking.XFrameOptionsMiddleware',
52]
53
54ROOT_URLCONF = 'auth_demo.urls'
55
56TEMPLATES = [
57 {
58 'BACKEND': 'django.template.backends.django.DjangoTemplates',
59 'DIRS': [],
60 'APP_DIRS': True,
61 'OPTIONS': {
62 'context_processors': [
63 'django.template.context_processors.debug',
64 'django.template.context_processors.request',
65 'django.contrib.auth.context_processors.auth',
66 'django.contrib.messages.context_processors.messages',
67 ],
68 },
69 },
70]
71
72WSGI_APPLICATION = 'auth_demo.wsgi.application'
73
74
75# Database
76# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
77
78DATABASES = {
79 'default': {
80 'ENGINE': 'django.db.backends.sqlite3',
81 'NAME': BASE_DIR / 'db.sqlite3',
82 }
83}
84
85
86# Password validation
87# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
88
89AUTH_PASSWORD_VALIDATORS = [
90 {
91 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
92 },
93 {
94 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
95 },
96 {
97 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
98 },
99 {
100 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
101 },
102]
103
104
105# Internationalization
106# https://docs.djangoproject.com/en/3.2/topics/i18n/
107
108LANGUAGE_CODE = 'en-us'
109
110TIME_ZONE = 'UTC'
111
112USE_I18N = True
113
114USE_L10N = True
115
116USE_TZ = True
117
118
119# Static files (CSS, JavaScript, Images)
120# https://docs.djangoproject.com/en/3.2/howto/static-files/
121
122STATIC_URL = '/static/'
123
124# Default primary key field type
125# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
126
127DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
128AUTH_USER_MODEL = 'auth_app.AuthAppShopUser'
129
130# Configure Shopify Application settings
131SHOPIFY_APP_NAME = 'XXXX'
132SHOPIFY_APP_API_KEY = os.environ.get('XXXX')
133SHOPIFY_APP_API_SECRET = os.environ.get('XXXX')
134SHOPIFY_APP_API_SCOPE = ['read_products', 'read_orders']
135# Find API version to pin at https://help.shopify.com/en/api/versioning
136SHOPIFY_APP_API_VERSION = "2021-04"
137SHOPIFY_APP_IS_EMBEDDED = False
138SHOPIFY_APP_DEV_MODE = False
139
140# Enable after the app is approved
141SHOPIFY_APP_THIRD_PARTY_COOKIE_CHECK = True
142
143# Use the Shopify Auth authentication backend as the sole authentication backend.
144AUTHENTICATION_BACKENDS = (
145 'shopify_auth.backends.ShopUserBackend',
146)
147
148# Add the Shopify Auth template context processor to the list of processors.
149# Note that this assumes you've defined TEMPLATE_CONTEXT_PROCESSORS earlier in your settings.
150TEMPLATE_CONTEXT_PROCESSORS = (
151 'shopify_auth.context_processors.shopify_auth',
152)
153
154# Use the Shopify Auth user model.
155AUTH_USER_MODEL = 'auth_app.AuthAppShopUser'
156
157# Set the login redirect URL to the "home" page for your app (where to go after logging on).
158LOGIN_REDIRECT_URL = '/'
159
160# Set secure proxy header to allow proper detection of secure URLs behind a proxy.
161# This ensures that correct 'https' URLs are generated when our Django app is running behind a proxy like nginx, or is
162# being tunneled (by ngrok, for example).
163SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')