Metadata-Version: 2.1
Name: django-ory-auth
Version: 0.1.3
Summary: A django package to enable integration with Ory Cloud
Home-page: https://github.com/gen1us2k/django_ory_auth
License: Apache 2
Keywords: django,ory cloud,auth
Author: Andrew Minkin
Author-email: minkin.andrew@gmail.com
Requires-Python: >=3.7,<4.0
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.0
Classifier: Framework :: Django :: 4
Classifier: Framework :: Django CMS
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: Django (>3)
Requires-Dist: requests
Requires-Dist: urllib3 (>=1.26.9,<2.0.0)
Project-URL: Repository, https://github.com/gen1us2k/django_ory_auth
Description-Content-Type: text/markdown

# Ory Django

This package provides integration with Ory Cloud or Ory Kratos for your django application

## Installing

You can simply run

```
   pip install django_ory_auth
```

or

```
   poetry add django_ory_auth
```

or

```
   pipenv install django_ory_auth
```

Add `django_ory_auth` to `INSTALLED_APPS`

```python
INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.sites",
    "django_ory_auth"
]
```

## Configuration

You need to add these variables to your settings

```python
ORY_SDK_URL=https://projectId.projects.oryapis.com
ORY_UI_URL=https://projectId.projects.oryapis.com/ui
LOGIN_URL=https://projectId.projects.oryapis.com/ui/login
```

`django_ory_auth` provides authentication backend. You must replace `ModelBackend` with `OryBackend` in the `AUTHENTICATION_BACKENDS` setting

```python
AUTHENTICATION_BACKENDS = [
    "django_ory_auth.backend.OryBackend",
]
```

Last step is to add `django_ory_auth.middleware.AuthenticationMiddleware` under `django.contrib.auth.middleware.AuthenticationMiddleware`

```python

MIDDLEWARE = [
    …
    "django.contrib.auth.middleware.AuthenticationMiddleware",
    "django_ory_auth.middleware.AuthenticationMiddleware",
    ...
]
```

## Using context processors

The package provides context processor to provide the following urls

- login_url
- logout_url (for authenticated users)
- signup_url
- recovery_url
- verify_url
- profile_url (available for authenticated users)

to enable context processor add `django_ory_auth.context.processor` to the `context_processor` setting

