-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.py
173 lines (134 loc) · 5.28 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
"""
These settings act as reference for the consumer.
The provider is the one where the user initially signs up.
The consumer is the one where the user signs up on a different
website but uses the initial website's "account" to authenticate
on the second site.
Django settings for consumer project.
Generated by 'django-admin startproject' using Django 3.2.
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# IMPORTANT SETTINGS! IMPORTANT SETTINGS! IMPORTANT SETTINGS! IMPORTANT SETTINGS!
# These are settings I changed from Django's default settings or added
# -------------------------------------------------------------------------------
INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# What I added:
"django.contrib.sites",
"allauth",
"allauth.account",
"allauth.socialaccount",
# "public" is needed in this case because I needed to add a migration
# for a domain to be loaded in the Sites module. Additionally,
# this is also where we load our custom provider
"public",
]
SITE_ID = 1
# This is if you want the scope to have scope=email
# SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
"custom": {
"APP": {
# This is from your application.
"client_id": "wOzvSUDj4oWKOVJbiapZsZSEj6eqWjwhRFAtTBm1",
"secret": "PTKjyF18FeZp9FbQJdc0CH41sZTAsvA2XUuvWx4oeQWghr3h73t"
"uopbNP0brdG5iIinJGCQpgkCo9Cvf1XxCad4TH95BDrfUKTFSN5Kiek0wXnZSV"
"Vd0KWLkTj42tllG",
# "SCOPE" key doesn't work for some reason. We use provider.py
# to overload the default scope "SCOPE": ["openid"],
}
}
}
# I have an index.html set up here
LOGIN_REDIRECT_URL = "/"
# These values are the default set by allauth
# ---------------------------------------------------------------
SOCIALACCOUNT_AUTO_SIGNUP = True
# ---------------------------------------------------------------
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": ["templates"],
"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",
],
},
},
]
# I've chosen to disable regular mail-based signup, so I've implemented
# an adapter from django-allauth. It's disabled in GitHub since the following
# line is commented out, but you can totally take advantage of allauth's extensibility
ACCOUNT_ADAPTER = "public.adapters.AccountAdapter"
# Only needed if you want an adapter. You don't need this
# if you don't implement adapter.py
SOCIALACCOUNT_ADAPTER = "public.adapters.SocialAccountAdapter"
# OTHER SETTINGS! OTHER SETTINGS! OTHER SETTINGS! OTHER SETTINGS! OTHER SETTINGS!
# These are part of the default Django project set up settings
# -------------------------------------------------------------------------------
# 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 = "django-insecure-v_pwpi^-+u!ha$!@(*-^-d268u9vtwvidss@pbmop#$09!x2qn"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
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 = "consumer.urls"
WSGI_APPLICATION = "consumer.wsgi.application"
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
# 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"