Your project description goes here
Project description
Make your authentication logs more easy with django-auth-audit
Please note
django-auth-audit
still an experimental project that originated as a feature in one of my professional projects. Due to the specific requirements and lack of existing GitHub repositories targeting this particular situation, I decided to create it as a separate project. As a result, the app is still in its early stages and may undergo frequent updates and improvements. Feedback and contributions are welcome.
Introduction
django-auth-audit
is a Django reusable app that provides functionality for tracking user authentication events, such as logins,logouts,password rest rate limit ...
It allows you to define custom mixins that override specific CRUD methods in your target class, send signals, and handle the flow back to your target class. Additionally, django-auth-audit includes a pre-defined mixins,that can be used to send signals and create authentication logs.
Installation
To install django-auth-audit
, follow these steps:
- Ensure you have Django installed in your project. If not, you can install it using pip:
pip install django
Download the django-auth-audit
package from the GitHub repository or install it using pip:
pip install django-auth-audit
Add django-auth-audit
to the INSTALLED_APPS setting in your Django project's settings.py file:
INSTALLED_APPS = [
...
'django-auth-audit',
...
]
Run the database migrations to create the necessary tables for the app:
python manage.py migrate django-auth-audit
Usage
django-auth-audit
allows you to create custom mixins that override specific CRUD methods in your target class, send signals, and handle the flow back to your target class.
Here's an example:
from dj_auth_audit.mixins import FailedResetEmailSignalMixin
class CustomPasswordResetView(FailedResetEmailSignalMixin, PasswordResetView):
class_name = 'PasswordResetView'
serializer_class = CustomPasswordResetSerializer
throttle_scope = 'reset_password_rate'
In this example, the CustomPasswordResetView
class inherits from FailedResetEmailSignalMixin
and PasswordResetView
. The FailedResetEmailSignalMixin
sends a signal and creates an authentication log in the database, indicating the time of the sent reset email and the user who requested the password reset. If the user reaches the rate limit, another signal is triggered to indicate that the user has exceeded the password reset rate.
The FailedResetEmailSignalMixin is hooked with the POST and throttled methods, which are typically defined in the target class. To use this mixin, you need to define the class_name
attribute in the subclass alongside with the self.user to define the actor.
Note
django-auth-audit
has a built-in mixin for all basic authentication logs you will need ,inclusing but not limited to : Login
, Logout
,password change
,password reset
,verfication email
... and if you define a throttle scope on the subclass , you will get rate limit signal the user have exceeded the allowed request rate.
You can also define your own mixin by inheriting from AbstractSignalMixin
in the mixin.py
file.
Note: The FailedResetEmailSignalMixin
or any other mixin will raise an exception if:
- class_name is not defined.
- The target class doesn't have any of the required methods for sending requests (
POST
,GET
...) - The self.user is not defined.
Please refer to
mixin.py
for more information on creating custom mixins and using the provided mixins.
Contributing
If you'd like to contribute to this project, please follow these guidelines:
Fork the repository on GitHub. Create a new branch from the master branch for your feature or bug fix. Make your changes and ensure they are properly tested. Commit your changes with clear and descriptive commit messages. Push your branch to your forked repository. Submit a pull request to the master branch of the this repository. Please refer to the Contribution Guidelines for more information.
License
django-auth-audit
is released under the MIT License. See the LICENSE file for more details.
Support
If you encounter any issues or have questions, please open an issue on the GitHub repository.
History
0.1.0 (2023-07-16) ++++++++++++++++++
- First release on PyPI.
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
File details
Details for the file django-auth-audit-0.0.tar.gz
.
File metadata
- Download URL: django-auth-audit-0.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21fc1b2dce1cb33a49bcae666f5098d782b01cb0b8763e9c4b08bddd8eb0cce9 |
|
MD5 | a9c502b15dc71009275ec69771486c60 |
|
BLAKE2b-256 | da0c7f034aa92db17ceaafa173a473e62ba1ae5d9c05f20a2920eb5e22c05bdf |
File details
Details for the file django_auth_audit-0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: django_auth_audit-0.0-py2.py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e217db2f6cc33f8b5240e4d423f42e146c97d925e9ddbf84b8df75e7ef47acac |
|
MD5 | ae009f3e271b61ee2be7baca990016cf |
|
BLAKE2b-256 | f40045668f34644c118e9f4579f05bca3d2da8ecde1dcad7dad702a611c1977c |