Skip to main content

An app for use Casdoor SSO

Project description

django-casdoor-auth

GitHub Action Version PyPI - Wheel Pyversions Gitter

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>`

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-casdoor-auth-1.0.2.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

django_casdoor_auth-1.0.2-py2.py3-none-any.whl (10.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-casdoor-auth-1.0.2.tar.gz.

File metadata

  • Download URL: django-casdoor-auth-1.0.2.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for django-casdoor-auth-1.0.2.tar.gz
Algorithm Hash digest
SHA256 dde415c9a79d511ad868020c90ad48741ca88c0e4d5e96e87216371a26f964d7
MD5 5d2aee67bf68ac3d5765879bc2f7329a
BLAKE2b-256 8d25358fbe1f8c707dc34be3b3c1dd1feb70b949f7ef0e6a1a2adaa7255c0c8d

See more details on using hashes here.

File details

Details for the file django_casdoor_auth-1.0.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_casdoor_auth-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c077c5a764c11997c5c2c45e8fe1460d5ec4e8b0a429a6a4cb7bf91896015c61
MD5 9379a310bdc57e29c596c2e1abdc67af
BLAKE2b-256 1dfb1e3a3c8233899023087b317b21995787ff2a4ce6e06fa4a0bf044484951b

See more details on using hashes here.

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