casdoor-js-sdk

Javascript client SDK for Casdoor

Usage no npm install needed!

<script type="module">
  import casdoorJsSdk from 'https://cdn.skypack.dev/casdoor-js-sdk';
</script>

README

casdoor-js-sdk

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

This is Casdoor's SDK for js 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.

Noted that this sdk has been applied to casnode, if you still don’t know how to use it after reading README.md, you can refer to it

Installation

# NPM
npm i casdoor-js-sdk

# Yarn
yarn add casdoor-js-sdk

Init SDK

Initialization requires 5 parameters, which are all string type:

Name (in order) Must Description
serverUrl Yes your Casdoor server URL
clientId Yes the Client ID of your Casdoor application
appName Yes the name of your Casdoor application
organizationName Yes the name of the Casdoor organization connected with your Casdoor application
redirectPath No the path of the redirect URL for your Casdoor application, will be /callback if not provided
import {SDK, SdkConfig} from 'casdoor-nodejs-sdk'

const sdkConfig: SdkConfig = {
    serverUrl: "https://door.casbin.com",
    clientId: "014ae4bd048734ca2dea",
    appName: "app-casnode",
    organizationName: "casbin",
    redirectPath: "/callback",
}
const sdk = new SDK(sdkConfig)
// call sdk to handle