The Casdoor Dify Plugin integrates Casdoor OAuth-based authentication into the Dify ecosystem as an extension plugin. It provides endpoints to handle OAuth login, signup, and callback flows, enabling seamless user authentication via Casdoor.
- OAuth Authentication:
Implements login, signup, and callback endpoints to facilitate the Casdoor OAuth flow. - Dify Plugin Integration:
Uses a plugin manifest and endpoint YAML definitions to register the plugin with Dify. - Environment-Based Configuration:
Loads sensitive credentials (certificates, client IDs, secrets, etc.) from a.envfile. - Local Testing with Flask:
Includes a Flask-based server (main.py) for local development and testing.
.
├── GUIDE.md # Quick start guide for plugin development
├── README.md # Project documentation
├── _assets
│ └── icon.svg # Plugin icon asset
├── endpoints
│ ├── casdoor_auth.py # Casdoor OAuth logic implementation
│ ├── casdoor_login.yaml # Endpoint manifest for login
│ ├── casdoor_signup.yaml # Endpoint manifest for signup
│ └── casdoor_callback.yaml # Endpoint manifest for callback
├── main.py # Entry point for local testing (Flask server)
├── manifest.yaml # Plugin manifest for Dify integration
└── requirements.txt # Python dependencies list
- Python: Version 3.12 or higher.
- Poetry: For dependency management. (Installation Guide)
- Dify Plugin Scaffolding Tool: (Optional) For further development and testing on the Dify platform.
- Environment Variables: A
.envfile containing your Casdoor credentials is required.
- Clone the Repository:
git clone <repository-url> cd casdoor-dify-plugin
- Install Dependencies:
poetry install
Create a .env file in the project root and populate it with your Casdoor credentials:
# Casdoor Configuration
CASDOOR_CERT="-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----"
CASDOOR_ENDPOINT=https://your-casdoor-endpoint.example
CASDOOR_CLIENT_ID=your_client_id
CASDOOR_CLIENT_SECRET=your_client_secret
CASDOOR_ORG_NAME=your_organization_name
CASDOOR_APP_NAME=your_app_name
# Installation Configuration
INSTALL_METHOD=remote
REMOTE_INSTALL_HOST=debug.dify.ai
REMOTE_INSTALL_PORT=5003
REMOTE_INSTALL_KEY=********-****-****-****-************
# Database Configuration
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=your_db_host
DB_PORT=your_db_port
DB_NAME=your_db_name
# Shared Secret for Generating Dify Tokens
SECRET_KEY=your_secret_key
# Redis Configuration
REDIS_HOST=your_redis_host
REDIS_PORT=your_redis_port
REDIS_PASSWORD=your_redis_password
REDIS_DB=your_redis_db
For local testing, run the Flask server with:
poetry run python main.pyThis starts the server on http://0.0.0.0:8000.
- Login Endpoint:
Navigate to http://localhost:8000/casdoor/login to initiate the Casdoor OAuth login flow. - Signup Endpoint:
Visit http://localhost:8000/casdoor/signup to start the signup process. - Callback Endpoint:
After authentication, Casdoor redirects to http://localhost:8000/casdoor/callback. This endpoint exchanges the authorization code for tokens and parses the JWT.
This repository is structured as a Dify extension plugin:
- Manifest File (
manifest.yaml):
Contains metadata and required permissions for plugin registration with Dify. - Endpoint YAML Files (in
endpoints/):
Define the API paths and HTTP methods for login, signup, and callback endpoints.
For more details on developing and integrating plugins with Dify, please refer to the Dify Plugin Documentation.
Contributions are welcome! Fork the repository and submit pull requests for any improvements. For significant changes, please open an issue to discuss your ideas first.
This project is licensed under the MIT License.
For questions or support, please contact Mohammad Fotouhi.