Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/casdoor/django-casdoor-auth
Django auth middleware based on Casdoor
https://github.com/casdoor/django-casdoor-auth
auth cas casdoor django go iam middleware oauth oidc python sso
Last synced: 3 months ago
JSON representation
Django auth middleware based on Casdoor
- Host: GitHub
- URL: https://github.com/casdoor/django-casdoor-auth
- Owner: casdoor
- License: apache-2.0
- Created: 2021-11-12T12:11:17.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-07-25T01:55:44.000Z (over 1 year ago)
- Last Synced: 2024-11-09T00:46:39.252Z (3 months ago)
- Topics: auth, cas, casdoor, django, go, iam, middleware, oauth, oidc, python, sso
- Language: Python
- Homepage: https://pypi.org/project/django-casdoor-auth
- Size: 17.6 KB
- Stars: 21
- Watchers: 3
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# django-casdoor-auth
[![GitHub Action](https://github.com/casdoor/django-casdoor-auth/workflows/build/badge.svg?branch=master)](https://github.com/casdoor/django-casdoor-auth/actions)
[![Version](https://img.shields.io/pypi/v/django-casdoor-auth.svg)](https://pypi.org/project/django-casdoor-auth/)
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/django-casdoor-auth.svg)](https://pypi.org/project/django-casdoor-auth/)
[![Pyversions](https://img.shields.io/pypi/pyversions/django-casdoor-auth.svg)](https://pypi.org/project/django-casdoor-auth/)
[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/5rPsrAzK7S)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:
```shell
pip install django-casdoor-auth
```casdoor-auth is simple to use. We will show you the steps below.
## Step2. Config
setting.pyAdd "casdoor_auth" in INSTALLED_APPS
```python
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 |```python
CASDOOR_CONFIG = {
'endpoint': 'http://localhost:8000',
'client_id': '',
'client_secret': '',
'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.
```python
REDIRECT_URI = 'http://127.0.0.1:8000/casdoor/callback/'
```
The login redirect url, after login successfully, you will jump to this page.
```python
LOGIN_REDIRECT_URL = '/'
```
## Step3. router
urls.py```python
urlpatterns = [
...
path('casdoor/', include('casdoor_auth.urls')),
...
]
```
The casdoor_auth provider two functions for using Casdoor.
```python
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:
```html
casdoor`
```