Below are the basic steps need to get django-all-access integrated into your Django project.
You need to add
allaccess to your installed apps as well as include an
additional authentication backend in your project settings. django-all-access requires
which are enabled in Django by default.
django.contrib.admin is recommended
for managing the set of providers, but is not required.
INSTALLED_APPS = ( # Required contrib apps 'django.contrib.auth', 'django.contrib.sessions', 'django.contrib.messages', # Optional 'django.contrib.admin', # Other installed apps would go here 'allaccess', ) AUTHENTICATION_BACKENDS = ( # Default backend 'django.contrib.auth.backends.ModelBackend', # Additional backend 'allaccess.backends.AuthorizedServiceBackend', )
AUTHENTICATION_BACKENDS is not included in the default settings
startproject. If you want to continue to use the default
username/password based authentication, you should be sure to include
django.contrib.auth.backends.ModelBackend in this setting.
By default, django-all-access uses the built-in Django settings
LOGIN_REDIRECT_URL. You should be sure that these are set to valid URLs for
To use the default redirect and callback views, you should include them in your root URL configuration.
from django.conf.urls import include urlpatterns = [ # Other URL patterns would go here url(r'^accounts/', include('allaccess.urls')), ]
This makes the login URL for a particular provider
/accounts/login/facebook/. Once the user
has authenticated with the remote provider, they will be sent back to
/accounts/callback/<provider>/, such as
Create Database Tables¶
You’ll need to create the necessary database tables for storing OAuth providers and
user associations with those providers. This is done with the
command built into Django:
python manage.py migrate allaccess
At this point your project is configured to use the default django-all-access authentication, but no providers have been added. Continue reading to learn how to add providers for your project.