This commit is contained in:
parent
1de1cb4086
commit
997fd760d2
11 changed files with 99 additions and 37 deletions
|
|
@ -12,6 +12,7 @@ For the full list of settings and their values, see
|
|||
https://docs.djangoproject.com/en/2.2/ref/settings/
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from decouple import Csv, config
|
||||
|
|
@ -64,6 +65,15 @@ OAUTH_SERVER_URL = config("OAUTH_SERVER_URL", default="")
|
|||
OAUTH_BUTTON_TEXT = config("OAUTH_BUTTON_TEXT", default="Login with OAuth")
|
||||
OAUTH_BUTTON_IMAGE = config("OAUTH_BUTTON_IMAGE", default="")
|
||||
OAUTH_SCOPE = config("OAUTH_SCOPE", default="openid profile email", cast=Csv(delimiter=" "))
|
||||
OAUTH_STAFF_GROUPS = config("OAUTH_STAFF_GROUPS", default="", cast=Csv(delimiter=" "))
|
||||
OAUTH_GROUP_MAP = dict(
|
||||
pair.split(":", 1)
|
||||
for pair in config("OAUTH_GROUP_MAP", default="", cast=Csv(delimiter=" "))
|
||||
if ":" in pair
|
||||
)
|
||||
OAUTH_AUTHORIZE_URL = config("OAUTH_AUTHORIZE_URL", default="")
|
||||
OAUTH_TOKEN_URL = config("OAUTH_TOKEN_URL", default="")
|
||||
OAUTH_PROFILE_URL = config("OAUTH_PROFILE_URL", default="")
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"django.contrib.admin",
|
||||
|
|
@ -118,6 +128,7 @@ TEMPLATES = [
|
|||
"django.template.context_processors.request",
|
||||
"django.contrib.auth.context_processors.auth",
|
||||
"django.contrib.messages.context_processors.messages",
|
||||
"photo21.views.oauth_context",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
@ -282,16 +293,24 @@ ACCOUNT_FORMS = {"signup": "photo21.forms.CustomSignupForm"}
|
|||
|
||||
if OAUTH_ENABLED:
|
||||
SOCIALACCOUNT_ONLY = OAUTH_ONLY
|
||||
SOCIALACCOUNT_PROVIDERS = {
|
||||
"oauth": {
|
||||
"SCOPE": OAUTH_SCOPE,
|
||||
"DOMAIN": OAUTH_SERVER_URL,
|
||||
"APP": {
|
||||
"client_id": OAUTH_CLIENT_ID,
|
||||
"secret": OAUTH_CLIENT_SECRET,
|
||||
},
|
||||
if OAUTH_ONLY:
|
||||
ACCOUNT_EMAIL_VERIFICATION = 'none'
|
||||
SOCIALACCOUNT_LOGIN_ON_GET = True
|
||||
_oauth_provider = {
|
||||
"SCOPE": OAUTH_SCOPE,
|
||||
"DOMAIN": OAUTH_SERVER_URL,
|
||||
"APP": {
|
||||
"client_id": OAUTH_CLIENT_ID,
|
||||
"secret": OAUTH_CLIENT_SECRET,
|
||||
},
|
||||
}
|
||||
if OAUTH_AUTHORIZE_URL:
|
||||
_oauth_provider["AUTHORIZE_URL"] = OAUTH_AUTHORIZE_URL
|
||||
if OAUTH_TOKEN_URL:
|
||||
_oauth_provider["TOKEN_URL"] = OAUTH_TOKEN_URL
|
||||
if OAUTH_PROFILE_URL:
|
||||
_oauth_provider["PROFILE_URL"] = OAUTH_PROFILE_URL
|
||||
SOCIALACCOUNT_PROVIDERS = {"oauth": _oauth_provider}
|
||||
|
||||
# Use Bootstrap forms
|
||||
CRISPY_TEMPLATE_PACK = "bootstrap4"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue