Installation
============

Dependencies
------------

This library serves as a simple drop-in wrapper around those the pyseto library.


Django Server
-------------

Install the library using pip.

.. code:: bash

    pip install encipher

Add ``encipher`` to the list of ``INSTALLED_APPS`` in ``settings.py``

.. code:: python

    INSTALLED_APPS = (
        …
        'encipher',
        …
    )

Add ``encipher.middleware.PasetoAuthMiddleware`` to the list of ``MIDDLEWARE_CLASSES`` in ``settings.py``

.. code:: python

    MIDDLEWARE_CLASSES = (
        …
        'encipher.middleware.PasetoAuthMiddleware',
    )

Create the new models in your DB.

.. code:: bash

    python manage.py migrate

This creates a new relationship on the ``django.contrib.auth.models.User`` model. ``User`` now contains a one-to-many relationship to ``encipher.models.EncryptionKey``. Any number of public key’s can be added to a user using the Django Admin site.

The middleware activated above will watch for incoming requests with a Paseto authorization header and will attempt to authenticate it using saved public keys.
