Skip to main content

Yet another email auth system for the Django web framework

Project description

email_auth is an email based authentication backend for Django. It allows you to use Django’s built-in authentication mechanisms and User model while authenticating User on email address instead of username.

It basically re-uses the original Django auth code, passing it a custom Form to allow for email authentication. Overall application structure is based on the one used by Django CAS, i.e. a custom authentication backend and a middleware to intercept calls to original login views (especially useful if you use the Django admin).

email_auth should be compatible with Django 1.3 and 1.4 versions.

email_auth is (c) 2009-2012 Jean-Charles Bagneris. See LICENSE for redistribution information and usual disclaimer.


The easiest and prefered way is to install from PyPI, either through pip or through easy_install:

$ pip install django_email_auth

$ easy_install -U django_email_auth

You can download the sources as well, and install from source:

$ python install

Then, reference the middleware and the backend in your project’s file. Resulting settings may look like:



If you want to use the login and logout templates provided instead of custom ones, make sure that django.template.loaders.app_directories.load_template_source is in your TEMPLATE_LOADERS setting and add email_auth to your INSTALLED_APPS setting. In addition, these templates are only provided as examples, and require the Django admin app to work, so add it too to your INSTALLED_APPS. For an example:



If you subclassed the User model instead of using the get_profile mechanism, use the CUSTOM_USER_MODEL setting to indicate the name of your model. email_auth would then return an instance of your custom user model upon successful authentication:

CUSTOM_USER_MODEL = 'coaching.Utilisateur'

If you want to use a custom login view instead of the one provided (email_auth.views.login), add a LOGIN_URL_MAP settings, pointing to it (thanks to Wesley Mason for the patch).

Finally, make sure that your project sets the required urls to log your users in and out in your urls mappings:

(r'^login/$', 'email_auth.views.login'),
(r'^logout/$', 'email_auth.views.logout'),


Templates for login and logout views are supposed to live in registration/login.html and registration/logged_out.html. Standard ones are provided with email_auth, put the application in your INSTALLED_APPS and use the django.template.loaders.app_directories.load_template_source template loader if you want to use those. Otherwise, either provide yours in a registration folder in your root template folder, or pass whatever names your templates have to the template_name parameter of login and logout views.


As a convenience, signals are raised when a user logs in or out successfully:

user_logged_in = Signal(providing_args=['request',])
user_logged_out = Signal(providing_args=['request',])

The full login or logout request is passed as an arg to the related signal. In addition, the sender of the logged in signal is the logged in User instance, and the sender of the logged out signal is the User instance which just logged out.


email_auth uses Django internationalization mechanism. Make sure you have django.middleware.locale.LocaleMiddleware in your MIDDLEWARE_CLASSES settings to use it. The locale files for the French language are provided with the application. If you create locale files for other languages, feel free to fork the project and send me a pull request for those to be included in the distribution.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django_email_auth-0.1.5.tar.gz (10.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page