djangofloor.middleware¶
HttpRequest and WindowInfo middlewares¶
Two kinds of middlewares are provided:
- standard Django middleware,
- middlewares for populating
djangofloor.wsgi.window_info.WindowInfo
The DjangoFloorMiddleware provides several things:
- authenticates users with the settings.DF_REMOTE_USER_HEADER HTTP header,
- generates a unique ID and add it to the
django.http.request.HttpRequest,- add the ‘X-UA-Compatible’ header to the response,
- if settings.DF_FAKE_AUTHENTICATION_USERNAME and the settings.DEBUG are set, a username is set, for simplifying debug sessions,
- overrides the ‘REMOTE_ADDR’ META attribute since your project is assumed to be run behind a reverse proxy,
- if the HTTP_AUTHORIZATION header is set, use it for authenticating users (HTTP basic auth)
The class WindowInfoMiddleware allows to:
- populate a new
djangofloor.wsgi.window_info.WindowInfofrom adjango.http.request.HttpRequest,- serialize a
djangofloor.wsgi.window_info.WindowInfoto a dict,- populate a new
djangofloor.wsgi.window_info.WindowInfofrom a dict,,- populate a template context from a
djangofloor.wsgi.window_info.WindowInfoobject,- build an empty
djangofloor.wsgi.window_info.WindowInfo,- install new methods to the
djangofloor.wsgi.window_info.WindowInfoclass.
-
class
djangofloor.middleware.BasicAuthMiddleware(get_response=None)[source]¶ Deprecated class, replaced by
djangofloor.middleware.DjangoFloorMiddleware
-
class
djangofloor.middleware.BrowserMiddleware[source]¶ add attributes related to the browser (currently only the HTTP_USER_AGENT header)
-
class
djangofloor.middleware.DjangoAuthMiddleware[source]¶ handle attributes related to the
django.contrib.authframework-
get_context(window_info)[source]¶ provide the same context data as the
django.contrib.auth.context_processors:- user: a user or
django.contrib.auth.models.AnonymousUser - perms, with the same meaning
- user: a user or
-
-
class
djangofloor.middleware.DjangoFloorMiddleware(get_response=None)[source]¶ Like
django.contrib.auth.middleware.RemoteUserMiddlewarebut:- can use any header defined by the setting DF_REMOTE_USER_HEADER,
- handle the HTTP_X_FORWARDED_FOR HTTP header (set the right client IP)
- handle HTTP basic authentication
- set response header for Internet Explorer (to use its most recent render engine)
-
ajax_header= 'HTTP_WINDOW_KEY'¶
-
header= None¶
-
class
djangofloor.middleware.Djangoi18nMiddleware[source]¶ Add attributes required for using i18n-related functions.
-
class
djangofloor.middleware.FakeAuthenticationMiddleware(get_response=None)[source]¶ Deprecated class, replaced by
djangofloor.middleware.DjangoFloorMiddleware-
group_cache= {}¶
-
-
class
djangofloor.middleware.IEMiddleware(get_response=None)[source]¶ Deprecated since version 1.0: replaced by
djangofloor.middleware.DjangoFloorMiddleware
-
class
djangofloor.middleware.RemoteUserMiddleware(get_response=None)[source]¶ Deprecated class, replaced by
djangofloor.middleware.DjangoFloorMiddleware-
header= None¶
-
-
class
djangofloor.middleware.WindowInfoMiddleware[source]¶ Base class for the WindowInfo middlewares.