casdoor-nodejs-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.20.0 • Public • Published

casdoor-nodejs-sdk

GitHub Actions codebeat badge NPM version NPM download 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)

Package Sidebar

Install

npm i casdoor-nodejs-sdk

Weekly Downloads

269

Version

1.20.0

License

Apache-2.0

Unpacked Size

261 kB

Total Files

123

Last publish

Collaborators

  • beacontownfc
  • fabian4
  • hsluoyz