Skip to main content

Authenticate Django Rest Framework Views with django-hawk

Project description

Django Hawk DRF

This package provides Django Rest Framework helper classes for use with Django Hawk.

Installation

Read the Django Hawk installation documentation.

Example usage

Read the Django Hawk example usage documentation.

Add the HawkResponseMiddleware to the MIDDLEWARE setting in your project like so:

MIDDLEWARE = [
    ...
    "django_hawk.middleware.HawkResponseMiddleware",
    "django_hawk_drf.middleware.HawkResponseMiddleware",
    ...
]

To check the you can use the django_hawk.authentication.HawkAuthentication authentication class.

from rest_framework.response import Response
from rest_framework.viewsets import ViewSet

from django_hawk_drf.authentication import HawkAuthentication


class ExampleViewSet(ViewSet):
    authentication_classes = (HawkAuthentication,)
    permission_classes = ()

    def list(self, request):
        return Response([])

Testing

Tests belong in the /django_hawk_drf/tests/ directory. You can run the tests by installing the requirements like so:

make setup

Now you can run the tests using the following command:

poetry run python manage.py test

Tox tests

We use tox to test compatibility across different Django versions.

To run these tests with tox, just run the following:

make tox

Pushing to PyPI

Running make build-package will build the package into the dist/ directory Running make push-pypi-test will push the built package to Test PyPI Running make push-pypi will push the built package to PyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_hawk_drf-1.1.2.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

django_hawk_drf-1.1.2-py3-none-any.whl (7.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page