Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

casbinjs-server-tool

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casbinjs-server-tool

This package provides the facilities to generate permission tokens on node-casbin service.

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Casbin.js Server Utilities for Node-Casbin

If you are using Casbin.js at your frontend and Node-Casbin as your backend Casbin service, you can install this package at your backend. This package provides a wrapper for generating the user profile passed to Casbin.js at the frontend.

Installation

npm install --save casbinjs-server-tool
# or
yarn add casbinjs-server-tool

Example

import CasbinServerTool from 'casbinjs-server-tool'

// In your Restful API
private async setRouter(): Promise<void> {
    this.app.get('/api/casbin', async (req: express.Request, res: express.Response) => {
        // Get the user identity from URL.
        const user = String(req.query["casbin_user"]);

        // Initialize the casbin server tool with casbin enforcer
        const casbinSvrTool = new CasbinServerTool(enforcer);
        
        // Generate the user's profile
        const profile = casbinSvrTool.genJsonProfile(user);

        // Return the response to the client-side.
        res.status(200).json({
            message: 'ok',
            data: profile
        })
    })
}

Keywords

FAQs

Package last updated on 02 Nov 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc