Skip to main content

django-casdoor-auth

GitHub Action Version PyPI - Wheel Pyversions Discord

Casdoor's SDK for Django will allow you to easily connect your application to the Casdoor authentication system without having to implement it from scratch.

Step1. install app

django-casdoor-auth is available on PyPI:

pip install django-casdoor-auth

casdoor-auth is simple to use. We will show you the steps below.

Step2. Config

setting.py

Add "casdoor_auth" in INSTALLED_APPS

INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "casdoor_auth"
]

Initialization requires 6 parameters, which are all str type:

Name (in order) Must Description
endpoint Yes Casdoor Server Url, such as http://localhost:8000
client_id Yes Application.client_id
client_secret Yes Application.client_secret
certificate Yes The public key for the Casdoor application's cert
org_name Yes Application.organization
application_name Yes Application.name
CASDOOR_CONFIG = {
    'endpoint': 'http://localhost:8000',
    'client_id': '<client-id>',
    'client_secret': '<client-secret>',
    'certificate': '''<certificate>''',
    'org_name': 'built-in',
    'application_name': 'app-built-in'
}

The redirect url, is the URL that your APP is configured to listen to the response from Casdoor.

REDIRECT_URI = 'http://127.0.0.1:8000/casdoor/callback/'

The login redirect url, after login successfully, you will jump to this page.

LOGIN_REDIRECT_URL = '/'

Step3. router

urls.py

urlpatterns = [
    ...
    path('casdoor/', include('casdoor_auth.urls')),
    ...
]

The casdoor_auth provider two functions for using Casdoor.

urlpatterns = [
    path('login/', views.toLogin, name='casdoor_sso'),
    path('callback/', views.callback, name='callback'),
]

To add a button for using the Casdoor login, for example:

<button><a href="{% url 'casdoor_sso' %}">casdoor</a></button>`

Metadata

Release files for django-casdoor-auth 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-casdoor-auth 1.1.0
File Size Uploaded
django-casdoor-auth-1.1.0.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-casdoor-auth 1.1.0
File Interpreter ABI Platform
django_casdoor_auth-1.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 18.4 kB

Release files / django-casdoor-auth-1.1.0.tar.gz

Download URL django-casdoor-auth-1.1.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
87f7a5a88fedb997b4f078bce9f48650b68ac106582697f2a193cc08f59b0f88
BLAKE2b-256 checksum
How to use checksums
72a9488ec36db927817fc3a661c55dc9080320327ab7b12dbc4ab8322c34aef6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.17

Release files / django_casdoor_auth-1.1.0-py2.py3-none-any.whl

Download URL django_casdoor_auth-1.1.0-py2.py3-none-any.whl
Size 10.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5b13f3a6484616b43633c78701dd410be118c53fb89cc505be0ef0353bf45acc
BLAKE2b-256 checksum
How to use checksums
52c96c49ab3953ae7e951444f52cf4cf9bcb537ebb26ee939e36f3503b5f9390
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.17

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page