### Clone and Install Example Project Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/mobile-sdks/react-native-app.md Clone the example project from GitHub and install its dependencies. This includes running `pod install` for iOS. ```bash git clone git@github.com:casdoor/casdoor-react-native-example.git cd casdoor-react-native-example yarn install cd ios/ && pod install && cd .. ``` -------------------------------- ### Install Frontend Dependencies and Start Source: https://github.com/casdoor/casdoor-website/blob/master/docs/basic/server-installation.mdx Navigate to the `web` directory, install frontend dependencies using Yarn, and start the development server for the Casdoor UI. ```bash cd web yarn install yarn start ``` -------------------------------- ### Install Dependencies and Start Development Server Source: https://github.com/casdoor/casdoor-website/blob/master/README.md Commands to clone the repository, install dependencies using Yarn, and start the local development server. ```bash git clone https://github.com/casdoor/casdoor-website.git cd casdoor-website yarn install yarn start ``` -------------------------------- ### Go SAML 2.0 Service Provider Example Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/saml/overview.md This Go code demonstrates how to set up a SAML 2.0 Service Provider using the gosaml2 library. It fetches IdP metadata, configures the SP, and handles SAML responses. Ensure the IdP metadata URL and application name are correct for your Casdoor setup. ```go import ( "crypto/x509" "fmt" "net/http" "io/ioutil" "encoding/base64" "encoding/xml" saml2 "github.com/russellhaering/gosaml2" "github.com/russellhaering/gosaml2/types" dsig "github.com/russellhaering/goxmldsig" ) func main() { res, err := http.Get("http://localhost:7001/api/saml/metadata?application=admin/app-built-in") if err != nil { panic(err) } rawMetadata, err := ioutil.ReadAll(res.Body) if err != nil { panic(err) } metadata := &types.EntityDescriptor{} err = xml.Unmarshal(rawMetadata, metadata) if err != nil { panic(err) } certStore := dsig.MemoryX509CertificateStore{ Roots: []*x509.Certificate{}, } for _, kd := range metadata.IDPSSODescriptor.KeyDescriptors { for idx, xcert := range kd.KeyInfo.X509Data.X509Certificates { if xcert.Data == "" { panic(fmt.Errorf("metadata certificate(%d) must not be empty", idx)) } certData, err := base64.StdEncoding.DecodeString(xcert.Data) if err != nil { panic(err) } idpCert, err := x509.ParseCertificate(certData) if err != nil { panic(err) } certStore.Roots = append(certStore.Roots, idpCert) } } randomKeyStore := dsig.RandomKeyStoreForTest() sp := &saml2.SAMLServiceProvider{ IdentityProviderSSOURL: metadata.IDPSSODescriptor.SingleSignOnServices[0].Location, IdentityProviderIssuer: metadata.EntityID, ServiceProviderIssuer: "http://localhost:6900/acs/example", AssertionConsumerServiceURL: "http://localhost:6900/v1/_saml_callback", SignAuthnRequests: true, AudienceURI: "http://localhost:6900/saml/acs/example", IDPCertificateStore: &certStore, SPKeyStore: randomKeyStore, } http.HandleFunc("/v1/_saml_callback", func(rw http.ResponseWriter, req *http.Request) { err := req.ParseForm() if err != nil { rw.WriteHeader(http.StatusBadRequest) return } samlReponse := req.URL.Query().Get("SAMLResponse") assertionInfo, err := sp.RetrieveAssertionInfo(samlReponse) if err != nil { fmt.Println(err) rw.WriteHeader(http.StatusForbidden) return } fmt.Println(assertionInfo) if assertionInfo.WarningInfo.InvalidTime { fmt.Println("here12:", assertionInfo.WarningInfo.InvalidTime) rw.WriteHeader(http.StatusForbidden) return } if assertionInfo.WarningInfo.NotInAudience { fmt.Println(assertionInfo) fmt.Println("here13:", assertionInfo.WarningInfo.NotInAudience) rw.WriteHeader(http.StatusForbidden) return } fmt.Fprintf(rw, "NameID: %s\n", assertionInfo.NameID) fmt.Fprintf(rw, "Assertions:\n") for key, val := range assertionInfo.Values { fmt.Fprintf(rw, " %s: %+v\n", key, val) } fmt.Println(assertionInfo.Values.Get("FirstName")) fmt.Fprintf(rw, "\n") fmt.Fprintf(rw, "Warnings:\n") fmt.Fprintf(rw, "%+v\n", assertionInfo.WarningInfo) }) println("Visit this URL To Authenticate:") authURL, err := sp.BuildAuthURL("") if err != nil { panic(err) } println(authURL) println("Supply:") fmt.Printf(" SP ACS URL : %s\n", sp.AssertionConsumerServiceURL) err = http.ListenAndServe(":6900", nil) if err != nil { panic(err) } } ``` -------------------------------- ### Docker Compose Setup and Execution Source: https://context7.com/casdoor/casdoor-website/llms.txt Steps to download default Casdoor configuration files, edit `app.conf`, and start the Docker Compose deployment. Includes commands to check logs. ```bash # Download default config files mkdir -p conf logs wget https://raw.githubusercontent.com/casdoor/casdoor/master/conf/app.conf -O conf/app.conf wget https://raw.githubusercontent.com/casdoor/casdoor/master/init_data.json.template -O conf/init_data.json # Edit conf/app.conf with your database settings, then: docker-compose up -d # Check logs docker-compose logs casdoor ``` -------------------------------- ### ELK Configuration File Example Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/go/elk.md This is an example configuration file for the casdoor/elk-auth-casdoor reverse proxy. Customize the values for your specific Casdoor and ELK setup. ```ini appname = . # port on which the reverse proxy shall be run httpport = 8080 runmode = dev # EDIT IT IF NECESSARY. The URL of this reverse proxy. pluginEndpoint = "http://localhost:8080" # EDIT IT IF NECESSARY. The URL of the Kibana. targetEndpoint = "http://localhost:5601" # EDIT IT. The URL of Casdoor. casdoorEndpoint = "http://localhost:8000" # EDIT IT. The clientID of your reverse proxy in Casdoor. clientID = ceb6eb261ab20174548d # EDIT IT. The clientSecret of your reverse proxy in Casdoor. clientSecret = af928f0ef1abc1b1195ca58e0e609e9001e134f4 # EDIT IT. The application name of your reverse proxy in Casdoor. appName = ELKProxy # EDIT IT. The organization to which your reverse proxy belongs in Casdoor. organization = built-in ``` -------------------------------- ### Install Go SDKs for JWT Validation Source: https://github.com/casdoor/casdoor-website/blob/master/docs/mcp-auth/third-party-integration.md Install the necessary Go SDKs for interacting with Casdoor and performing JWT validation. These packages are required for the Go example. ```bash go get github.com/casdoor/casdoor-go-sdk/casdoorsdk go get github.com/golang-jwt/jwt/v5 ``` -------------------------------- ### Start Local Development Environment with Docker Compose Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/cli.md Starts a local Casdoor development environment using Docker Compose. Ensure Docker and Docker Compose are installed. ```bash docker compose up -d ``` -------------------------------- ### Go SDK: Create, Get, List, Update, and Delete Application Source: https://context7.com/casdoor/casdoor-website/llms.txt Examples using the Casdoor Go SDK to programmatically manage OAuth applications. This includes creating new applications with specified URIs and token formats, retrieving, listing, updating, and deleting them. ```go // Go SDK – create a new application import ( auth "github.com/casdoor/casdoor-go-sdk/casdoorsdk" ) newApp := &auth.Application{ Owner: "casbin", Name: "app-my-service", DisplayName: "My Service", Organization: "casbin", EnablePassword: true, EnableSignUp: true, RedirectUris: []string{"https://myservice.com/callback"}, TokenFormat: "JWT", ExpireInHours: 168, // 1 week RefreshExpireInHours: 720, } // AddApplication auto-populates signup/signin items with sensible defaults added, err := auth.AddApplication(newApp) if err != nil { log.Fatal(err) } fmt.Println("Created:", added.Name, "ClientId:", added.ClientId) // Get an application app, err := auth.GetApplication("app-my-service") // List all applications apps, err := auth.GetApplications() // Update app.ExpireInHours = 336 updated, err := auth.UpdateApplication(app) // Delete deleted, err := auth.DeleteApplication(newApp) ``` -------------------------------- ### Build and Install Casdoor CLI for Linux Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/cli.md Builds the Casdoor CLI binary for Linux and installs it. Ensure Go 1.22.0 or higher is installed. ```bash make build TARGET_OS=linux && make install TARGET_OS=linux ``` -------------------------------- ### Example OpenID Configuration Output Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/C++/Nginx.md This is an example of the relevant fields obtained from the OpenID configuration endpoint. ```json { "authorization_endpoint": "https:///login/oauth/authorize", "...":"...", "token_endpoint": "http:///api/login/oauth/access_token", "...":"...", "jwks_uri": "http:///.well-known/jwks", "...":"..." } ``` -------------------------------- ### Start MinIO Server Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/go/minio.md Start a MinIO server instance. Ensure you set the root user and password for authentication. The console address and port can be specified using `--console-address`. ```shell export MINIO_ROOT_USER=minio export MINIO_ROOT_PASSWORD=minio123 minio server /mnt/export ``` -------------------------------- ### Auth URL Example Source: https://github.com/casdoor/casdoor-website/blob/master/docs/provider/oauth/CustomProvider.md This is an example of the authorization URL sent to the IdP. When PKCE is enabled, additional parameters for code challenge are appended. ```url https://door.casdoor.com/login/oauth/authorize?client_id={ClientID}&redirect_uri=https://{your-casdoor-hostname}/callback&state={State_generated_by_Casdoor}&response_type=code&scope={Scope} ``` ```url https://door.casdoor.com/login/oauth/authorize?client_id={ClientID}&redirect_uri=https://{your-casdoor-hostname}/callback&state={State_generated_by_Casdoor}&response_type=code&scope={Scope}&code_challenge={code_challenge}&code_challenge_method=S256 ``` -------------------------------- ### CasdoorAuthService Examples Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/java/spring-boot.mdx Examples for obtaining OAuth tokens and parsing JWT tokens. ```APIDOC ## CasdoorAuthService ### getOAuthToken Obtains an OAuth token from Casdoor. ```java String token = casdoorAuthService.getOAuthToken(code, "app-built-in"); ``` ### parseJwtToken Parses a JWT token to retrieve user information. ```java CasdoorUser casdoorUser = casdoorAuthService.parseJwtToken(token); ``` ``` -------------------------------- ### Example Output: List Applications Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/mcp/connect-claude-desktop.md This is an example of the expected output when you ask Claude to list all applications in your Casdoor instance. The response will detail the applications found. ```text I found the following applications in your Casdoor instance: 1. claude-desktop-mcp (Claude Desktop MCP Client) 2. app-built-in (Casdoor) ... ``` -------------------------------- ### Verify OAuth2-Proxy Installation Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/C++/NginxCommunityVersion.md Check if the OAuth2-Proxy binary was installed correctly by running the version command. ```bash cd ~ oauth2-proxy --version ``` -------------------------------- ### Build and Install Casdoor CLI for macOS and Linux Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/cli.md Build and install the Casdoor CLI for your operating system. This involves using the 'make' command to compile and install the binary. ```bash make build TARGET_OS=darwin && make install TARGET_OS=darwin # For macOS ``` ```bash make build TARGET_OS=linux && make install TARGET_OS=linux # For Linux ``` ```bash casdoor login ``` -------------------------------- ### CasdoorResourceService API Examples Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/java/spring-cloud-gateway.md Examples demonstrating resource upload and deletion using the CasdoorResourceService. ```java CasdoorResponse response = casdoorResourceService.uploadResource(user, tag, parent, fullFilePath, file); ``` ```java CasdoorResponse response = casdoorResourceService.deleteResource(file.getName()); ``` -------------------------------- ### Install Casdoor Helm Chart Source: https://github.com/casdoor/casdoor-website/blob/master/docs/basic/try-with-helm.md Installs the Casdoor Helm chart from a registry. Specify the version to ensure reproducibility. ```shell helm install casdoor oci://registry-1.docker.io/casbin/casdoor-helm-charts --version ``` -------------------------------- ### Example Application-Specific OIDC Discovery URLs Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/oidc-client.md Example URLs for an application named 'app-example'. These endpoints provide isolated OIDC configurations for multi-tenant deployments. ```url https://door.casdoor.com/.well-known/app-example/openid-configuration ``` ```url https://door.casdoor.com/.well-known/app-example/oauth-authorization-server ``` -------------------------------- ### CasdoorUserService API Examples Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/java/spring-cloud-gateway.md Examples showcasing various operations available through the CasdoorUserService for managing users. ```java CasdoorUser casdoorUser = casdoorUserService.getUser("admin"); ``` ```java CasdoorUser casdoorUser = casdoorUserService.getUserByEmail("admin@example.com"); ``` ```java CasdoorUser[] casdoorUsers = casdoorUserService.getUsers(); ``` ```java CasdoorUser[] casdoorUsers = casdoorUserService.getSortedUsers("created_time", 5); ``` ```java int count = casdoorUserService.getUserCount("0"); ``` ```java CasdoorResponse response = casdoorUserService.addUser(user); ``` ```java CasdoorResponse response = casdoorUserService.updateUser(user); ``` ```java CasdoorResponse response = casdoorUserService.deleteUser(user); ``` -------------------------------- ### CasdoorAuthService API Examples Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/java/spring-cloud-gateway.md Examples demonstrating how to obtain an OAuth token and parse a JWT token using the CasdoorAuthService. ```java String token = casdoorAuthService.getOAuthToken(code, "app-built-in"); ``` ```java CasdoorUser casdoorUser = casdoorAuthService.parseJwtToken(token); ``` -------------------------------- ### UserInfo URL Request Example Source: https://github.com/casdoor/casdoor-website/blob/master/docs/provider/oauth/CustomProvider.md This example demonstrates how Casdoor fetches user information from the UserInfo URL using the obtained access token. ```bash curl -X GET -H "Authorization: Bearer {accessToken}" https://door.casdoor.com/api/userinfo ``` -------------------------------- ### Install MCP Proxy Dependencies Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/mcp/connect-chatgpt.md Install the necessary packages for building an MCP proxy server using Node.js. This includes the SDK and Express framework. ```bash npm install @modelcontextprotocol/sdk express ``` -------------------------------- ### Example ChatGPT Prompts for Casdoor MCP Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/mcp/connect-chatgpt.md Use these example prompts in ChatGPT to test the connection and interact with your Casdoor instance. These leverage the MCP tools for executing commands. ```text Using Casdoor, list all applications Show me details about the application named 'my-app' from Casdoor Create a new application in Casdoor called 'test-app' in organization 'my-org' ``` -------------------------------- ### Casdoor CLI Configuration Example Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/cli.md Example configuration file for the Casdoor CLI, specifying connection details for your Casdoor instance. This file should be placed at ~/.casdoor-cli/config.yaml. ```yaml application_name: your-app-name casdoor_endpoint: https://your-casdoor-instance.com certificate: | -----BEGIN CERTIFICATE----- Your certificate content here -----END CERTIFICATE----- client_id: your-client-id client_secret: your-client-secret organization_name: your-organization redirect_uri: http://localhost:9000/callback ``` -------------------------------- ### Example Integration: Create and Upgrade Guest User Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/guest-auth.md This JavaScript example demonstrates how to create a guest user by sending a POST request to the token endpoint and how to later upgrade that user by updating their username or password. ```javascript // Create a guest user async function createGuestUser() { const response = await fetch('https://your-casdoor-host/api/login/oauth/access_token', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ grant_type: 'authorization_code', client_id: 'your_client_id', client_secret: 'your_client_secret', code: 'guest-user' }) }); const data = await response.json(); return data.access_token; } // Later, upgrade the guest user async function upgradeGuestUser(accessToken, newUsername, newPassword) { const response = await fetch('https://your-casdoor-host/api/update-user', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${accessToken}` }, body: JSON.stringify({ name: newUsername, password: newPassword }) }); return response.json(); } ``` -------------------------------- ### Quick Start with Binaries (Linux/macOS) Source: https://github.com/casdoor/casdoor-website/blob/master/docs/basic/server-installation.mdx Extract the downloaded Casdoor binary archive, navigate into the extracted directory, edit the database configuration in `conf/app.conf`, and then run the Casdoor executable. ```bash tar -xzf casdoor_Linux_x86_64.tar.gz cd casdoor_Linux_x86_64 # Edit conf/app.conf with your database settings ./casdoor ``` -------------------------------- ### Get Account API Response with Original Token Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/oauth.md Example response from the /api/get-account endpoint, showing the 'originalToken' field which contains the OAuth provider's access token. ```json { "status": "ok", "data": { "name": "user123", "originalToken": "ya29.a0AfH6SMBx...", ... } } ``` -------------------------------- ### Build Frontend Static Assets Source: https://github.com/casdoor/casdoor-website/blob/master/docs/basic/server-installation.mdx Navigate to the web directory, install dependencies, and build the static assets for the frontend. ```bash cd web yarn install yarn build ``` -------------------------------- ### Install OAuth2-Proxy Binary Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/C++/NginxCommunityVersion.md Copy the OAuth2-Proxy binary to a system-wide executable path and set execute permissions. Use sudo if necessary. ```bash cp ./oauth2-proxy /usr/local/bin cd /usr/local/bin chmod +x ./oauth2-proxy ``` -------------------------------- ### Initialize MCP Server Instance Source: https://github.com/casdoor/casdoor-website/blob/master/docs/mcp-auth/third-party-integration.md Instantiates the MCP server with a given name. This is the starting point for setting up the MCP server. ```python app = Server("example-mcp-server") ``` -------------------------------- ### Build and Install Casdoor CLI for macOS Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/cli.md Builds the Casdoor CLI binary for macOS and installs it. Ensure Go 1.22.0 or higher is installed. ```bash make build TARGET_OS=darwin && make install TARGET_OS=darwin ``` -------------------------------- ### Build Frontend with npm Source: https://github.com/casdoor/casdoor-website/blob/master/docs/deployment/nginx.mdx Installs dependencies and builds the frontend static files using npm. This is a prerequisite for deployment. ```bash npm install && npm run build ``` -------------------------------- ### Complete MCP Client DCR Example Source: https://github.com/casdoor/casdoor-website/blob/master/docs/application/dynamic-client-registration.md Implement Dynamic Client Registration from scratch by first discovering the registration endpoint and then registering the application with specified metadata. Store the returned client credentials for subsequent OAuth flows. This example assumes a native application type. ```javascript // Discover the registration endpoint const discovery = await fetch('https://your-casdoor.com/.well-known/openid-configuration') .then(r => r.json()); // Register the application const registration = await fetch(discovery.registration_endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ client_name: 'MCP Client', redirect_uris: ['http://127.0.0.1:6437/callback'], grant_types: ['authorization_code', 'refresh_token'], token_endpoint_auth_method: 'none', application_type: 'native' }) }).then(r => r.json()); // Store credentials for OAuth flows const { client_id, client_secret } = registration; ``` -------------------------------- ### CasdoorEmailService Example Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/java/spring-boot.mdx Example for sending an email using the Casdoor email service. ```APIDOC ## CasdoorEmailService ### sendEmail Sends an email to a specified recipient. ```java CasdoorResponse response = casdoorEmailService.sendEmail(title, content, sender, receiver); ``` ``` -------------------------------- ### Build and Run Casdoor Backend from Source Source: https://context7.com/casdoor/casdoor-website/llms.txt Instructions for cloning the Casdoor repository, building, and running the backend application in development or production modes. ```bash # Clone and run backend (port 8000) git clone https://github.com/casdoor/casdoor cd casdoor go run main.go # dev mode # Build and run production binary go build ./casdoor --config /etc/casdoor/app.conf # Frontend (port 7001 in dev) cd web yarn install yarn start # dev yarn build # production assets served by backend on port 8000 ``` -------------------------------- ### CasdoorResourceService Examples Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/java/spring-boot.mdx Examples for uploading and deleting resources using the Casdoor resource service. ```APIDOC ## CasdoorResourceService ### uploadResource Uploads a resource file to Casdoor. ```java CasdoorResponse response = casdoorResourceService.uploadResource(user, tag, parent, fullFilePath, file); ``` ### deleteResource Deletes a resource file from Casdoor by its name. ```java CasdoorResponse response = casdoorResourceService.deleteResource(file.getName()); ``` ``` -------------------------------- ### Run the MCP Server Source: https://github.com/casdoor/casdoor-website/blob/master/docs/mcp-auth/third-party-integration.md This is the main entry point for running the MCP server. It uses an asynchronous server to handle read and write streams, initializing the application with the necessary options. ```python async def main(): """Run the MCP server""" async with stdio_server() as (read_stream, write_stream): await app.run( read_stream, write_stream, app.create_initialization_options() ) if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### CasdoorSmsService Example Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/java/spring-boot.mdx Example for sending an SMS message using the Casdoor SMS service. ```APIDOC ## CasdoorSmsService ### sendSms Sends an SMS message with a random code to a recipient. ```java CasdoorResponse response = casdoorSmsService.sendSms(randomCode(), receiver); ``` ``` -------------------------------- ### Build Frontend with Yarn Source: https://github.com/casdoor/casdoor-website/blob/master/docs/deployment/nginx.mdx Installs dependencies and builds the frontend static files using Yarn. This is a prerequisite for deployment. ```bash yarn install && yarn run build ``` -------------------------------- ### Download Casdoor Configuration Files Source: https://github.com/casdoor/casdoor-website/blob/master/docs/deployment/docker.mdx Download the default Casdoor configuration file and an initialization template. Ensure the paths are correct for your setup. ```bash wget https://raw.githubusercontent.com/casdoor/casdoor/master/conf/app.conf -O conf/app.conf ``` ```bash wget https://raw.githubusercontent.com/casdoor/casdoor/master/init_data.json.template -O conf/init_data.json ``` -------------------------------- ### CasdoorUserService Examples Source: https://github.com/casdoor/casdoor-website/blob/master/docs/integration/java/spring-boot.mdx Examples for managing Casdoor users, including retrieval, addition, update, and deletion. ```APIDOC ## CasdoorUserService ### getUser Retrieves a user by their username. ```java CasdoorUser casdoorUser = casdoorUserService.getUser("admin"); ``` ### getUserByEmail Retrieves a user by their email address. ```java CasdoorUser casdoorUser = casdoorUserService.getUserByEmail("admin@example.com"); ``` ### getUsers Retrieves all users. ```java CasdoorUser[] casdoorUsers = casdoorUserService.getUsers(); ``` ### getSortedUsers Retrieves a specified number of users sorted by a given field. ```java CasdoorUser[] casdoorUsers = casdoorUserService.getSortedUsers("created_time", 5); ``` ### getUserCount Gets the total count of users, optionally filtered by an organization ID. ```java int count = casdoorUserService.getUserCount("0"); ``` ### addUser Adds a new user to Casdoor. ```java CasdoorResponse response = casdoorUserService.addUser(user); ``` ### updateUser Updates an existing user in Casdoor. ```java CasdoorResponse response = casdoorUserService.updateUser(user); ``` ### deleteUser Deletes a user from Casdoor. ```java CasdoorResponse response = casdoorUserService.deleteUser(user); ``` ``` -------------------------------- ### Verify Casdoor CLI Installation Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/cli.md Checks if the Casdoor CLI is installed and accessible by running the help command. ```bash casdoor --help ``` -------------------------------- ### Webhook Receiver Example Source: https://context7.com/casdoor/casdoor-website/llms.txt A Node.js Express example demonstrating how to receive and process webhook events from Casdoor. ```APIDOC ## POST /webhook ### Description Receives real-time event notifications from Casdoor. Configure this endpoint in Casdoor settings. ### Method POST ### Endpoint /webhook ### Request Body - **event** (string) - The type of event that occurred (e.g., "login", "signup", "add-user"). - **timestamp** (integer) - The Unix timestamp when the event occurred. - **user** (object) - Information about the user associated with the event. - **id** (string) - User's unique identifier. - **username** (string) - User's username. - **email** (string) - User's email address. ### Response #### Success Response (200) - **received** (boolean) - Indicates if the webhook event was successfully received. ### Request Example (Node.js Express) ```javascript const express = require("express"); const app = express(); app.use(express.json()); app.post("/webhook", (req, res) => { const { event, timestamp, user } = req.body; switch (event) { case "login": console.log(`User ${user.username} signed in at ${new Date(timestamp * 1000)}`); break; case "signup": console.log(`New user registered: ${user.email}`); break; case "add-user": console.log(`Admin created user: ${user.username}`); break; default: console.log("Casdoor event:", event, req.body); } res.status(200).json({ received: true }); }); app.listen(3000, () => console.log("Webhook server on port 3000")); ``` ### Example Payload (login event) ```json { "event": "login", "timestamp": 1709452800, "user": { "id": "12345", "username": "johndoe", "email": "johndoe@example.com" } } ``` ``` -------------------------------- ### Run Casdoor Backend in Development Source: https://github.com/casdoor/casdoor-website/blob/master/docs/basic/server-installation.mdx Starts the Casdoor Go backend server. This command should be run from the project's root directory. ```bash go run main.go ``` -------------------------------- ### Create Configuration Directories Source: https://github.com/casdoor/casdoor-website/blob/master/docs/deployment/docker.mdx Use this command to create the necessary directories for Casdoor configuration and logs. ```bash mkdir -p conf logs ``` -------------------------------- ### Start Casdoor with Docker Compose Source: https://github.com/casdoor/casdoor-website/blob/master/docs/deployment/docker.mdx Command to start the Casdoor service in detached mode using Docker Compose. ```bash docker-compose up -d ``` -------------------------------- ### Install Python MCP SDK and JWT Libraries Source: https://github.com/casdoor/casdoor-website/blob/master/docs/mcp-auth/third-party-integration.md Installs the necessary Python packages for the MCP server and JWT validation. ```bash pip install mcp PyJWT cryptography requests ``` -------------------------------- ### Example Cursor MCP Prompts Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/mcp/connect-cursor.md Use these example prompts in Cursor's chat to interact with your Casdoor MCP server. These commands leverage Cursor's AI to execute actions on your Casdoor instance. ```text Using the Casdoor MCP server, list all applications ``` ```text Show me details about the application named 'my-app' from Casdoor ``` ```text Create a new Casdoor application called 'test-app' in organization 'my-org' ``` -------------------------------- ### Install Casdoor Vue SDK Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/vue-sdk.md Install the Casdoor Vue SDK using either NPM or Yarn package managers. ```shell # NPM npm install casdoor-vue-sdk ``` ```shell # Yarn yarn add casdoor-vue-sdk ``` -------------------------------- ### Console Output Example Source: https://github.com/casdoor/casdoor-website/blob/master/docs/how-to-connect/saml/overview.md This is the expected console output when running the SAML 2.0 Service Provider example. It provides the authentication URL and the Service Provider's Assertion Consumer Service (ACS) URL. ```text Visit this URL To Authenticate: http://localhost:7001/login/saml/authorize/admin/app-built-in?SAMLRequest=lFVbk6K8Fv0rFvNo2QR... Supply: SP ACS URL : http://localhost:6900/v1/_saml_callback ```