What is djangorestframework-api-key and when to use it?
masterThis library provides API key permissions for the Django REST Framework, designed for server-side clients (machines/third-party services) that do not have user accounts but need secure API access.
Use Cases
- Blocking anonymous traffic.
- Implementing API key-based throttling.
- Identifying usage patterns by logging request information alongside the API key.
- Authorizing internal services (e.g., an API server or internal frontend application).
Important Security Warnings
- NOT for User Authentication: Do NOT use this package to identify individual users. For server-to-server authentication involving users, consider OAuth (e.g.,
django-oauth-toolkit). - HTTPS Required: Ensure you are serving your API over HTTPS to protect keys.
- Key Security: API keys are hashed before storage and are only visible at the moment of creation.