An app for use Casdoor SSO
Project description
django-casdoor-auth
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
Built Distribution
Hashes for django-casdoor-auth-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4548222c76ee8dfb8c7a6d3b11ac7c54adf9da0ff1d17d727084f15ceba1462 |
|
MD5 | 6665f006679b5a29223dcfa3be1537d0 |
|
BLAKE2b-256 | a2727fb910e3c1721ca5f71fe4741e19ab27eb2733e5d230b334d0da2cec531c |
Hashes for django_casdoor_auth-1.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f3a7938a53723ae384d030ab0788dec7172ef1909eaa340cd4bd20cc488910f |
|
MD5 | c0f8329d58bd06764365de75f5b6d64a |
|
BLAKE2b-256 | 3b3d9dbd67690d0e922f7fec975fe3566284db7b1f93c0e992e2db2ff8137ee1 |