diff --git a/CHANGELOG.md b/CHANGELOG.md
index bcf01d4..88cd59a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,11 @@ Changelog
[Unreleased]
------------
+[v2.0.0] - 2024-05-23
+------------------
+
+- Rename project (#56)
+
[v1.1.1] - 2024-05-23
------------------
diff --git a/Makefile b/Makefile
index 7ce0cfc..6fc41ce 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
venv = venv
bin = ${venv}/bin/
-pysources = rest_framework_simple_api_key/ example/ tests/
+pysources = drf-apikey/ example/ tests/
build:
${bin}python -m build
diff --git a/README.md b/README.md
index e3163af..b81c193 100644
--- a/README.md
+++ b/README.md
@@ -3,15 +3,15 @@
Django REST Framework Simple API Key is a fast and secure API Key authentication plugin for REST API built with [Django Rest Framework](https://www.django-rest-framework.org/).
-For the full documentation, visit [https://drf-apikey.readthedocs.io/en/latest/](https://djangorestframework-simple-apikey.readthedocs.io/en/latest/).
+For the full documentation, visit [https://djangorestframework-simple-apikey.readthedocs.io/en/latest/](https://djangorestframework-simple-apikey.readthedocs.io/en/latest/).
## Package Renaming Notice
@@ -21,6 +21,7 @@ For the full documentation, visit [https://drf-apikey.readthedocs.io/en/latest/]
```bash
pip uninstall djangorestframework-simple-apikey
pip install drf-apikey
+For the full documentation, visit [https://djangorestframework-simple-apikey.readthedocs.io/en/latest/](https://djangorestframework-simple-apikey.readthedocs.io/en/latest/).
## Introduction
@@ -34,7 +35,7 @@ Why should you use this package for your API Key authentication?
* 🔐 **Secure**: Fernet guarantees that a message encrypted using it cannot be manipulated or read without the key, which we call `FERNET_KEY`. As long as you treat the fernet key at the same level you treat the Django `SECRET_KEY` setting, you are good to go.
-* 🔧 **Customizable**: The models, authentication backend, and permissions classes can be rewritten and fit your needs. We do our best to extend Django classes and methods, so you can easily extend our classes and methods.😉 Your Api Key authentication settings are kept in a single configuration dictionary named `SIMPLE_API_KEY` in the `settings.py` file of your Django project. It can be customized to fit your project needs.
+* 🔧 **Customizable**: The models, authentication backend, and permissions classes can be rewritten and fit your needs. We do our best to extend Django classes and methods, so you can easily extend our classes and methods.😉 Your Api Key authentication settings are kept in a single configuration dictionary named `DRF_API_KEY` in the `settings.py` file of your Django project. It can be customized to fit your project needs.
## Quickstart
@@ -42,7 +43,7 @@ Why should you use this package for your API Key authentication?
1 - Install with `pip`:
```bash
-pip install djangorestframework-simple-apikey
+pip install drf-apikey
```
2 - Register the app in the `INSTALLED_APPS` in the `settings.py` file:
@@ -53,14 +54,14 @@ pip install djangorestframework-simple-apikey
INSTALLED_APPS = [
# ...
"rest_framework",
- "rest_framework_simple_api_key",
+ "drf_apikey",
]
```
-3- Add the `FERNET_KEY` setting in your `SIMPLE_API_KEY` configuration dictionary. You can easily generate a fernet key using the `python manage.py generate_fernet_key` command. Keep in mind that the fernet key plays a huge role in the api key authentication system.
+3- Add the `FERNET_KEY` setting in your `DRF_API_KEY` configuration dictionary. You can easily generate a fernet key using the `python manage.py generate_fernet_key` command. Keep in mind that the fernet key plays a huge role in the api key authentication system.
```python
-SIMPLE_API_KEY = {
+DRF_API_KEY = {
"FERNET_SECRET": "sVjomf7FFy351xRxDeJWFJAZaE2tG3MTuUv92TLFfOA="
}
```
@@ -78,15 +79,16 @@ In your view then, you can add the authentication class and the permission class
```python
from rest_framework import viewsets
-from rest_framework_simple_api_key.backends import APIKeyAuthentication
+from drf_apikey.backends import APIKeyAuthentication
from rest_framework.response import Response
+
class FruitViewSets(viewsets.ViewSet):
- http_method_names = ["get"]
- authentication_classes = (APIKeyAuthentication, )
+ http_method_names = ["get"]
+ authentication_classes = (APIKeyAuthentication,)
- def list(self, request):
- return Response([{"detail": True}], 200 )
+ def list(self, request):
+ return Response([{"detail": True}], 200)
```
## Generate a Fernet Key
@@ -118,7 +120,7 @@ python manage.py runserver
## Changelog
-See [CHANGELOG.md](https://github.com/koladev32/djangorestframework-simple-apikey/blob/main/CHANGELOG.md).
+See [CHANGELOG.md](https://github.com/koladev32/drf-apikey/blob/main/CHANGELOG.md).
## Contributing
@@ -126,7 +128,7 @@ Thank you for your interest in contributing to the project! Here's a guide to he
- **Setup Development Environment:**
```bash
- git clone https://github.com/koladev32/djangorestframework-simple-apikey.git
+ git clone https://github.com/koladev32/drf-apikey.git
```
Use the command below to set up your environment:
```
@@ -157,4 +159,4 @@ Thank you for your interest in contributing to the project! Here's a guide to he
make test
```
-See [CONTRIBUTING.md](https://github.com/koladev32/djangorestframework-simple-apikey/blob/main/CONTRIBUTING.md).
\ No newline at end of file
+See [CONTRIBUTING.md](https://github.com/koladev32/drf-apikey/blob/main/CONTRIBUTING.md).
\ No newline at end of file
diff --git a/docs/analytics.rst b/docs/analytics.rst
index 09539a7..ea7542e 100644
--- a/docs/analytics.rst
+++ b/docs/analytics.rst
@@ -2,7 +2,7 @@
API Key Analytics Middleware
======================
-The API Key Analytics Middleware is a component of the `rest_framework_simple_api_key` package that provides
+The API Key Analytics Middleware is a component of the `drf-apikey` package that provides
real-time analytics on API key usage. It records each API request, tracking which endpoints are accessed and how frequently.
API Key Analytics Middleware Usage cases
@@ -31,7 +31,7 @@ Setup
To use the `ApiKeyAnalyticsMiddleware`, follow these setup instructions:
-1. Ensure the middleware app `rest_framework_simple_api_key.analytics` is included in the ``INSTALLED_APPS`` setting
+1. Ensure the middleware app `drf-apikey.analytics` is included in the ``INSTALLED_APPS`` setting
of your Django project.
.. code-block:: python
@@ -39,8 +39,8 @@ To use the `ApiKeyAnalyticsMiddleware`, follow these setup instructions:
INSTALLED_APPS = (
...
"rest_framework",
- "rest_framework_simple_api_key",
- "rest_framework_simple_api_key.analytics", # Ensure this app is added
+ "drf-apikey",
+ "drf-apikey.analytics", # Ensure this app is added
)
2. Add the `ApiKeyAnalyticsMiddleware` to the `MIDDLEWARE` settings in your Django configuration.
@@ -50,7 +50,7 @@ To use the `ApiKeyAnalyticsMiddleware`, follow these setup instructions:
MIDDLEWARE = [
...
'django.middleware.security.SecurityMiddleware',
- 'rest_framework_simple_api_key.analytics.middleware.ApiKeyAnalyticsMiddleware', # Add the middleware here
+ 'drf-apikey.analytics.middleware.ApiKeyAnalyticsMiddleware', # Add the middleware here
...
]
@@ -58,7 +58,7 @@ To use the `ApiKeyAnalyticsMiddleware`, follow these setup instructions:
.. code-block:: shell
- python manage.py migrate rest_framework_simple_api_key_analytics
+ python manage.py migrate drf-apikey_analytics
Activation
----------
diff --git a/docs/authentication.rst b/docs/authentication.rst
index bd30098..afb7355 100644
--- a/docs/authentication.rst
+++ b/docs/authentication.rst
@@ -13,7 +13,7 @@ Key at ``request.user`` too.
solutions to have something such as ``request.entity`` without having
to disrupt the Django REST Framework authentication and authorization
flow. If you have some ideas, feel free to open an issue
- https://github.com/koladev32/djangorestframework-simple-apikey/issues.
+ https://github.com/koladev32/drf-apikey/issues.
Use the ``APIKeyAuthentication`` backend
----------------------------------------
@@ -36,10 +36,10 @@ you can modify in the ``settings.py`` file of your Django project.
.. code:: python
- SIMPLE_API_KEY = {
+ DRF_API_KEY = {
...
"AUTHENTICATION_KEYWORD_HEADER": "YOUR_CUSTOM_VALUE",
}
Feel free to read the code of the authentication class at
-https://github.com/koladev32/djangorestframework-simple-apikey/blob/main/rest_framework_simple_api_key/backends.py.
+https://github.com/koladev32/drf-apikey/blob/main/drf-apikey/backends.py.
diff --git a/docs/customizing_api_key_model.rst b/docs/customizing_api_key_model.rst
index 876102b..5fc1436 100644
--- a/docs/customizing_api_key_model.rst
+++ b/docs/customizing_api_key_model.rst
@@ -9,7 +9,7 @@ example using a custom class called ``Organization``.
# organizations/models.py
from django.db import models
- from rest_framework_simple_api_key.models import AbstractAPIKey
+ from drf-apikey.models import AbstractAPIKey
class Organization(models.Model):
name = models.CharField(max_length=255)
diff --git a/docs/getting_started.rst b/docs/getting_started.rst
index 628835c..c3315e9 100644
--- a/docs/getting_started.rst
+++ b/docs/getting_started.rst
@@ -35,7 +35,7 @@ Why should you use this package for your API Key authentication?
permissions classes can be rewritten and fit your needs. We do our
best to extend Django classes and methods, so you can easily extend
our classes and methods.😉 Your Api Key authentication settings are
- kept in a single configuration dictionary named ``SIMPLE_API_KEY`` in
+ kept in a single configuration dictionary named ``DRF_API_KEY`` in
the ``settings.py`` file of your Django project. It can be customized
to fit your project needs.
@@ -46,7 +46,7 @@ Quickstart
.. code:: bash
- pip install djangorestframework-simple-apikey
+ pip install drf-apikey
2 - Register the app in the ``INSTALLED_APPS`` in the ``settings.py``
file:
@@ -58,17 +58,17 @@ file:
INSTALLED_APPS = [
# ...
"rest_framework",
- "rest_framework_simple_api_key",
+ "drf-apikey",
]
-3- Add the ``FERNET_KEY`` setting in your ``SIMPLE_API_KEY``
+3- Add the ``FERNET_KEY`` setting in your ``DRF_API_KEY``
configuration dictionary. You can easily generate a fernet key using the
``python manage.py generate_fernet_key`` command. Keep in mind that the
fernet key plays a huge role in the api key authentication system.
.. code:: python
- SIMPLE_API_KEY = {
+ DRF_API_KEY = {
"FERNET_SECRET": "sVjomf7FFy351xRxDeJWFJAZaE2tG3MTuUv92TLFfOA="
}
@@ -88,7 +88,7 @@ permission class.
from rest_framework import viewsets
- from rest_framework_simple_api_key.backends import APIKeyAuthentication
+ from drf-apikey.backends import APIKeyAuthentication
from rest_framework.response import Response
class FruitViewSets(viewsets.ViewSet):
@@ -119,10 +119,10 @@ Changelog
---------
See
-`CHANGELOG.md `__.
+`CHANGELOG.md `__.
Contributing
------------
See
-`CONTRIBUTING.md `__.
\ No newline at end of file
+`CONTRIBUTING.md `__.
\ No newline at end of file
diff --git a/docs/index.rst b/docs/index.rst
index d57ca71..441190c 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,13 +1,13 @@
Django REST Simple Api Key
==========
-.. image:: https://badge.fury.io/py/djangorestframework-simple-apikey.svg/
- :target: https://github.com/koladev32/djangorestframework-simple-apikey/
+.. image:: https://badge.fury.io/py/drf-apikey.svg/
+ :target: https://github.com/koladev32/drf-apikey/
-.. image:: https://github.com/koladev32/djangorestframework-simple-apikey/actions/workflows/ci-cd.yml/badge.svg/
- :target: https://github.com/koladev32/djangorestframework-simple-apikey/actions/workflows/ci-cd.yml/
+.. image:: https://github.com/koladev32/drf-apikey/actions/workflows/ci-cd.yml/badge.svg/
+ :target: https://github.com/koladev32/drf-apikey/actions/workflows/ci-cd.yml/
-.. image:: https://readthedocs.org/projects/djangorestframework-simple-apikey/badge/?version=latest
+.. image:: https://readthedocs.org/projects/drf-apikey/badge/?version=latest
:target: https://djangorestframework-simple-apikey.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
diff --git a/docs/permissions.rst b/docs/permissions.rst
index 863f4ae..001fdb2 100644
--- a/docs/permissions.rst
+++ b/docs/permissions.rst
@@ -31,7 +31,7 @@ You can then call use this class in your view 👇
.. code:: python
- from rest_framework_simple_api_key.permissions import IsActiveEntity
+ from drf-apikey.permissions import IsActiveEntity
class YourViewSet(viewsets.ViewSet):
...
@@ -39,4 +39,4 @@ You can then call use this class in your view 👇
permission_classes = (IsActiveEntity, )
Feel free to read the code of the permission class at
-`https://github.com/koladev32/djangorestframework-simple-apikey/blob/main/rest_framework_simple_api_key/permissions.py `__.
\ No newline at end of file
+`https://github.com/koladev32/drf-apikey/blob/main/drf-apikey/permissions.py `__.
\ No newline at end of file
diff --git a/docs/rotation.rst b/docs/rotation.rst
index 2f31963..362152f 100644
--- a/docs/rotation.rst
+++ b/docs/rotation.rst
@@ -13,7 +13,7 @@ project using the package, detailing the inner workings of the rotation process.
Key Rotation Overview
---------------------
-API Key Rotation in the `rest_framework_simple_api_key` package involves periodically
+API Key Rotation in the `drf-apikey` package involves periodically
changing the encryption keys used to secure API keys. During rotation, a new key is introduced,
and both the old and new keys are used for a transition period. This ensures that existing API
keys remain valid while new keys are encrypted with the fresh key.
@@ -23,22 +23,22 @@ Activation
Before activating a rotation, ensure to set the rotating Fernet key ``ROTATION_FERNET_SECRET`` in the settings of the package.
-You will need to add the rotation app ``rest_framework_simple_api_key.rotation`` in the ``INSTALLED_APPS`` Django setting of your project.
+You will need to add the rotation app ``drf-apikey.rotation`` in the ``INSTALLED_APPS`` Django setting of your project.
.. code-block:: python
INSTALLED_APPS=(
...
"rest_framework",
- "rest_framework_simple_api_key",
- "rest_framework_simple_api_key.rotation", # added app
+ "drf-apikey",
+ "drf-apikey.rotation", # added app
)
And you will need to run the migrate command:
.. code-block:: shell
- python manage.py migrate rest_framework_simple_api_key_rotation
+ python manage.py migrate drf-apikey_rotation
To activate API Key Rotation, you can choose one of the following methods:
diff --git a/docs/settings.rst b/docs/settings.rst
index 9b521aa..3e175f2 100644
--- a/docs/settings.rst
+++ b/docs/settings.rst
@@ -2,14 +2,14 @@ Settings
===========
Some of Django REST Framework Simple API Key's behavior can be customized through settings variables in
-``settings.py``. You can find below the default `SIMPLE_API_KEY` setting.
+``settings.py``. You can find below the default `DRF_API_KEY` setting.
.. code-block:: python
# Django project settings.py
...
- SIMPLE_API_KEY = {
+ DRF_API_KEY = {
"FERNET_SECRET": "",
"API_KEY_LIFETIME": 365,
"AUTHENTICATION_KEYWORD_HEADER": "Api-Key",
diff --git a/rest_framework_simple_api_key/__init__.py b/drf_apikey/__init__.py
similarity index 87%
rename from rest_framework_simple_api_key/__init__.py
rename to drf_apikey/__init__.py
index d8a7593..1ed2a96 100644
--- a/rest_framework_simple_api_key/__init__.py
+++ b/drf_apikey/__init__.py
@@ -9,7 +9,7 @@
warnings.warn(
"This package, 'djangorestframework-simple-apikey', has been renamed to 'drf-apikey' and will no longer be updated."
"Please switch to the new package to continue receiving updates and support. "
- "For more information and migration instructions, please visit: https://drf-apikey.readthedocs.io/en/latest/migrating.html",
+ "For more information and migration instructions, please visit: https://djangorestframework-simple-apikey.readthedocs.io/en/latest/migrating.html",
DeprecationWarning,
stacklevel=2,
)
diff --git a/rest_framework_simple_api_key/admin.py b/drf_apikey/admin.py
similarity index 100%
rename from rest_framework_simple_api_key/admin.py
rename to drf_apikey/admin.py
diff --git a/rest_framework_simple_api_key/analytics/__init__.py b/drf_apikey/analytics/__init__.py
similarity index 100%
rename from rest_framework_simple_api_key/analytics/__init__.py
rename to drf_apikey/analytics/__init__.py
diff --git a/rest_framework_simple_api_key/analytics/admin.py b/drf_apikey/analytics/admin.py
similarity index 100%
rename from rest_framework_simple_api_key/analytics/admin.py
rename to drf_apikey/analytics/admin.py
diff --git a/rest_framework_simple_api_key/analytics/apps.py b/drf_apikey/analytics/apps.py
similarity index 54%
rename from rest_framework_simple_api_key/analytics/apps.py
rename to drf_apikey/analytics/apps.py
index 964e302..521839a 100644
--- a/rest_framework_simple_api_key/analytics/apps.py
+++ b/drf_apikey/analytics/apps.py
@@ -3,5 +3,5 @@
class AnalyticsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
- name = "rest_framework_simple_api_key.analytics"
- label = "rest_framework_simple_api_key_analytics"
+ name = "drf_apikey.analytics"
+ label = "drf_apikey_analytics"
diff --git a/rest_framework_simple_api_key/analytics/middleware.py b/drf_apikey/analytics/middleware.py
similarity index 70%
rename from rest_framework_simple_api_key/analytics/middleware.py
rename to drf_apikey/analytics/middleware.py
index cba06eb..4e397bc 100644
--- a/rest_framework_simple_api_key/analytics/middleware.py
+++ b/drf_apikey/analytics/middleware.py
@@ -1,7 +1,7 @@
-from rest_framework_simple_api_key.analytics.models import ApiKeyAnalytics
-from rest_framework_simple_api_key.crypto import get_crypto
-from rest_framework_simple_api_key.parser import APIKeyParser
-from rest_framework_simple_api_key.utils import get_key
+from drf_apikey.analytics.models import ApiKeyAnalytics
+from drf_apikey.crypto import get_crypto
+from drf_apikey.parser import APIKeyParser
+from drf_apikey.utils import get_key
class ApiKeyAnalyticsMiddleware:
diff --git a/rest_framework_simple_api_key/analytics/migrations/0001_initial.py b/drf_apikey/analytics/migrations/0001_initial.py
similarity index 88%
rename from rest_framework_simple_api_key/analytics/migrations/0001_initial.py
rename to drf_apikey/analytics/migrations/0001_initial.py
index 7680c9f..48687d2 100644
--- a/rest_framework_simple_api_key/analytics/migrations/0001_initial.py
+++ b/drf_apikey/analytics/migrations/0001_initial.py
@@ -9,7 +9,7 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
- ("rest_framework_simple_api_key", "0002_alter_apikey_options"),
+ ("drf_apikey", "0002_alter_apikey_options"),
]
operations = [
@@ -32,7 +32,7 @@ class Migration(migrations.Migration):
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="analytics",
- to="rest_framework_simple_api_key.apikey",
+ to="drf_apikey.apikey",
),
),
],
diff --git a/rest_framework_simple_api_key/analytics/migrations/__init__.py b/drf_apikey/analytics/migrations/__init__.py
similarity index 100%
rename from rest_framework_simple_api_key/analytics/migrations/__init__.py
rename to drf_apikey/analytics/migrations/__init__.py
diff --git a/rest_framework_simple_api_key/analytics/models.py b/drf_apikey/analytics/models.py
similarity index 96%
rename from rest_framework_simple_api_key/analytics/models.py
rename to drf_apikey/analytics/models.py
index 2fabdd3..af62ae3 100644
--- a/rest_framework_simple_api_key/analytics/models.py
+++ b/drf_apikey/analytics/models.py
@@ -1,5 +1,5 @@
from django.db import models
-from rest_framework_simple_api_key.settings import package_settings
+from drf_apikey.settings import package_settings
class ApiKeyAnalyticsManager(models.Manager):
diff --git a/rest_framework_simple_api_key/apps.py b/drf_apikey/apps.py
similarity index 74%
rename from rest_framework_simple_api_key/apps.py
rename to drf_apikey/apps.py
index ec4045a..d292ab8 100644
--- a/rest_framework_simple_api_key/apps.py
+++ b/drf_apikey/apps.py
@@ -2,5 +2,5 @@
class RestSimpleAPIKeyConfig(AppConfig):
- name = "rest_framework_simple_api_key"
+ name = "drf_apikey"
verbose_name = "Django REST simple API Key"
diff --git a/rest_framework_simple_api_key/backends.py b/drf_apikey/backends.py
similarity index 93%
rename from rest_framework_simple_api_key/backends.py
rename to drf_apikey/backends.py
index 797ef6e..1a226a3 100644
--- a/rest_framework_simple_api_key/backends.py
+++ b/drf_apikey/backends.py
@@ -8,9 +8,9 @@
from rest_framework import exceptions
-from rest_framework_simple_api_key.crypto import get_crypto
-from rest_framework_simple_api_key.models import APIKey
-from rest_framework_simple_api_key.parser import APIKeyParser
+from drf_apikey.crypto import get_crypto
+from drf_apikey.models import APIKey
+from drf_apikey.parser import APIKeyParser
class APIKeyAuthentication(BaseBackend):
diff --git a/rest_framework_simple_api_key/crypto.py b/drf_apikey/crypto.py
similarity index 90%
rename from rest_framework_simple_api_key/crypto.py
rename to drf_apikey/crypto.py
index 63010be..89c04fe 100644
--- a/rest_framework_simple_api_key/crypto.py
+++ b/drf_apikey/crypto.py
@@ -11,7 +11,7 @@
from django.utils.timezone import now
-from rest_framework_simple_api_key.settings import package_settings
+from drf_apikey.settings import package_settings
class BaseApiCrypto:
@@ -60,11 +60,11 @@ def __init__(self):
def get_crypto():
- if "rest_framework_simple_api_key.rotation" in settings.INSTALLED_APPS:
+ if "drf_apikey.rotation" in settings.INSTALLED_APPS:
try:
# Try to import necessary components and initialize the MultiApiCrypto.
# This might fail if certain conditions aren't met, like missing migrations.
- from rest_framework_simple_api_key.rotation.utils import get_rotation_status
+ from drf_apikey.rotation.utils import get_rotation_status
from .mutli_api_crypto import MultiApiCrypto
if get_rotation_status():
diff --git a/rest_framework_simple_api_key/management/__init__.py b/drf_apikey/management/__init__.py
similarity index 100%
rename from rest_framework_simple_api_key/management/__init__.py
rename to drf_apikey/management/__init__.py
diff --git a/rest_framework_simple_api_key/management/commands/__init__.py b/drf_apikey/management/commands/__init__.py
similarity index 100%
rename from rest_framework_simple_api_key/management/commands/__init__.py
rename to drf_apikey/management/commands/__init__.py
diff --git a/rest_framework_simple_api_key/management/commands/generate_fernet_key.py b/drf_apikey/management/commands/generate_fernet_key.py
similarity index 100%
rename from rest_framework_simple_api_key/management/commands/generate_fernet_key.py
rename to drf_apikey/management/commands/generate_fernet_key.py
diff --git a/rest_framework_simple_api_key/management/commands/rotation.py b/drf_apikey/management/commands/rotation.py
similarity index 91%
rename from rest_framework_simple_api_key/management/commands/rotation.py
rename to drf_apikey/management/commands/rotation.py
index 40fdb17..9845b30 100644
--- a/rest_framework_simple_api_key/management/commands/rotation.py
+++ b/drf_apikey/management/commands/rotation.py
@@ -3,8 +3,8 @@
from django.core.management.base import BaseCommand, CommandError
from django.utils import timezone
-from rest_framework_simple_api_key.rotation.models import Rotation
-from rest_framework_simple_api_key.settings import package_settings
+from drf_apikey.rotation.models import Rotation
+from drf_apikey.settings import package_settings
class Command(BaseCommand):
diff --git a/rest_framework_simple_api_key/migrations/0001_initial.py b/drf_apikey/migrations/0001_initial.py
similarity index 93%
rename from rest_framework_simple_api_key/migrations/0001_initial.py
rename to drf_apikey/migrations/0001_initial.py
index 68ac96d..d8fe8c9 100644
--- a/rest_framework_simple_api_key/migrations/0001_initial.py
+++ b/drf_apikey/migrations/0001_initial.py
@@ -3,7 +3,7 @@
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
-import rest_framework_simple_api_key.models
+import drf_apikey.models
class Migration(migrations.Migration):
@@ -30,7 +30,7 @@ class Migration(migrations.Migration):
(
"expiry_date",
models.DateTimeField(
- default=rest_framework_simple_api_key.models._expiry_date,
+ default=drf_apikey.models._expiry_date,
help_text="Once API key expires, entities cannot use it anymore.",
verbose_name="Expires",
),
diff --git a/rest_framework_simple_api_key/migrations/0002_alter_apikey_options.py b/drf_apikey/migrations/0002_alter_apikey_options.py
similarity index 85%
rename from rest_framework_simple_api_key/migrations/0002_alter_apikey_options.py
rename to drf_apikey/migrations/0002_alter_apikey_options.py
index a925fc9..599e8a5 100644
--- a/rest_framework_simple_api_key/migrations/0002_alter_apikey_options.py
+++ b/drf_apikey/migrations/0002_alter_apikey_options.py
@@ -5,7 +5,7 @@
class Migration(migrations.Migration):
dependencies = [
- ("rest_framework_simple_api_key", "0001_initial"),
+ ("drf_apikey", "0001_initial"),
]
operations = [
diff --git a/rest_framework_simple_api_key/migrations/__init__.py b/drf_apikey/migrations/__init__.py
similarity index 100%
rename from rest_framework_simple_api_key/migrations/__init__.py
rename to drf_apikey/migrations/__init__.py
diff --git a/rest_framework_simple_api_key/models.py b/drf_apikey/models.py
similarity index 94%
rename from rest_framework_simple_api_key/models.py
rename to drf_apikey/models.py
index d09db13..0ef11ce 100644
--- a/rest_framework_simple_api_key/models.py
+++ b/drf_apikey/models.py
@@ -4,8 +4,8 @@
from django.conf import settings
from django.db import models
-from rest_framework_simple_api_key.crypto import get_crypto
-from rest_framework_simple_api_key.settings import package_settings
+from drf_apikey.crypto import get_crypto
+from drf_apikey.settings import package_settings
def _expiry_date():
diff --git a/rest_framework_simple_api_key/mutli_api_crypto.py b/drf_apikey/mutli_api_crypto.py
similarity index 85%
rename from rest_framework_simple_api_key/mutli_api_crypto.py
rename to drf_apikey/mutli_api_crypto.py
index 9fb1927..e58c1ce 100644
--- a/rest_framework_simple_api_key/mutli_api_crypto.py
+++ b/drf_apikey/mutli_api_crypto.py
@@ -1,7 +1,7 @@
from cryptography.fernet import MultiFernet, Fernet
-from rest_framework_simple_api_key.crypto import BaseApiCrypto
-from rest_framework_simple_api_key.settings import package_settings
+from drf_apikey.crypto import BaseApiCrypto
+from drf_apikey.settings import package_settings
class MultiApiCrypto(BaseApiCrypto):
diff --git a/rest_framework_simple_api_key/parser.py b/drf_apikey/parser.py
similarity index 94%
rename from rest_framework_simple_api_key/parser.py
rename to drf_apikey/parser.py
index 8123e41..a18ac37 100644
--- a/rest_framework_simple_api_key/parser.py
+++ b/drf_apikey/parser.py
@@ -3,7 +3,7 @@
from django.http import HttpRequest
from rest_framework.exceptions import NotAuthenticated, AuthenticationFailed
-from rest_framework_simple_api_key.settings import package_settings
+from drf_apikey.settings import package_settings
class APIKeyParser:
diff --git a/rest_framework_simple_api_key/permissions.py b/drf_apikey/permissions.py
similarity index 100%
rename from rest_framework_simple_api_key/permissions.py
rename to drf_apikey/permissions.py
diff --git a/rest_framework_simple_api_key/rotation/__init__.py b/drf_apikey/rotation/__init__.py
similarity index 100%
rename from rest_framework_simple_api_key/rotation/__init__.py
rename to drf_apikey/rotation/__init__.py
diff --git a/rest_framework_simple_api_key/rotation/admin.py b/drf_apikey/rotation/admin.py
similarity index 100%
rename from rest_framework_simple_api_key/rotation/admin.py
rename to drf_apikey/rotation/admin.py
diff --git a/rest_framework_simple_api_key/rotation/apps.py b/drf_apikey/rotation/apps.py
similarity index 54%
rename from rest_framework_simple_api_key/rotation/apps.py
rename to drf_apikey/rotation/apps.py
index 90d5c75..68caab9 100644
--- a/rest_framework_simple_api_key/rotation/apps.py
+++ b/drf_apikey/rotation/apps.py
@@ -3,5 +3,5 @@
class RotationConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
- name = "rest_framework_simple_api_key.rotation"
- label = "rest_framework_simple_api_key_rotation"
+ name = "drf_apikey.rotation"
+ label = "drf_apikey_rotation"
diff --git a/rest_framework_simple_api_key/rotation/migrations/0001_initial.py b/drf_apikey/rotation/migrations/0001_initial.py
similarity index 100%
rename from rest_framework_simple_api_key/rotation/migrations/0001_initial.py
rename to drf_apikey/rotation/migrations/0001_initial.py
diff --git a/rest_framework_simple_api_key/rotation/migrations/__init__.py b/drf_apikey/rotation/migrations/__init__.py
similarity index 100%
rename from rest_framework_simple_api_key/rotation/migrations/__init__.py
rename to drf_apikey/rotation/migrations/__init__.py
diff --git a/rest_framework_simple_api_key/rotation/models.py b/drf_apikey/rotation/models.py
similarity index 100%
rename from rest_framework_simple_api_key/rotation/models.py
rename to drf_apikey/rotation/models.py
diff --git a/rest_framework_simple_api_key/rotation/utils.py b/drf_apikey/rotation/utils.py
similarity index 88%
rename from rest_framework_simple_api_key/rotation/utils.py
rename to drf_apikey/rotation/utils.py
index 5e8b8ce..03a7277 100644
--- a/rest_framework_simple_api_key/rotation/utils.py
+++ b/drf_apikey/rotation/utils.py
@@ -2,7 +2,7 @@
from django.apps import apps
from django.utils import timezone
-from rest_framework_simple_api_key.settings import package_settings
+from drf_apikey.settings import package_settings
def get_rotation_status():
@@ -12,7 +12,7 @@ def get_rotation_status():
rotation_status is None
): # We should check for 'None' specifically because the cached value could be False
# Lazy load the Rotation model
- Rotation = apps.get_model("rest_framework_simple_api_key_rotation", "Rotation")
+ Rotation = apps.get_model("drf_apikey_rotation", "Rotation")
# Filter the latest rotation that is enabled
config = (
diff --git a/rest_framework_simple_api_key/settings.py b/drf_apikey/settings.py
similarity index 81%
rename from rest_framework_simple_api_key/settings.py
rename to drf_apikey/settings.py
index 19c9e77..23cfaee 100644
--- a/rest_framework_simple_api_key/settings.py
+++ b/drf_apikey/settings.py
@@ -6,7 +6,7 @@
from django.utils.translation import gettext_lazy as _
from rest_framework.settings import APISettings as _APISettings
-USER_SETTINGS = getattr(settings, "SIMPLE_API_KEY", None)
+USER_SETTINGS = getattr(settings, "DRF_API_KEY", None)
DEFAULTS = {
"FERNET_SECRET": "",
@@ -14,7 +14,7 @@
"API_KEY_LIFETIME": 365,
"AUTHENTICATION_KEYWORD_HEADER": "Api-Key",
"ROTATION_PERIOD": timedelta(days=7),
- "API_KEY_CLASS": "rest_framework_simple_api_key.Apikey",
+ "API_KEY_CLASS": "drf_apikey.Apikey",
}
REMOVED_SETTINGS = ()
@@ -24,11 +24,11 @@ class PackageSettings(_APISettings):
@property
def user_settings(self):
if not hasattr(self, "_user_settings"):
- self._user_settings = getattr(settings, "SIMPLE_API_KEY", {})
+ self._user_settings = getattr(settings, "DRF_API_KEY", {})
return self._user_settings
def __check_user_settings(self, user_settings):
- SETTINGS_DOC = "https://django-rest-framework-simple-apikey.readthedocs.io/en/latest/settings.html"
+ SETTINGS_DOC = "https://djangorestframework-simple-apikey.readthedocs.io/en/latest/settings.html"
for setting in REMOVED_SETTINGS:
if setting in user_settings:
@@ -53,7 +53,7 @@ def reload_api_settings(*args, **kwargs):
setting, value = kwargs["setting"], kwargs["value"]
- if setting == "SIMPLE_API_KEY":
+ if setting == "DRF_API_KEY":
package_settings = PackageSettings(value, DEFAULTS)
diff --git a/rest_framework_simple_api_key/utils.py b/drf_apikey/utils.py
similarity index 100%
rename from rest_framework_simple_api_key/utils.py
rename to drf_apikey/utils.py
diff --git a/drf_apikey/version.py b/drf_apikey/version.py
new file mode 100644
index 0000000..2101409
--- /dev/null
+++ b/drf_apikey/version.py
@@ -0,0 +1 @@
+VERSION = "2.0.0"
diff --git a/example/ApiKey/settings.py b/example/ApiKey/settings.py
index fd9de28..05c3d05 100644
--- a/example/ApiKey/settings.py
+++ b/example/ApiKey/settings.py
@@ -38,7 +38,7 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"rest_framework",
- "rest_framework_simple_api_key",
+ "drf_apikey",
"fruits",
]
@@ -126,4 +126,4 @@
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
-SIMPLE_API_KEY = {"FERNET_SECRET": "foo"}
+DRF_API_KEY = {"FERNET_SECRET": "foo"}
diff --git a/example/fruits/viewsets.py b/example/fruits/viewsets.py
index 61a9316..28f3414 100644
--- a/example/fruits/viewsets.py
+++ b/example/fruits/viewsets.py
@@ -2,8 +2,8 @@
from rest_framework import viewsets
-from rest_framework_simple_api_key.backends import APIKeyAuthentication
-from rest_framework_simple_api_key.permissions import IsActiveEntity
+from drf_apikey.backends import APIKeyAuthentication
+from drf_apikey.permissions import IsActiveEntity
from rest_framework.response import Response
diff --git a/example/requirements.txt b/example/requirements.txt
index 83cbe3d..2084405 100644
--- a/example/requirements.txt
+++ b/example/requirements.txt
@@ -1,3 +1,3 @@
Django==4.1.6
djangorestframework==3.14.0
-djangorestframework-simple-apikey==0.1.2
+drf-apikey==0.1.2
diff --git a/pyproject.toml b/pyproject.toml
index 09859ad..7077c8e 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -5,6 +5,6 @@ requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
-name = "djangorestframework-simple-apikey"
-version = "1.1.1"
+name = "drf-apikey"
+version = "2.0.0"
dynamic = ["description", "readme", "optional-dependencies", "dependencies", "classifiers", "authors", "license"]
\ No newline at end of file
diff --git a/rest_framework_simple_api_key/version.py b/rest_framework_simple_api_key/version.py
deleted file mode 100644
index ca638cf..0000000
--- a/rest_framework_simple_api_key/version.py
+++ /dev/null
@@ -1 +0,0 @@
-VERSION = "1.1.1"
diff --git a/scripts/makemigrations.py b/scripts/makemigrations.py
index 6ff023e..34197f0 100644
--- a/scripts/makemigrations.py
+++ b/scripts/makemigrations.py
@@ -21,9 +21,9 @@
"django.contrib.sites",
"django.contrib.staticfiles",
"rest_framework",
- "rest_framework_simple_api_key",
- "rest_framework_simple_api_key.rotation",
- "rest_framework_simple_api_key.analytics",
+ "drf_apikey",
+ "drf_apikey.rotation",
+ "drf_apikey.analytics",
"tests",
),
DATABASES={
@@ -32,7 +32,7 @@
"NAME": ":memory:",
}
},
- SIMPLE_API_KEY={
+ DRF_API_KEY={
"FERNET_SECRET": "sVjomf7FFy351xRxDeJWFJAZaE2tG3MTuUv92TLFfOA=",
},
)
diff --git a/setup.cfg b/setup.cfg
index 4932fb0..d6c884d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 1.1.1
+current_version = 2.0.0
commit = True
tag = True
@@ -7,7 +7,7 @@ tag = True
search = version = "{current_version}"
replace = version = "{new_version}"
-[bumpversion:file:rest_framework_simple_api_key/version.py]
+[bumpversion:file:drf_apikey/version.py]
search = VERSION = "{current_version}"
replace = VERSION = "{new_version}"
@@ -26,9 +26,9 @@ replace =
universal = 1
[metadata]
-name = djangorestframework-simple-apikey
+name = drf-apikey
version = "{current_version}"
-url = https://github.com/koladev32/djangorestframework-simple-apikey
+url = https://github.com/koladev32/drf-apikey
license = MIT
author = Kolawole Mangabo
author_email = onaelmangabo@gmail.com
diff --git a/tests/conftest.py b/tests/conftest.py
index aee85b6..eb88f88 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -11,7 +11,7 @@ def pytest_configure():
"django.contrib.sessions.middleware.SessionMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
- "rest_framework_simple_api_key.analytics.middleware.ApiKeyAnalyticsMiddleware",
+ "drf_apikey.analytics.middleware.ApiKeyAnalyticsMiddleware",
)
apps = [
@@ -22,13 +22,13 @@ def pytest_configure():
"django.contrib.sites",
"django.contrib.staticfiles",
"rest_framework",
- "rest_framework_simple_api_key",
- "rest_framework_simple_api_key.analytics",
+ "drf_apikey",
+ "drf_apikey.analytics",
"tests",
]
if os.environ.get("TEST_WITH_ROTATION"):
- apps.append("rest_framework_simple_api_key.rotation")
+ apps.append("drf_apikey.rotation")
settings.configure(
DEBUG_PROPAGATE_EXCEPTIONS=True,
@@ -50,7 +50,7 @@ def pytest_configure():
MIDDLEWARE_CLASSES=MIDDLEWARE,
INSTALLED_APPS=apps,
PASSWORD_HASHERS=("django.contrib.auth.hashers.MD5PasswordHasher",),
- SIMPLE_API_KEY={
+ DRF_API_KEY={
"FERNET_SECRET": "sVjomf7FFy351xRxDeJWFJAZaE2tG3MTuUv92TLFfOA=",
"ROTATION_FERNET_SECRET": "EqkeOOgvV8bt70vUJiVXloNycn5bt_z1VqyoAi9K6f4=",
},
@@ -69,7 +69,7 @@ def setup_rotation_config(db):
from django.conf import settings
"""Ensure a RotationConfig object exists for tests."""
- if "rest_framework_simple_api_key.rotation" in settings.INSTALLED_APPS:
- from rest_framework_simple_api_key.rotation.models import Rotation
+ if "drf_apikey.rotation" in settings.INSTALLED_APPS:
+ from drf_apikey.rotation.models import Rotation
Rotation.objects.create(is_rotation_enabled=True)
diff --git a/tests/fixtures/api_key.py b/tests/fixtures/api_key.py
index 1d74d09..9e3e0cc 100644
--- a/tests/fixtures/api_key.py
+++ b/tests/fixtures/api_key.py
@@ -1,7 +1,7 @@
import pytest
from django.utils.timezone import now
-from rest_framework_simple_api_key.models import APIKey
+from drf_apikey.models import APIKey
from .user import user, inactive_user
diff --git a/tests/test_admin.py b/tests/test_admin.py
index cf2b5a6..07634c6 100644
--- a/tests/test_admin.py
+++ b/tests/test_admin.py
@@ -7,8 +7,8 @@
from django.http.response import HttpResponse
from django.test import RequestFactory
-from rest_framework_simple_api_key.admin import ApiKeyAdmin
-from rest_framework_simple_api_key.models import APIKey
+from drf_apikey.admin import ApiKeyAdmin
+from drf_apikey.models import APIKey
from .fixtures.user import user
diff --git a/tests/test_analytics.py b/tests/test_analytics.py
index 7f08731..111130d 100644
--- a/tests/test_analytics.py
+++ b/tests/test_analytics.py
@@ -1,5 +1,5 @@
import pytest
-from rest_framework_simple_api_key.analytics.models import ApiKeyAnalytics
+from drf_apikey.analytics.models import ApiKeyAnalytics
from .fixtures.api_key import active_only_api_key
from .fixtures.user import user
diff --git a/tests/test_analytics_middleware.py b/tests/test_analytics_middleware.py
index 75fd5a6..5c0f49a 100644
--- a/tests/test_analytics_middleware.py
+++ b/tests/test_analytics_middleware.py
@@ -3,8 +3,8 @@
import pytest
from django.http import HttpResponse
from django.test import RequestFactory
-from rest_framework_simple_api_key.analytics.middleware import ApiKeyAnalyticsMiddleware
-from rest_framework_simple_api_key.analytics.models import ApiKeyAnalytics
+from drf_apikey.analytics.middleware import ApiKeyAnalyticsMiddleware
+from drf_apikey.analytics.models import ApiKeyAnalytics
from .fixtures.api_key import active_api_key
from .fixtures.user import user
@@ -36,9 +36,9 @@ def test_api_key_analytics_middleware(
# Assume get_key and get_crypto are properly mocked to return expected values
with mock.patch(
- "rest_framework_simple_api_key.parser.APIKeyParser.get", return_value=key
+ "drf_apikey.parser.APIKeyParser.get", return_value=key
), mock.patch(
- "rest_framework_simple_api_key.crypto.ApiCrypto.decrypt",
+ "drf_apikey.crypto.ApiCrypto.decrypt",
return_value={"_pk": apikey.pk},
):
# Call middleware
diff --git a/tests/test_api_authentication.py b/tests/test_api_authentication.py
index 56779c8..ec9308a 100644
--- a/tests/test_api_authentication.py
+++ b/tests/test_api_authentication.py
@@ -5,7 +5,7 @@
from rest_framework.test import APIRequestFactory
-from rest_framework_simple_api_key.settings import package_settings
+from drf_apikey.settings import package_settings
from .fixtures.user import user
from .fixtures.api_key import expired_api_key, active_api_key, revoked_api_key
@@ -54,7 +54,7 @@ def valid_request(user, active_api_key):
def api_key_authentication():
- from rest_framework_simple_api_key.backends import APIKeyAuthentication
+ from drf_apikey.backends import APIKeyAuthentication
return APIKeyAuthentication()
diff --git a/tests/test_api_key_crypto.py b/tests/test_api_key_crypto.py
index f5f97d9..f2ad5c8 100644
--- a/tests/test_api_key_crypto.py
+++ b/tests/test_api_key_crypto.py
@@ -4,7 +4,7 @@
def key_crypto():
- from rest_framework_simple_api_key.crypto import get_crypto
+ from drf_apikey.crypto import get_crypto
return get_crypto()
diff --git a/tests/test_api_key_multi_crypto.py b/tests/test_api_key_multi_crypto.py
index 2768cee..3dc5fe3 100644
--- a/tests/test_api_key_multi_crypto.py
+++ b/tests/test_api_key_multi_crypto.py
@@ -3,15 +3,15 @@
import pytest
-from rest_framework_simple_api_key.crypto import ApiCrypto
-from rest_framework_simple_api_key.mutli_api_crypto import MultiApiCrypto
+from drf_apikey.crypto import ApiCrypto
+from drf_apikey.mutli_api_crypto import MultiApiCrypto
@pytest.mark.django_db
class TestCryptoFunctions:
@pytest.fixture(scope="class")
def key_crypto(self):
- from rest_framework_simple_api_key.crypto import get_crypto
+ from drf_apikey.crypto import get_crypto
return get_crypto()
diff --git a/tests/test_models.py b/tests/test_models.py
index 08be284..0505e0c 100644
--- a/tests/test_models.py
+++ b/tests/test_models.py
@@ -1,6 +1,6 @@
import pytest
-from rest_framework_simple_api_key.models import APIKey
+from drf_apikey.models import APIKey
from .fixtures.user import user
from .fixtures.api_key import active_api_key
diff --git a/tests/test_permissions.py b/tests/test_permissions.py
index b88dc9d..c7e9832 100644
--- a/tests/test_permissions.py
+++ b/tests/test_permissions.py
@@ -10,9 +10,9 @@
from rest_framework.test import APIRequestFactory
-from rest_framework_simple_api_key.backends import APIKeyAuthentication
-from rest_framework_simple_api_key.permissions import IsActiveEntity
-from rest_framework_simple_api_key.settings import package_settings
+from drf_apikey.backends import APIKeyAuthentication
+from drf_apikey.permissions import IsActiveEntity
+from drf_apikey.settings import package_settings
from .fixtures.api_key import inactive_entity_api_key, active_api_key
from .fixtures.user import inactive_user, user