Django client for our Authentication API (https://github.com/Kagiso-Future-Media/auth)
pip install kagiso_django_auth
Add kagiso_auth to the list of INSTALLED_APPS
in your settings.py:
INSTALLED_APPS = (
# ...,
'kagiso_auth',
)
Then add the custom backend to the list of 'AUTHENTICATION_BACKENDS`:
AUTHENTICATION_BACKENDS = (
# ...
'kagiso_auth.backends.KagisoBackend',
)
Then specify that Django is to use the KagisoUser
model as its user model.
AUTH_USER_MODEL = 'kagiso_auth.KagisoUser'
Then you will need to specify some other settings:
APP_NAME = 'Your app name'
AUTH_FROM_EMAIL = '[email protected]' # Must be whitelisted with SparkPost!
SIGN_UP_EMAIL_TEMPLATE = 'Name of your SparkPost template'
PASSWORD_RESET_EMAIL_TEMPLATE = 'Name of your SparkPost template'
AUTHOMATIC_CONFIG = {} # see http://peterhudec.github.io/authomatic/reference/config.html if you want social auth
Note that the above settings may use lambdas that receive the request as the sole argument if you wish to make your settings depend on the request.
If you want to use the generic auth UI for sign ups and password resets etc, add the following to your urls.py:
from kagiso_auth import urls as kagiso_auth_urls
url(r'', include(kagiso_auth_urls)),
Finally you need to add your Auth API (https://github.com/Kagiso-Future-Media/auth) credentials to settings.py. In production make sure you read them in from an environment variable.
AUTH_API_TOKEN = 'your-token'
AUTH_API_BASE_URL (optional - defaults to https://auth.kagiso.io) = 'xyz'
This library uses Pytest-Django (https://pytest-django.readthedocs.org/en/latest/).
pip install -r requirements.txt
py.test
py.test --ds=kagiso_auth.tests.settings.ci # For Codeship
To run the integration tests (excluded by default as they are slow):
py.test kagiso_auth/tests/integration/test_integration.py