django-oidc-provider/oidc_provider/settings.py

73 lines
1.3 KiB
Python
Raw Normal View History

from django.conf import settings
2015-03-02 20:37:54 +00:00
2015-03-04 20:17:37 +00:00
class DefaultSettings(object):
2015-03-04 20:17:37 +00:00
@property
def LOGIN_URL(self):
"""
REQUIRED.
"""
return None
2015-03-02 20:37:54 +00:00
2015-03-04 20:17:37 +00:00
@property
def SITE_URL(self):
"""
REQUIRED.
"""
return None
2015-03-02 20:37:54 +00:00
2015-03-04 20:17:37 +00:00
@property
def OIDC_CODE_EXPIRE(self):
"""
OPTIONAL.
"""
return 60*10
2015-02-26 19:14:36 +00:00
2015-03-04 20:17:37 +00:00
@property
def OIDC_EXTRA_SCOPE_CLAIMS(self):
"""
OPTIONAL.
"""
from oidc_provider.lib.claims import AbstractScopeClaims
2015-03-02 20:37:54 +00:00
2015-03-04 20:17:37 +00:00
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
2015-03-06 15:55:50 +00:00
default_settings = DefaultSettings()
2015-03-02 20:37:54 +00:00
def get(name):
2015-03-02 20:37:54 +00:00
'''
Helper function to use inside the package.
'''
try:
2015-03-06 15:55:50 +00:00
value = getattr(default_settings, name)
2015-03-02 20:37:54 +00:00
value = getattr(settings, name)
except AttributeError:
if value == None:
raise Exception('You must set ' + name + ' in your settings.')
return value