Giter Site home page Giter Site logo

casdoor / casdoor-nodejs-angular-example Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 2.0 650 KB

Node.js Express + Angular example app for Casdoor based on casdoor-nodejs-sdk and casdoor-js-sdk

Home Page: https://github.com/casdoor/casdoor-angular-sdk

License: Apache License 2.0

JavaScript 31.69% TypeScript 58.91% HTML 8.71% CSS 0.69%
angular casdoor example js express iam javascript node nodejs oauth

casdoor-nodejs-angular-example's Introduction

Casdoor nodejs-angular Example

Demo

angular-illustration.gif

Architecture

The example includes two parts:

Name SDK Framework Source code
Frontend casdoor-angular-sdk Angular https://github.com/casdoor/casdoor-nodejs-angular-example/tree/master/web
Backend casdoor-nodejs-sdk Express.js https://github.com/casdoor/casdoor-nodejs-angular-example/tree/master/backend

Installation

Example uses Casdoor to manage members. So you need to create an organization and an application for the example in a Casdoor instance.

Necessary Configurations

Get the Code

git clone https://github.com/casdoor/casdoor
git clone https://github.com/casdoor/casdoor-nodejs-angular-example

Run Example

  1. Run Casdoor
  2. Configure
  • Backend
  • Frontend

Backend Config

Initialization requires 6 (or 5) parameters, which are all string type. Please refer to the official doc on backend sdk configuration for the latest change.

Parameter Must Description
endpoint Yes Casdoor Server URL, like https://door.casdoor.com or http://localhost:8000
clientId Yes Client ID for the Casdoor application
clientSecret Yes Client secret for the Casdoor application
jwtPublicKey Yes The public key for the Casdoor application's cert
organizationName Yes The name for the Casdoor organization
applicationName No The name for the Casdoor application
// in ./backend/server.js
const authCfg = {
  endpoint: 'https://door.casdoor.com',
  clientId: '014ae4bd048734ca2dea',
  clientSecret: 'f26a4115725867b7bb7b668c81e1f8f7fae1544d',
  certificate: cert,
  orgName: 'casbin',
  appName: 'app-casnode',
}

Frontend

The 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 for the latest change.

// in ./src/Setting.js
const config = {
  serverUrl: "https://door.casdoor.com",
  clientId: "014ae4bd048734ca2dea",
  organizationName: "casbin",
  appName: "app-casnode",
  redirectPath: "/callback",
};

Fetch dependencies:

cd web
npm install

Run frontend at: http://localhost:9000

ng serve --port 9000

Backend

Fetch dependencies:

yarn install

Run backend at: http://localhost:8080

node server.js

casdoor-nodejs-angular-example's People

Contributors

hsluoyz avatar rantao123 avatar selflocking avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.