Skip to main content

Django Middleware to authenticate users with Appwrite

Project description

Appwrite Middleware for Django

PyPI version PyPI - Python Version [PyPI - License]

A Django middleware to authenticate users with Appwrite.

Installation

To install django_appwrite, simply run:

$ pip install django-appwrite

Usage

  1. In your Django project's settings.py file, add django_appwrite to your MIDDLEWARE list:
MIDDLEWARE = [
    ...,
    'django_appwrite.middleware.AppwriteMiddleware',
    ...
]
  1. Configure the Appwrite client settings in your Django settings file:
APPWRITE = {
    'PROJECT_ENDPOINT': 'https://example.com/v1',
    'PROJECT_ID': 'PROJECT_ID',
    'PROJECT_API_KEY': 'PROJECT_API_KEY',
    'USER_ID_HEADER': 'USER_ID',
}
Setting Default Description
PROJECT_ENDPOINT The endpoint of your Appwrite project. You can find this in the Appwrite console under Settings > General.
PROJECT_ID The ID of your Appwrite project. You can find this in the Appwrite console under Settings > General.
PROJECT_API_KEY The API key of your Appwrite project. You can find this in the Appwrite console under Settings > API Keys.
USER_ID_HEADER USER_ID The header name that will be used to store the user ID.

How it works

This middleware class will get the user ID from the header specified in the USER_ID_HEADER setting. It will then use this user ID to retrieve the user information from Appwrite using the Users service. If a user is found, it will create a Django user if it doesn't exist, and authenticate the user.

Please note that this middleware is intended to be used in conjunction with the Appwrite client-side SDK to authorize users on the frontend, and does not provide any APIs for user authentication on its own.

License

The appwrite-drf package is released under the MIT License. See the bundled LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-appwrite-0.2.0.tar.gz (4.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page