A library that provides a simple token authorization for Django REST framework.
Project description
DRF Simple Access Key
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
- Andreas Stocker AStocker@anexia-it.com
- Harald Nezbeda HNezbeda@anexia-it.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for drf-simple-access-key-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 526ddc31135003a7ce04dac54f22f65fa1ff56fb9d978a7e1fe7389ff90aa0c6 |
|
MD5 | ae41ea91341fe016cafaf0110b070f20 |
|
BLAKE2b-256 | 218b6d0acb9088d006e6b4a1ec075541a487bc4c8526d1881903c114e7d7beb9 |
Close
Hashes for drf_simple_access_key-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 314f37b5aa2d2ef9e8655338fdefaf8781d986d366c6f8fad41d2c01dee6396f |
|
MD5 | 3a3c7f3148620afae14dcfbb15a4e6ca |
|
BLAKE2b-256 | 2fa719aef7d46865f7d6f5285f66703e6ce3189ed09b0137f5ecc10109fccb51 |