Commit ccbbc76b authored by Jon Yu's avatar Jon Yu
Browse files

Extract auth check, tweak flake8 settings

parent 72fd877e
......@@ -144,4 +144,5 @@ cython_debug/
# Misc
.DS_Store
.vscode
\ No newline at end of file
.vscode
dev/
\ No newline at end of file
[flake8]
# https://docs.djangoproject.com/en/dev/internals/contributing/writing-code/coding-style/#coding-style
max-line-length=119
exclude=migrations
exclude=*/migrations/*
from django.conf.urls import url
from django.urls import include
from django.urls import include, path
from oidc_auth.utils import using_oidc_auth
urlpatterns = [
url(r'^oidc/', include('mozilla_django_oidc.urls')),
]
if using_oidc_auth():
urlpatterns += [path('accounts/', include('django.contrib.auth.urls'))]
from django.conf import settings
def using_oidc_auth():
return (
settings.OIDC_RP_CLIENT_ID and
settings.OIDC_RP_CLIENT_SECRET and
settings.OIDC_OP_AUTHORIZATION_ENDPOINT and
settings.OIDC_OP_TOKEN_ENDPOINT and
settings.OIDC_OP_USER_ENDPOINT
)
......@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/3.0/ref/settings/
import os
import dj_database_url
from oidc_auth.utils import using_oidc_auth
def str_to_bool(val):
......@@ -129,8 +130,7 @@ OIDC_USERNAME_ALGO = 'oidc_auth.auth.generate_username'
OIDC_RP_SCOPES = 'openid email profile'
OIDC_CREATE_USER = str_to_bool(os.getenv('OIDC_CREATE_USER', 'on'))
if (OIDC_RP_CLIENT_ID and OIDC_RP_CLIENT_SECRET and OIDC_OP_AUTHORIZATION_ENDPOINT
and OIDC_OP_TOKEN_ENDPOINT and OIDC_OP_USER_ENDPOINT):
if using_oidc_auth():
EXTRA_APPS += ['mozilla_django_oidc']
AUTHENTICATION_BACKENDS += ['oidc_auth.auth.UMichOIDCBackend']
MIDDLEWARE += ['mozilla_django_oidc.middleware.SessionRefresh']
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment