django-oidc-provider/oidc_provider/settings.py

37 lines
822 B
Python
Raw Normal View History

from django.conf import settings
2015-03-02 20:37:54 +00:00
2015-02-18 18:07:22 +00:00
from oidc_provider.lib.claims import AbstractScopeClaims
2015-03-02 20:37:54 +00:00
def default_sub_generator(user, client):
return user.id
2015-02-26 19:14:36 +00:00
2015-03-02 20:37:54 +00:00
# Here goes all the package default settings.
default_settings = {
2015-03-02 20:37:54 +00:00
# Required.
'LOGIN_URL': None,
'SITE_URL': None,
# Optional.
'OIDC_CODE_EXPIRE': 60*10,
'OIDC_EXTRA_SCOPE_CLAIMS': AbstractScopeClaims,
'OIDC_IDTOKEN_EXPIRE': 60*10,
'OIDC_IDTOKEN_SUB_GENERATOR': default_sub_generator,
'OIDC_TOKEN_EXPIRE': 60*60,
}
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:
value = default_settings[name]
value = getattr(settings, name)
except AttributeError:
if value == None:
raise Exception('You must set ' + name + ' in your settings.')
return value