dxh-django


Namedxh-django JSON
Version 2.0.1 PyPI version JSON
download
home_pagehttps://github.com/devxhub/dxh-django
SummaryA Django package for development
upload_time2024-08-12 13:59:25
maintainerNone
docs_urlNone
authorDEVxHUB
requires_python>=3.9
licenseMIT
keywords python django package development devxhub dxh-django dxh devxhub-django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![build](https://img.shields.io/github/workflow/status/devxhub/dxh-django/Build)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/devxhub/dxh-django/pulls)
[![PyPI](https://img.shields.io/pypi/v/dxh-django)](https://pypi.org/project/dxh-django/)
![downloads](https://img.shields.io/pypi/dm/dxh-django)
![license](https://img.shields.io/pypi/l/dxh-django)
![code style](https://img.shields.io/badge/code%20style-black-black)

`dxh-django` is a Python package designed to integrate with AWS services and Anticaptcha in Django projects. This package simplifies the configuration and usage of `AWS S3`, `AWS Textract`, and `Anticaptcha` by centralizing credential management in your Django settings.

## Installation

To install the `dxh-django` package, use pip:

```sh
pip install dxh-django
```
## Configuration

After installing the package, add AWS and Anticaptcha credentials to the Django project's settings.py file. This ensures that the necessary credentials are available for the package to interact with the services

## AWS S3 Configuration
Add the following variables to your settings.py file:
```python
DJANGO_AWS_S3_REGION_NAME = '<your-aws-s3-region-name>'
DJANGO_AWS_ACCESS_KEY_ID = '<your-aws-access-key-id>'
DJANGO_AWS_SECRET_ACCESS_KEY = '<your-aws-secret-access-key>'
DJANGO_AWS_STORAGE_BUCKET_NAME = '<your-aws-storage-bucket-name>'
DJANGO_AWS_TEXTRACT_REGION_NAME = '<your-aws-textract-region-name>'
```

## Anticaptcha Configuration
Add the following variable to your `settings.py` file:

```python
ANTICAPTCHA_API_KEY = '<your-anticaptcha-api-key>'
```

## Usage
Once the settings are configured, the package can be used in the Django project as follows:
    
```python   
from dxh_django.aws.s3_client import S3Client
from dxh_django.aws.textract import textract_handler
from dxh_django.anticaptcha.captcha import AntiCaptchaSolver
```
```python
from dxh_django.s3_client import S3Client

# Initialize the S3 client
s3_client = S3Client()

# Upload a file to S3
s3_client.upload_to_s3('path/to/local/file', 's3/object/name')

# Delete an object from S3
s3_client.delete_from_s3(object_key='s3/object/name')
```

## Auditlog Configuration
To enable audit logging, include auditlog in INSTALLED_APPS and configure the AuditActorMiddleware.

Add auditlog to INSTALLED_APPS in settings.py:

```
INSTALLED_APPS = [
    ...
    'auditlog',
    ...
]
```

Add AuditActorMiddleware to MIDDLEWARE in settings.py:

```python
MIDDLEWARE = [
    ...
    'dxh_django.middleware.AuditActorMiddleware',
    ...
]
``` 

## Websocket Configuration

This middleware for JWT authentication in WebSocket connections.

Checks the 'authorization' header for a JWT token, retrieves the corresponding user,
and adds the user to the connection scope.

If the token is invalid or not provided, sets the user to AnonymousUser.

```python
from dxh_django.middleware import JwtAuthMiddleware


'websocket': JwtAuthMiddleware(
        AuthMiddlewareStack(
            URLRouter(websocket_urlpatterns)
        )
    )
``` 

## Supported Captcha Types:
1. reCAPTCHA v3
2. reCAPTCHA v2 (Invisible)
3. Image Captcha
4. Turnstile Captcha


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/devxhub/dxh-django",
    "name": "dxh-django",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "python, django, package, development, devxhub, dxh-django, dxh, devxhub-django",
    "author": "DEVxHUB",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/08/ec/4829e632ecaf30ad6bc35b855506faef5ab289713d2fc27c75866762321d/dxh-django-2.0.1.tar.gz",
    "platform": null,
    "description": "![build](https://img.shields.io/github/workflow/status/devxhub/dxh-django/Build)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/devxhub/dxh-django/pulls)\n[![PyPI](https://img.shields.io/pypi/v/dxh-django)](https://pypi.org/project/dxh-django/)\n![downloads](https://img.shields.io/pypi/dm/dxh-django)\n![license](https://img.shields.io/pypi/l/dxh-django)\n![code style](https://img.shields.io/badge/code%20style-black-black)\n\n`dxh-django` is a Python package designed to integrate with AWS services and Anticaptcha in Django projects. This package simplifies the configuration and usage of `AWS S3`, `AWS Textract`, and `Anticaptcha` by centralizing credential management in your Django settings.\n\n## Installation\n\nTo install the `dxh-django` package, use pip:\n\n```sh\npip install dxh-django\n```\n## Configuration\n\nAfter installing the package, add AWS and Anticaptcha credentials to the Django project's settings.py file. This ensures that the necessary credentials are available for the package to interact with the services\n\n## AWS S3 Configuration\nAdd the following variables to your settings.py file:\n```python\nDJANGO_AWS_S3_REGION_NAME = '<your-aws-s3-region-name>'\nDJANGO_AWS_ACCESS_KEY_ID = '<your-aws-access-key-id>'\nDJANGO_AWS_SECRET_ACCESS_KEY = '<your-aws-secret-access-key>'\nDJANGO_AWS_STORAGE_BUCKET_NAME = '<your-aws-storage-bucket-name>'\nDJANGO_AWS_TEXTRACT_REGION_NAME = '<your-aws-textract-region-name>'\n```\n\n## Anticaptcha Configuration\nAdd the following variable to your `settings.py` file:\n\n```python\nANTICAPTCHA_API_KEY = '<your-anticaptcha-api-key>'\n```\n\n## Usage\nOnce the settings are configured, the package can be used in the Django project as follows:\n    \n```python   \nfrom dxh_django.aws.s3_client import S3Client\nfrom dxh_django.aws.textract import textract_handler\nfrom dxh_django.anticaptcha.captcha import AntiCaptchaSolver\n```\n```python\nfrom dxh_django.s3_client import S3Client\n\n# Initialize the S3 client\ns3_client = S3Client()\n\n# Upload a file to S3\ns3_client.upload_to_s3('path/to/local/file', 's3/object/name')\n\n# Delete an object from S3\ns3_client.delete_from_s3(object_key='s3/object/name')\n```\n\n## Auditlog Configuration\nTo enable audit logging, include auditlog in INSTALLED_APPS and configure the AuditActorMiddleware.\n\nAdd auditlog to INSTALLED_APPS in settings.py:\n\n```\nINSTALLED_APPS = [\n    ...\n    'auditlog',\n    ...\n]\n```\n\nAdd AuditActorMiddleware to MIDDLEWARE in settings.py:\n\n```python\nMIDDLEWARE = [\n    ...\n    'dxh_django.middleware.AuditActorMiddleware',\n    ...\n]\n``` \n\n## Websocket Configuration\n\nThis middleware for JWT authentication in WebSocket connections.\n\nChecks the 'authorization' header for a JWT token, retrieves the corresponding user,\nand adds the user to the connection scope.\n\nIf the token is invalid or not provided, sets the user to AnonymousUser.\n\n```python\nfrom dxh_django.middleware import JwtAuthMiddleware\n\n\n'websocket': JwtAuthMiddleware(\n        AuthMiddlewareStack(\n            URLRouter(websocket_urlpatterns)\n        )\n    )\n``` \n\n## Supported Captcha Types:\n1. reCAPTCHA v3\n2. reCAPTCHA v2 (Invisible)\n3. Image Captcha\n4. Turnstile Captcha\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Django package for development",
    "version": "2.0.1",
    "project_urls": {
        "Homepage": "https://github.com/devxhub/dxh-django",
        "Source": "https://github.com/devxhub/dxh-django"
    },
    "split_keywords": [
        "python",
        " django",
        " package",
        " development",
        " devxhub",
        " dxh-django",
        " dxh",
        " devxhub-django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "08ec4829e632ecaf30ad6bc35b855506faef5ab289713d2fc27c75866762321d",
                "md5": "21ea12bc363689aedbc586331250dab8",
                "sha256": "81cabfce1ad4a3393af347ba0bc4766c25e045858909d4a2088713cd30bc3e83"
            },
            "downloads": -1,
            "filename": "dxh-django-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "21ea12bc363689aedbc586331250dab8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 10078,
            "upload_time": "2024-08-12T13:59:25",
            "upload_time_iso_8601": "2024-08-12T13:59:25.873084Z",
            "url": "https://files.pythonhosted.org/packages/08/ec/4829e632ecaf30ad6bc35b855506faef5ab289713d2fc27c75866762321d/dxh-django-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-12 13:59:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "devxhub",
    "github_project": "dxh-django",
    "github_not_found": true,
    "lcname": "dxh-django"
}
        
Elapsed time: 4.23904s