1.20.0 • Published 21 days ago

casdoor-nodejs-sdk v1.20.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
21 days ago

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)MustDescription
endpointYesCasdoor Server Url, such as http://localhost:8000
clientIdYesClient ID for the Casdoor application
clientSecretYesClient secret for the Casdoor application
certificateYesx509 certificate content of Application.cert
orgNameYesThe name for the Casdoor organization
appNameNoThe 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)
1.20.0

21 days ago

1.19.0

1 month ago

1.18.0

2 months ago

1.17.0

3 months ago

1.16.0

3 months ago

1.15.0

3 months ago

1.14.0

3 months ago

1.13.0

3 months ago

1.12.0

3 months ago

1.11.0

3 months ago

1.10.1

4 months ago

1.10.0

4 months ago

1.9.0

6 months ago

1.8.0

6 months ago

1.7.1

6 months ago

1.7.0

8 months ago

1.6.0

8 months ago

1.5.1

8 months ago

1.5.0

8 months ago

1.4.0

9 months ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.1

2 years ago