diff --git a/fountain/development/__init__.py b/fountain/development/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/fountain/development/middleware.py b/fountain/development/middleware.py new file mode 100644 index 0000000000000000000000000000000000000000..fd372f390afe969e76be59a4ccc00d18a264a694 --- /dev/null +++ b/fountain/development/middleware.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals +from django.conf import settings +from django.contrib.auth.middleware import RemoteUserMiddleware +from django.core.exceptions import ImproperlyConfigured + +class LocalUserMiddleware(RemoteUserMiddleware): + """ + This middleware can be used for developing Django projects in + environments where RemoteUserMiddleware is used in production + environments and a 1:1 mapping between local user accounts and + remote users exist. + + :attention: Never use this middleware in production environments! + """ + header = 'LOGNAME' + + def __init__(self, *args, **kwargs): + super(LocalUserMiddleware, self).__init__(*args, **kwargs) + # Prevent accidental usage in production environments + if settings.DEBUG == False: + raise ImproperlyConfigured('The LocalUserMiddleware cannot be used in production environments!')