API key permissions for the Django REST Framework
Project description
Django REST Framework API Key
API key permissions for the Django REST Framework.
Introduction
Django REST Framework API Key is a powerful library for allowing server-side clients to safely use your API. These clients are typically third-party backends and services (i.e. machines) which do not have a user account but still need to interact with your API in a secure way.
Features
- ✌️ Simple to use: create, view and revoke API keys via the admin site, or use built-in helpers to create API keys programmatically.
- 🔒 As secure as possible: API keys are treated with the same level of care than user passwords. They are hashed using the default password hasher before being stored in the database, and only visible at creation.
- 🎨 Customizable: satisfy specific business requirements by building your own customized API key models, permission classes and admin panels.
Should I use API keys?
There are important security aspects you need to consider before switching to an API key access control scheme. We've listed some of these in Security caveats, including serving your API over HTTPS.
Besides, see Why and when to use API keys for hints on whether API keys can fit your use case.
API keys are ideal in the following situations:
- Blocking anonymous traffic.
- Implementing API key-based throttling. (Note that Django REST Framework already has may built-in utilities for this use case.)
- Identifying usage patterns by logging request information along with the API key.
They can also present enough security for authorizing internal services, such as your API server and an internal frontend application.
Please note that this package is NOT meant for authentication. You should NOT use this package to identify individual users, either directly or indirectly.
If you need server-to-server authentication, you may want to consider OAuth instead. Libraries such as django-oauth-toolkit can help.
Quickstart
Install the latest version with pip
:
pip install djangorestframework-api-key
Add the app to your INSTALLED_APPS
:
# settings.py
INSTALLED_APPS = [
# ...
"rest_framework",
"rest_framework_api_key",
]
Run the included migrations:
python manage.py migrate
To learn how to configure permissions and manage API keys, head to the Documentation.
Changelog
See CHANGELOG.md.
Contributing
See CONTRIBUTING.md.
License
MIT
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
Hashes for djangorestframework-api-key-1.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | aef275b754d466ccca901ae7f0b24593c981885b27e7d2a96f43dfee96a6a4e3 |
|
MD5 | 28870258efd7dacaf289f488d8482d99 |
|
BLAKE2b-256 | 2c13d5679706518d96da57afb7c0fb1799ec8868bb3ed6b2d46d6167fc4fef3f |
Hashes for djangorestframework_api_key-1.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0fd4a34331149891d8927b695dbdd880df145d2cd4d3105d049d5c09fe9f6a3 |
|
MD5 | 69d6bf84565ca78336d1d9cc8cbf34c9 |
|
BLAKE2b-256 | 240932f271f607d5a93010057ba47d88a1d985c6e0ebee53bd464e4c79bd2761 |