🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

casdoor-nodejs-sdk

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casdoor-nodejs-sdk

Node.js client SDK for Casdoor

1.28.0
latest
Source
npm
Version published
Weekly downloads
992
19.52%
Maintainers
3
Weekly downloads
 
Created
Source

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:

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'
import type { AxiosRequestConfig } from 'axios';
import https from 'node:https';

// Optional param for providing a self-signed CA with requests.
const axiosConfig: AxiosRequestConfig = {
  httpsAgent: new https.Agent({ ca: ... })
}

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

const sdk = new SDK(authCfg)
// or
const sdk = new SDK(authCfg, axiosConfig)

// 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)

Keywords

auth

FAQs

Package last updated on 02 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts