Skip to main content

A library that provides a simple token authorization for Django REST framework.

Project description

DRF Simple Access Key

PyPI Test Status Codecov

A library that provides a simple token authorization for Django REST framework.

Installation

With a correctly configured pipenv toolchain:

pipenv install drf-simple-access-key

You may also use classic pip to install the package:

pip install drf-simple-access-key

Getting started

Configuration options

HTTP_AUTHORIZATION_HEADER: str

Default: 'x-authorization'

Name of the HTTP request header used for authorization.

HTTP_AUTHORIZATION_SCHEME: str

Default: 'bearer'

Name of the HTTP authorization scheme.

AUTHORIZATION_KEYS: list[str]

Default: []

List of valid authorization keys. Note that any request is allowed if this configuration option is empty!

Example configuration for Django settings

SIMPLE_ACCESS_KEY_SETTINGS = {
    'HTTP_AUTHORIZATION_HEADER': 'x-authorization',
    'HTTP_AUTHORIZATION_SCHEME': 'bearer',
    'AUTHORIZATION_KEYS': [
        'example-token-1234',
    ],
}

REST_FRAMEWORK = {
    # ...
    'DEFAULT_PERMISSION_CLASSES': [
        'drf_simple_access_key.SimpleAccessKey',
        # ...
    ],
    # ...
}

How to use

All API endpoints that use the permission class are protected by the simple access key authorization.

GET http://my.tld/api/v1/resource/
x-authorization: bearer example-token-1234

Supported versions

Django REST framework 3.10 Django REST framework 3.11 Django REST framework 3.12
Python 3.6
Python 3.7
Python 3.8
Python 3.9
Python 3.10
PyPy3

List of developers

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

drf-simple-access-key-1.0.0.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

drf_simple_access_key-1.0.0-py3-none-any.whl (4.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