Skip to content

Commit

Permalink
Merge pull request #61 from koladev32/revert-60-revert-57-56-rename-p…
Browse files Browse the repository at this point in the history
…roject

Revert "Revert ":recycle: big renaming""
  • Loading branch information
koladev32 authored May 23, 2024
2 parents f4238ab + 76ce9ae commit 6225ca7
Show file tree
Hide file tree
Showing 61 changed files with 135 additions and 128 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Changelog
[Unreleased]
------------

[v2.0.0] - 2024-05-23
------------------

- Rename project (#56)

[v1.1.1] - 2024-05-23
------------------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).

<div>
<a href="https://badge.fury.io/py/djangorestframework-simple-apikey">
<img src="https://badge.fury.io/py/djangorestframework-simple-apikey.svg" alt="Version"/>
<a href="https://badge.fury.io/py/drf-apikey">
<img src="https://badge.fury.io/py/drf-apikey.svg" alt="Version"/>
</a>
<a href="https://github.com/koladev32/djangorestframework-simple-apikey/actions/workflows/ci-cd.yml">
<img src="https://github.com/koladev32/djangorestframework-simple-apikey/actions/workflows/ci-cd.yml/badge.svg" alt="Testing"/>
<a href="https://github.com/koladev32/drf-apikey/actions/workflows/ci-cd.yml">
<img src="https://github.com/koladev32/drf-apikey/actions/workflows/ci-cd.yml/badge.svg" alt="Testing"/>
</a>
</div>

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

Expand All @@ -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

Expand All @@ -34,15 +35,15 @@ 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

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:
Expand All @@ -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="
}
```
Expand All @@ -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
Expand Down Expand Up @@ -118,15 +120,15 @@ 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
Thank you for your interest in contributing to the project! Here's a guide to help you get started:

- **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:
```
Expand Down Expand Up @@ -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).
See [CONTRIBUTING.md](https://github.com/koladev32/drf-apikey/blob/main/CONTRIBUTING.md).
12 changes: 6 additions & 6 deletions docs/analytics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -31,16 +31,16 @@ 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
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.
Expand All @@ -50,15 +50,15 @@ 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
...
]
3. Run the migrate command to create the necessary database tables:

.. code-block:: shell
python manage.py migrate rest_framework_simple_api_key_analytics
python manage.py migrate drf-apikey_analytics
Activation
----------
Expand Down
6 changes: 3 additions & 3 deletions docs/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------------------------------------
Expand All @@ -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.
2 changes: 1 addition & 1 deletion docs/customizing_api_key_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand All @@ -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="
}
Expand All @@ -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):
Expand Down Expand Up @@ -119,10 +119,10 @@ Changelog
---------

See
`CHANGELOG.md <https://github.com/koladev32/djangorestframework-simple-apikey/blob/main/CHANGELOG.md>`__.
`CHANGELOG.md <https://github.com/koladev32/drf-apikey/blob/main/CHANGELOG.md>`__.

Contributing
------------

See
`CONTRIBUTING.md <https://github.com/koladev32/djangorestframework-simple-apikey/blob/main/CONTRIBUTING.md>`__.
`CONTRIBUTING.md <https://github.com/koladev32/drf-apikey/blob/main/CONTRIBUTING.md>`__.
10 changes: 5 additions & 5 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/permissions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ 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):
...
authentication_classes = (APIKeyAuthentication, )
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 <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/permissions.py <https://github.com/koladev32/drf-apikey/blob/main/drf-apikey/backends.py>`__.
10 changes: 5 additions & 5 deletions docs/rotation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:

Expand Down
4 changes: 2 additions & 2 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Loading

0 comments on commit 6225ca7

Please sign in to comment.