diff --git a/openid_provider/lib/utils/http.py b/openid_provider/lib/utils/http.py deleted file mode 100644 index 9b6a710..0000000 --- a/openid_provider/lib/utils/http.py +++ /dev/null @@ -1,27 +0,0 @@ -import json - -from django.core.serializers.json import DjangoJSONEncoder -from django.http import HttpResponse - - -# CLass JsonResponse see: https://github.com/django/django/blob/master/django/http/response.py#L456 - -class JsonResponse(HttpResponse): - """ - An HTTP response class that consumes data to be serialized to JSON. - :param data: Data to be dumped into json. By default only ``dict`` objects - are allowed to be passed due to a security flaw before EcmaScript 5. See - the ``safe`` parameter for more information. - :param encoder: Should be an json encoder class. Defaults to - ``django.core.serializers.json.DjangoJSONEncoder``. - :param safe: Controls if only ``dict`` objects may be serialized. Defaults - to ``True``. - """ - - -def __init__(self, data, encoder=DjangoJSONEncoder, safe=True, **kwargs): - if safe and not isinstance(data, dict): - raise TypeError('In order to allow non-dict objects to be serialized set the safe parameter to False') - kwargs.setdefault('content_type', 'application/json') - data = json.dumps(data, cls=encoder) - super(JsonResponse, self).__init__(content=data, **kwargs) diff --git a/openid_provider/settings.py b/openid_provider/settings.py deleted file mode 100644 index 26288b8..0000000 --- a/openid_provider/settings.py +++ /dev/null @@ -1,83 +0,0 @@ -from django.conf import settings - - -class DefaultSettings(object): - - @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() - -def get(name): - ''' - Helper function to use inside the package. - ''' - try: - value = getattr(default_settings, name) - value = getattr(settings, name) - except AttributeError: - if value == None: - raise Exception('You must set ' + name + ' in your settings.') - - return value \ No newline at end of file