Skip to content

Commit

Permalink
Google SSO enable/disable at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsarm committed Sep 2, 2024
1 parent 8d1772a commit 1a11b86
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
19 changes: 11 additions & 8 deletions coleman/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
'django.contrib.staticfiles',
'django_extensions',
'health_check',
'django_google_sso',
]

REST_ENABLED = env.bool('REST_ENABLED', False)
Expand Down Expand Up @@ -178,14 +177,18 @@
}


# Google SSO (django-google-sso)
GOOGLE_SSO_ENABLED = env.bool('GOOGLE_SSO_ENABLED', False)
SSO_SHOW_FORM_ON_ADMIN_PAGE = env.bool('SSO_SHOW_FORM_ON_ADMIN_PAGE', True)
GOOGLE_SSO_CLIENT_ID = env.str("GOOGLE_SSO_CLIENT_ID", None)
GOOGLE_SSO_CLIENT_SECRET = env.str('GOOGLE_SSO_CLIENT_SECRET', None)
GOOGLE_SSO_PROJECT_ID = env.str('GOOGLE_SSO_PROJECT_ID', "django-coleman")
GOOGLE_SSO_AUTO_CREATE_USERS = True
GOOGLE_SSO_STAFF_LIST = ["*"]
GOOGLE_SSO_ALLOWABLE_DOMAINS = env.str('GOOGLE_SSO_ALLOWABLE_DOMAINS', "gmail.com").split(',')
if GOOGLE_SSO_ENABLED:
SSO_SHOW_FORM_ON_ADMIN_PAGE = env.bool('SSO_SHOW_FORM_ON_ADMIN_PAGE', True)
GOOGLE_SSO_CLIENT_ID = env.str("GOOGLE_SSO_CLIENT_ID", None)
GOOGLE_SSO_CLIENT_SECRET = env.str('GOOGLE_SSO_CLIENT_SECRET', None)
GOOGLE_SSO_PROJECT_ID = env.str('GOOGLE_SSO_PROJECT_ID', "django-coleman")
GOOGLE_SSO_AUTO_CREATE_USERS = True
GOOGLE_SSO_STAFF_LIST = ["*"]
GOOGLE_SSO_ALLOWABLE_DOMAINS = env.str('GOOGLE_SSO_ALLOWABLE_DOMAINS', "gmail.com").split(',')
INSTALLED_APPS += ['django_google_sso']


#
# Custom configurations
Expand Down
16 changes: 10 additions & 6 deletions coleman/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
urlpatterns = [
re_path('^api/v1/', include(router.urls)),
re_path(r'^health/', include('health_check.urls')),
path(
"google_sso/", include(
"django_google_sso.urls",
namespace="django_google_sso"
)
),
]

if settings.ADMIN:
Expand All @@ -43,5 +37,15 @@
path('admin/', admin.site.urls),
] + urlpatterns

if settings.GOOGLE_SSO_ENABLED:
urlpatterns = [
path(
"google_sso/", include(
"django_google_sso.urls",
namespace="django_google_sso"
)
),
] + urlpatterns

admin.site.site_title = admin.site.site_header = settings.SITE_HEADER
admin.site.index_title = settings.INDEX_TITLE

0 comments on commit 1a11b86

Please sign in to comment.