Skip to content

leebrooks0/django_auth

 
 

Repository files navigation

Kagiso Auth

Django client for our Authentication API (https://github.com/Kagiso-Future-Media/auth)

Codeship Status for Kagiso-Future-Media/django_auth codecov.io

Installation

pip install kagiso_django_auth

Usage

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'

Testing

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 95.6%
  • HTML 4.4%