GithubHelp home page GithubHelp logo

radiorz / casdoor-nodejs-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from casdoor/casdoor-nodejs-sdk

0.0 0.0 0.0 919 KB

Node.js client SDK for Casdoor, see example at: https://github.com/casdoor/casdoor-nodejs-react-example

Home Page: https://github.com/casdoor/casdoor

License: Apache License 2.0

Shell 0.05% JavaScript 0.35% TypeScript 99.60%

casdoor-nodejs-sdk's Introduction

casdoor-nodejs-sdk

NPM version NPM download codebeat badge GitHub Actions Coverage Status Release Discord

This is Casdoor's SDK for NodeJS will allow you to easily connect your application to the Casdoor authentication system without having to implement it from scratch.

Casdoor SDK is very simple to use. We will show you the steps below.

Examples

The following examples use Node.js Express as backend, but have different frontend frameworks. Choose the appropriate example based on your tech stack:

  1. React frontend: https://github.com/casdoor/casdoor-nodejs-react-example
  2. Angular frontend: https://github.com/casdoor/casdoor-nodejs-angular-example

Installation

# NPM
npm i casdoor-nodejs-sdk

# Yarn
yarn add casdoor-nodejs-sdk

Step1. Init SDK

Initialization requires 5 parameters, which are all string type:

Name (in order) Must Description
endpoint Yes Casdoor Server Url, such as http://localhost:8000
clientId Yes Client ID for the Casdoor application
clientSecret Yes Client secret for the Casdoor application
certificate Yes x509 certificate content of Application.cert
orgName Yes The name for the Casdoor organization
appName No The name for the Casdoor application
import { SDK, Config } from 'casdoor-nodejs-sdk'

const authCfg: Config = {
  endpoint: '',
  clientId: '',
  clientSecret: '',
  certificate: '',
  orgName: '',
}

const sdk = new SDK(authCfg)

// call sdk to handle

Step2. Get service and use

// user
const { data: users } = await sdk.getUsers()

// auth
const token = await sdk.getAuthToken('<callback-code>')
const user = sdk.parseJwtToken(token)

casdoor-nodejs-sdk's People

Contributors

hsluoyz avatar fabian4 avatar huyonger avatar dshilovprpl avatar zhongjixiuxing avatar radiorz avatar nomeguy avatar qianxi0410 avatar mogu4iy avatar cyanxiao avatar kusaljr avatar gtn1024 avatar selflocking avatar nodece avatar palp1tate 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.