Make OIDC_AFTER_USERLOGIN_HOOK to be lazy imported by string.
This commit is contained in:
parent
889eb47c16
commit
73ece1bf64
|
@ -56,3 +56,10 @@ def default_sub_generator(user):
|
|||
Default function for setting OIDC_IDTOKEN_SUB_GENERATOR.
|
||||
"""
|
||||
return str(user.id)
|
||||
|
||||
|
||||
def default_after_userlogin_hook(request, user, client):
|
||||
"""
|
||||
Default function for setting OIDC_AFTER_USERLOGIN_HOOK.
|
||||
"""
|
||||
return None
|
||||
|
|
|
@ -25,10 +25,7 @@ class DefaultSettings(object):
|
|||
OPTIONAL. Provide a way to plug into the process after
|
||||
the user has logged in, typically to perform some business logic.
|
||||
"""
|
||||
def default_hook_func(request, user, client):
|
||||
return None
|
||||
|
||||
return default_hook_func
|
||||
return 'oidc_provider.lib.utils.common.default_after_userlogin_hook'
|
||||
|
||||
@property
|
||||
def OIDC_CODE_EXPIRE(self):
|
||||
|
|
|
@ -13,11 +13,11 @@ DATABASES = {
|
|||
|
||||
SITE_ID = 1
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
MIDDLEWARE_CLASSES = [
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
)
|
||||
]
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
|
@ -35,24 +35,23 @@ LOGGING = {
|
|||
},
|
||||
}
|
||||
|
||||
INSTALLED_APPS = (
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.sites',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.admin',
|
||||
|
||||
'oidc_provider',
|
||||
)
|
||||
]
|
||||
|
||||
SECRET_KEY = 'this-is-top-secret'
|
||||
SECRET_KEY = 'this-should-be-top-secret'
|
||||
|
||||
ROOT_URLCONF = 'oidc_provider.tests.app.urls'
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
"oidc_provider/tests/templates",
|
||||
)
|
||||
TEMPLATE_DIRS = [
|
||||
'oidc_provider/tests/templates',
|
||||
]
|
||||
|
||||
# OIDC Provider settings.
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class AuthorizeView(View):
|
|||
|
||||
if request.user.is_authenticated():
|
||||
# Check if there's a hook setted.
|
||||
hook_resp = settings.get('OIDC_AFTER_USERLOGIN_HOOK')(
|
||||
hook_resp = settings.get('OIDC_AFTER_USERLOGIN_HOOK', import_str=True)(
|
||||
request=request, user=request.user,
|
||||
client=authorize.client)
|
||||
if hook_resp:
|
||||
|
|
Loading…
Reference in a new issue