May 4, 2014, midnight

Using a imap server as authentication backend for your Django app

Authentication is always a PITA to handle when developing a webapp. It usually implies the user creating one more account to access the new resource, or the setup of complex services like LDAP.

In a scenario where the app will be used by a specific group, (like a company) the django-auth-imap can be really handy. It uses the existing IMAP server to authenticate users from your application.

This way you don't have to add a new service (like ldap), your user don't have to create another account, and most important: you don't have to store passwords in your system. Your user will be able to login simply using his company e-mail credentials.

The best part? It's dead simple to make your app authenticate against a IMAP server:

Install the django_auth_imap package

pip install django_auth_imap

Enable the backend in your


Set the imap server:


Define the access rules

IMAP_AUTH_ADMIN = ["", ""]

These rules will allow anyone whose email address ends in to login in your app. The users "sergey.brin" and "" will also be able to login at admin interface and will be considered as django superusers.

comments powered by Disqus