Skip to content

Commit

Permalink
Configure project to conditionally use the new app based on environme…
Browse files Browse the repository at this point in the history
…nt configured
  • Loading branch information
ababic committed May 27, 2022
1 parent 3586e6c commit 2dca26d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 13 additions & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
"allauth.account.auth_backends.AuthenticationBackend",
]

WSGI_APPLICATION = "config.wsgi.application"

# django-allauth configuration
ACCOUNT_AUTHENTICATION_METHOD = "email"
ACCOUNT_EMAIL_REQUIRED = True
Expand All @@ -135,7 +137,17 @@
ACCOUNT_ADAPTER = "etna.users.adapters.NoSelfSignupAccountAdapter"
ACCOUNT_FORMS = {"login": "etna.users.forms.EtnaLoginForm"}

WSGI_APPLICATION = "config.wsgi.application"
# Auth0 configuration
AUTH0_DOMAIN = os.getenv("AUTH0_DOMAIN")
AUTH0_CLIENT_ID = os.getenv("AUTH0_CLIENT_ID")
AUTH0_CLIENT_SECRET = os.getenv("AUTH0_CLIENT_SECRET")
if AUTH0_DOMAIN:
INSTALLED_APPS.insert(0, "etna.auth0")
LOGIN_URL = WAGTAIL_FRONTEND_LOGIN_URL = "/login/"
AUTHENTICATION_BACKENDS.append("etna.auth0.auth_backend.Auth0Backend")
TERMINATE_SSO_SESSION_ON_LOGOUT = strtobool(
os.getenv("TERMINATE_SSO_SESSION_ON_LOGOUT", "False")
)

# Logging
# https://docs.djangoproject.com/en/3.2/topics/logging/
Expand Down
5 changes: 4 additions & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ def trigger_error(request):
private_urls = [
path("django-admin/", admin.site.urls),
path("admin/", include(wagtailadmin_urls)),
path("accounts/", include("allauth.urls")),
path("documents/", include(wagtaildocs_urls)),
path(
"accounts/",
include("etna.auth0.urls" if settings.AUTH0_DOMAIN else "allauth.urls"),
),
]

if settings.SENTRY_DEBUG_URL_ENABLED:
Expand Down

0 comments on commit 2dca26d

Please sign in to comment.