2015-01-28 17:50:14 +00:00
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
|
2015-06-08 14:55:54 +00:00
|
|
|
class DefaultSettings(object):
|
2015-01-28 17:50:14 +00:00
|
|
|
|
2015-06-08 14:55:54 +00:00
|
|
|
@property
|
|
|
|
def LOGIN_URL(self):
|
|
|
|
"""
|
|
|
|
REQUIRED.
|
|
|
|
"""
|
|
|
|
return None
|
|
|
|
|
|
|
|
@property
|
|
|
|
def SITE_URL(self):
|
|
|
|
"""
|
|
|
|
REQUIRED.
|
|
|
|
"""
|
|
|
|
return None
|
|
|
|
|
|
|
|
@property
|
|
|
|
def OIDC_AFTER_USERLOGIN_HOOK(self):
|
|
|
|
"""
|
|
|
|
OPTIONAL.
|
|
|
|
"""
|
|
|
|
def default_hook_func(request, user, client):
|
|
|
|
return None
|
|
|
|
|
|
|
|
return default_hook_func
|
|
|
|
|
|
|
|
@property
|
|
|
|
def OIDC_CODE_EXPIRE(self):
|
|
|
|
"""
|
|
|
|
OPTIONAL.
|
|
|
|
"""
|
|
|
|
return 60*10
|
|
|
|
|
|
|
|
@property
|
|
|
|
def OIDC_EXTRA_SCOPE_CLAIMS(self):
|
|
|
|
"""
|
|
|
|
OPTIONAL.
|
|
|
|
"""
|
|
|
|
from oidc_provider.lib.claims import AbstractScopeClaims
|
|
|
|
|
|
|
|
return AbstractScopeClaims
|
|
|
|
|
|
|
|
@property
|
|
|
|
def OIDC_IDTOKEN_EXPIRE(self):
|
|
|
|
"""
|
|
|
|
OPTIONAL.
|
|
|
|
"""
|
|
|
|
return 60*10
|
|
|
|
|
|
|
|
@property
|
|
|
|
def OIDC_IDTOKEN_SUB_GENERATOR(self):
|
|
|
|
"""
|
|
|
|
OPTIONAL.
|
|
|
|
"""
|
|
|
|
def default_sub_generator(user):
|
|
|
|
return user.id
|
|
|
|
|
|
|
|
return default_sub_generator
|
|
|
|
|
|
|
|
@property
|
|
|
|
def OIDC_TOKEN_EXPIRE(self):
|
|
|
|
"""
|
|
|
|
OPTIONAL.
|
|
|
|
"""
|
|
|
|
return 60*60
|
|
|
|
|
|
|
|
default_settings = DefaultSettings()
|
2015-01-29 14:12:08 +00:00
|
|
|
|
2015-01-28 17:50:14 +00:00
|
|
|
def get(name):
|
2015-06-08 14:55:54 +00:00
|
|
|
'''
|
2015-01-29 14:12:08 +00:00
|
|
|
Helper function to use inside the package.
|
2015-06-08 14:55:54 +00:00
|
|
|
'''
|
2015-01-29 14:12:08 +00:00
|
|
|
try:
|
2015-06-08 14:55:54 +00:00
|
|
|
value = getattr(default_settings, name)
|
2015-01-29 14:12:08 +00:00
|
|
|
value = getattr(settings, name)
|
|
|
|
except AttributeError:
|
|
|
|
if value == None:
|
|
|
|
raise Exception('You must set ' + name + ' in your settings.')
|
2015-01-28 17:50:14 +00:00
|
|
|
|
2015-06-08 14:55:54 +00:00
|
|
|
return value
|