1+ """
2+ Django settings for BrowserStackAutomation project.
3+
4+ Generated by 'django-admin startproject' using Django 4.1.3.
5+
6+ For more information on this file, see
7+ https://docs.djangoproject.com/en/4.1/topics/settings/
8+
9+ For the full list of settings and their values, see
10+ https://docs.djangoproject.com/en/4.1/ref/settings/
11+ """
12+
13+ import glob
14+ from os .path import join
15+ import json
16+ from pathlib import Path
17+ import os
18+
19+ # Build paths inside the project like this: BASE_DIR / 'subdir'.
20+ BASE_DIR = Path (__file__ ).resolve ().parent .parent
21+
22+
23+ # Quick-start development settings - unsuitable for production
24+ # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
25+
26+ # SECURITY WARNING: keep the secret key used in production secret!
27+ SECRET_KEY = ""
28+
29+ # SECURITY WARNING: don't run with debug turned on in production!
30+ DEBUG = True
31+
32+ ALLOWED_HOSTS = []
33+
34+
35+ # Application definition
36+
37+ INSTALLED_APPS = [
38+ "django.contrib.admin" ,
39+ "django.contrib.auth" ,
40+ "django.contrib.contenttypes" ,
41+ "django.contrib.sessions" ,
42+ "django.contrib.messages" ,
43+ "django.contrib.staticfiles" ,
44+ "bootprocess.apps.BootprocessConfig" ,
45+ 'social_django' ,
46+ 'Access' ,
47+ ]
48+
49+ MIDDLEWARE = [
50+ "django.middleware.security.SecurityMiddleware" ,
51+ "django.contrib.sessions.middleware.SessionMiddleware" ,
52+ "django.middleware.common.CommonMiddleware" ,
53+ "django.middleware.csrf.CsrfViewMiddleware" ,
54+ "django.contrib.auth.middleware.AuthenticationMiddleware" ,
55+ "django.contrib.messages.middleware.MessageMiddleware" ,
56+ "django.middleware.clickjacking.XFrameOptionsMiddleware" ,
57+ 'social_django.middleware.SocialAuthExceptionMiddleware' ,
58+ ]
59+
60+ AUTHENTICATION_BACKENDS = (
61+ 'social_core.backends.google.GoogleOAuth2' ,
62+ 'django.contrib.auth.backends.ModelBackend' ,
63+ )
64+
65+ SOCIAL_AUTH_PIPELINE = (
66+ 'social_core.pipeline.social_auth.social_details' ,
67+ 'social_core.pipeline.social_auth.social_uid' ,
68+ 'social_core.pipeline.social_auth.auth_allowed' ,
69+ 'social_core.pipeline.social_auth.social_user' ,
70+ 'social_core.pipeline.user.get_username' ,
71+ 'social_core.pipeline.user.create_user' ,
72+ 'social_core.pipeline.social_auth.associate_user' ,
73+ 'social_core.pipeline.social_auth.load_extra_data' ,
74+ 'social_core.pipeline.user.user_details' ,
75+ 'social_core.pipeline.debug.debug' ,
76+ )
77+
78+ SOCIAL_AUTH_DISCONNECT_PIPELINE = (
79+ # Verifies that the social association can be disconnected from the current
80+ # user (ensure that the user login mechanism is not compromised by this
81+ # disconnection).
82+ #'social.pipeline.disconnect.allowed_to_disconnect',
83+
84+ # Collects the social associations to disconnect.
85+ 'social_core.pipeline.disconnect.get_entries' ,
86+
87+ # Revoke any access_token when possible.
88+ 'social_core.pipeline.disconnect.revoke_tokens' ,
89+
90+ # Removes the social associations.
91+ 'social_core.pipeline.disconnect.disconnect' ,
92+ )
93+
94+ ROOT_URLCONF = "BrowserStackAutomation.urls"
95+
96+ template_dirs = glob .glob (join (BASE_DIR , "templates" ))
97+
98+ TEMPLATES = [
99+ {
100+ "BACKEND" : "django.template.backends.django.DjangoTemplates" ,
101+ "DIRS" : template_dirs ,
102+ "APP_DIRS" : True ,
103+ "OPTIONS" : {
104+ "context_processors" : [
105+ "django.template.context_processors.debug" ,
106+ "django.template.context_processors.request" ,
107+ "django.contrib.auth.context_processors.auth" ,
108+ "django.contrib.messages.context_processors.messages" ,
109+ ],
110+ },
111+ },
112+ ]
113+
114+ WSGI_APPLICATION = "BrowserStackAutomation.wsgi.application"
115+
116+
117+ # Database
118+ # https://docs.djangoproject.com/en/4.1/ref/settings/#databases
119+
120+ DATABASES = {
121+ "default" : {
122+ "ENGINE" : "django.db.backends.sqlite3" ,
123+ "NAME" : BASE_DIR / "db.sqlite3" ,
124+ }
125+ }
126+
127+
128+ # Password validation
129+ # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
130+
131+ AUTH_PASSWORD_VALIDATORS = [
132+ {
133+ "NAME" : "django.contrib.auth.password_validation.UserAttributeSimilarityValidator" ,
134+ },
135+ {
136+ "NAME" : "django.contrib.auth.password_validation.MinimumLengthValidator" ,
137+ },
138+ {
139+ "NAME" : "django.contrib.auth.password_validation.CommonPasswordValidator" ,
140+ },
141+ {
142+ "NAME" : "django.contrib.auth.password_validation.NumericPasswordValidator" ,
143+ },
144+ ]
145+
146+
147+ # Internationalization
148+ # https://docs.djangoproject.com/en/4.1/topics/i18n/
149+
150+ LANGUAGE_CODE = "en-us"
151+
152+ TIME_ZONE = "UTC"
153+
154+ USE_I18N = True
155+
156+ USE_TZ = True
157+
158+
159+ # Static files (CSS, JavaScript, Images)
160+ # https://docs.djangoproject.com/en/4.1/howto/static-files/
161+
162+ STATIC_URL = "static/"
163+ STATIC_ROOT = os .path .join (BASE_DIR , 'public/' )
164+ STATICFILES_DIRS = [
165+ os .path .join (BASE_DIR , "static/" ),
166+ ]
167+ # Default primary key field type
168+ # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
169+
170+ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
171+
172+
173+ with open ('config.json' ) as data_file :
174+ data = json .load (data_file )
175+
176+
177+ SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = data ['googleapi' ]['SOCIAL_AUTH_GOOGLE_OAUTH2_KEY' ]
178+ SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = data ['googleapi' ]['SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET' ]
179+ SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS = data ['googleapi' ]['SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_DOMAINS' ]
180+
181+ USER_STATUS_CHOICES = [
182+ ('1' , 'active' ),
183+ ('2' , 'offboarding' ),
184+ ('3' , 'offboarded' ),
185+ ]
186+
187+ DEFAULT_ACCESS_GROUP = 'default_access_group'
0 commit comments