{"id":20215678,"url":"https://github.com/casdoor/casdoor-nodejs-react-example","last_synced_at":"2025-04-10T14:40:48.923Z","repository":{"id":104354017,"uuid":"576173332","full_name":"casdoor/casdoor-nodejs-react-example","owner":"casdoor","description":"Node.js Express + React example app for Casdoor based on casdoor-nodejs-sdk and casdoor-js-sdk","archived":false,"fork":false,"pushed_at":"2023-11-12T18:27:38.000Z","size":4893,"stargazers_count":7,"open_issues_count":0,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T13:11:12.249Z","etag":null,"topics":["casdoor","express","iam","js","node","nodejs","oauth","oidc","react","sso"],"latest_commit_sha":null,"homepage":"https://github.com/casdoor/casdoor-nodejs-sdk","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casdoor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-12-09T07:13:29.000Z","updated_at":"2024-10-09T04:37:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"b1aba8ce-6887-4d33-a1c3-6cfe206e52c8","html_url":"https://github.com/casdoor/casdoor-nodejs-react-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-nodejs-react-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-nodejs-react-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-nodejs-react-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casdoor%2Fcasdoor-nodejs-react-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casdoor","download_url":"https://codeload.github.com/casdoor/casdoor-nodejs-react-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248233989,"owners_count":21069493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["casdoor","express","iam","js","node","nodejs","oauth","oidc","react","sso"],"created_at":"2024-11-14T06:23:58.667Z","updated_at":"2025-04-10T14:40:48.903Z","avatar_url":"https://github.com/casdoor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\" style=\"border-bottom: none;\"\u003eCasdoor NodeJS React Example\u003c/h1\u003e\n\n## Demo\n\n![react-express-illustration.gif](public/demo.gif)\n\n## Architecture\n\nThis project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) and [Express](https://expressjs.com/).\n\nThe example includes two parts:\n\n| Name     | SDK                | Language             | Source code                                                                 |\n|----------|--------------------|----------------------|-----------------------------------------------------------------------------|\n| Frontend | casdoor-js-sdk     | Javascript + React   | https://github.com/casdoor/casdoor-nodejs-react-example/tree/master/src     |\n| Backend  | casdoor-nodejs-sdk | JavaScript + Express | https://github.com/casdoor/casdoor-nodejs-react-example/tree/master/backend |\n\n## Installation\n\nExample uses Casdoor to manage members. So you need to create an organization and an application for the example in a Casdoor instance.\n\n### Necessary Configurations\n\n#### Get the Code\n\n```shell\ngit clone https://github.com/casdoor/casdoor\ngit clone https://github.com/casdoor/casdoor-nodejs-react-example\n```\n\n#### Run Example\n\n1. Run Casdoor\n2. Configure\n   - Backend\n   - Frontend\n\n#### Backend Config\n\nInitialization requires 6 (or 5) parameters, which are all string type. Please refer to the official doc on [backend sdk configuration](https://casdoor.org/docs/how-to-connect/sdk#1-backend-sdk-configuration) for the latest change.\n\n| Parameter        | Must | Description                                                                    |\n|------------------|------|--------------------------------------------------------------------------------|\n| endpoint         | Yes  | Casdoor Server URL, like `https://door.casdoor.com` or `http://localhost:8000` |\n| clientId         | Yes  | Client ID for the Casdoor application                                          |\n| clientSecret     | Yes  | Client secret for the Casdoor application                                      |\n| jwtPublicKey     | Yes  | The public key for the Casdoor application's cert                              |\n| organizationName | Yes  | The name for the Casdoor organization                                          |\n| applicationName  | No   | The name for the Casdoor application                                           |\n\n```js\n// in ./backend/server.js\nconst authCfg = {\n  endpoint: 'https://door.casdoor.com',\n  clientId: '014ae4bd048734ca2dea',\n  clientSecret: 'f26a4115725867b7bb7b668c81e1f8f7fae1544d',\n  certificate: cert,\n  orgName: 'casbin',\n  appName: 'app-casnode',\n}\n```\n\n#### Frontend Config\n\nThe first 4 parameters should use the same value as the Casdoor backend SDK. The last parameter redirectPath is relative path for the redirected URL, returned from Casdoor's login page. Please refer to the official doc on [frontend sdk configuration](https://casdoor.org/docs/how-to-connect/sdk#2-frontend-configuration) for the latest change.\n\n```js\n// in ./src/Setting.js\nconst config = {\n  serverUrl: \"https://door.casdoor.com\",\n  clientId: \"014ae4bd048734ca2dea\",\n  organizationName: \"casbin\",\n  appName: \"app-casnode\",\n  redirectPath: \"/callback\",\n};\n```\n\nAfter setting configurations up, install all dependencies by running `yarn install`. While Casdoor is operating, run the following scripts.\n\n### Available Scripts\n\nIn the project directory, you can run:\n\n```shell\nyarn install\n```\n\nInstalls all necessary dependencies.\n\n```shell\nnode backend/server.js\n```\n\nRuns the backend powered by Express at [http://localhost:8080](http://localhost:8080).\n\n```shell\nyarn start\n```\n\nRuns the app in the development mode.\n\nNote that the port running frontend is set in `package.json`:\n\n`\"start\": \"PORT=9000 react-scripts start\"`\n\nOpen [http://localhost:9000](http://localhost:9000) to view it in your browser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor%2Fcasdoor-nodejs-react-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasdoor%2Fcasdoor-nodejs-react-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasdoor%2Fcasdoor-nodejs-react-example/lists"}