Socket
Book a DemoInstallSign in
Socket

casbin-couchdb-adapter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casbin-couchdb-adapter

CouchDB adapter for Casbin

0.1.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

CouchDB Adapter

NPM version NPM download ci Coverage Status Gitter

CouchDB policy storage, implemented as an adapter for node-casbin.

Installation

NPM:

npm install casbin-couchdb-adapter --save

Yarn:

yarn add casbin-couchdb-adapter

Simple Example

import { newEnforcer } from 'casbin';
import { CouchdbAdapter } from 'casbin-couchdb-adapter';
import { join } from 'path';

async function myFunction() {
    // Initialize a CouchdbAdapter adapter and use it in a Node-Casbin enforcer:
    const adapter = await CouchdbAdapter.newAdapter("http://admin:password@localhost:5984");

    // The location of your Casbin model configuration file
    const model = join(__dirname, 'casbin_conf/model.conf');

    const enforcer = await newEnforcer(model, adapter);

    // Check the permission.
    enforcer.enforce('alice', 'data1', 'read');

    // Modify the policy.
    // await enforcer.addPolicy(...);
    // await enforcer.removePolicy(...);

    // Save the policy back to DB.
    await enforcer.savePolicy();
}

Configuration

You need to create a database named "casbin" and a document like this:

{
  "_id": "policies",
  "value": []
}

CouchdbAdapter.newAdapter() takes the following parameters as an object to establish the connection with couchdb-server

databaseUrl: string = "http://{admin}:{password}@{ip}:{port}"

Getting Help

  • Node-Casbin

License

This project is under Apache 2.0 License. See the LICENSE file for the full license text.

Keywords

casbin

FAQs

Package last updated on 27 Mar 2023

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.