New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

casbin-dynamodb-adapter-v3

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

casbin-dynamodb-adapter-v3

Casbin DynamoDB Adapter V3

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

casbin-dynamodb-adapter

DynamoDB adapter for Casbin https://github.com/casbin/node-casbin

Based on casbin-couchbase-adapter.

Installation

npm install casbin-dynamodb-adapter

Changes in version 0.4.x

  • Change in CasbinDynamoDBAdapter class import
  • New CasbinDynamoDBFilteredAdapter class based on DefaultFilteredAdapter class

Simple Example

const Casbin = require('casbin');
const { CasbinDynamoDBAdapter } = require('casbin-dynamodb-adapter');
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
const { DynamoDBDocumentClient } = require('@aws-sdk/lib-dynamodb');

const client = new DynamoDBClient({ region: 'your-region' });
const docClient = DynamoDBDocumentClient.from(client);

(async () => {
  try {
    const opts = {
      tableName: 'Test_Casbin',
      hashKey: 'id'
    };
    const adapter = new CasbinDynamoDBAdapter(docClient, opts);
    const enforcer = await Casbin.newEnforcer('model.conf', adapter);

    // Load policies from the database.
    await enforcer.loadPolicy();

    // Add a policy.
    await enforcer.addPolicy('alice', 'data1', 'read');

    // Check permissions.
    const isMatched = await enforcer.enforce('alice', 'data1', 'read');
    console.log(isMatched); // true

    // Remove a policy.
    await enforcer.removePolicy('alice', 'data1', 'read');

    // Save policies back to the database.
    await enforcer.savePolicy();

    process.exit();
  } catch (e) {
    console.error(e);
  }
})();

FAQs

Package last updated on 03 Oct 2024

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