ランキングに戻る

apache/casbin-node-casbin

TypeScriptcasbin.org

An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser

casbinnodejsnodejsjavascriptaccess-controlauthorizationrbacabacaclauthauthz
スター成長
スター
2.9k
フォーク
230
週間成長
Issue
4
1k2k
2018年7月2021年3月2023年11月2026年7月
成果物npmnpm install casbin-node-casbin
README

Node-Casbin

GitHub Actions Coverage Status Release NPM version NPM download install size Discord

News: still worry about how to write the correct node-casbin policy? Casbin online editor is coming to help!

casbin Logo

node-casbin is a powerful and efficient open-source access control library for Node.JS projects. It provides support for enforcing authorization based on various access control models.

All the languages supported by Casbin:

golang java nodejs php
Casbin jCasbin node-Casbin PHP-Casbin
production-ready production-ready production-ready production-ready
python dotnet c++ rust
PyCasbin Casbin.NET Casbin-CPP Casbin-RS
production-ready production-ready beta-test production-ready

Documentation

https://casbin.apache.org/docs/overview

Installation

# NPM
npm install casbin --save

# Yarn
yarn add casbin

Get started

New a node-casbin enforcer with a model file and a policy file, see Model section for details:

// For Node.js:
const { newEnforcer } = require('casbin');
// For browser:
// import { newEnforcer } from 'casbin';

const enforcer = await newEnforcer('basic_model.conf', 'basic_policy.csv');

Note: you can also initialize an enforcer with policy in DB instead of file, see Persistence section for details.

Add an enforcement hook into your code right before the access happens:

const sub = 'alice'; // the user that wants to access a resource.
const obj = 'data1'; // the resource that is going to be accessed.
const act = 'read'; // the operation that the user performs on the resource.

// Async:
const res = await enforcer.enforce(sub, obj, act);
// Sync:
// const res = enforcer.enforceSync(sub, obj, act);

if (res) {
  // permit alice to read data1
} else {
  // deny the request, show an error
}

Besides the static policy file, node-casbin also provides API for permission management at run-time. For example, You can get all the roles assigned to a user as below:

const roles = await enforcer.getRolesForUser('alice');

See Policy management APIs for more usage.

Policy management

Casbin provides two sets of APIs to manage permissions:

  • Management API: the primitive API that provides full support for Casbin policy management.
  • RBAC API: a more friendly API for RBAC. This API is a subset of Management API. The RBAC users could use this API to simplify the code.

Official Model

https://casbin.apache.org/docs/supported-models

Policy persistence

https://casbin.apache.org/docs/adapters

Policy consistence between multiple nodes

https://casbin.apache.org/docs/watchers

Role manager

https://casbin.apache.org/docs/role-managers

Contributors

This project exists thanks to all the people who contribute.

Star History

Star History Chart

License

This project is licensed under the Apache 2.0 license.

Contact

If you have any issues or feature requests, please contact us. PR is welcomed.

関連リポジトリ
flipped-aurora/gin-vue-admin

🚀Vite+Vue3+Gin拥有AI辅助的基础开发平台,企业级业务AI+开发解决方案,内置mcp辅助服务,内置skills管理,支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下载、代码生成器、表单生成器和可配置的导入导出等开发必备功能。

GoGo ModulesOthergin-vue-admingin
demo.gin-vue-admin.com
24.9k7.1k
apache/casbin

Apache Casbin: an authorization library that supports access control models like ACL, RBAC, ABAC.

GoGo ModulesApache License 2.0casbinaccess-control
casbin.apache.org
20.3k1.8k
casbin/casbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Golang: https://discord.gg/S5UjpzGZjN

GoGo ModulesApache License 2.0casbinaccess-control
casbin.org
18.3k1.7k
go-admin-team/go-admin

基于Gin + Vue + Element UI & Arco Design & Ant Design 的前后端分离权限管理系统脚手架(包含了:多租户的支持,基础用户管理功能,jwt鉴权,代码生成器,RBAC资源控制,表单构建,定时任务等)3分钟构建自己的中后台项目;项目文档》:https://www.go-admin.pro V2 Demo: https://vue2.go-admin.dev V3 Demo: https://vue3.go-admin.dev Antd PRO:https://antd.go-admin.pro

GoGo ModulesMIT Licensegincasbin
go-admin.pro
12.7k2.6k
LyricTian/gin-admin

A lightweight, flexible, elegant and full-featured RBAC scaffolding based on GIN + GORM 2.0 + Casbin 2.0 + Wire DI.基于 Golang + Gin + GORM 2.0 + Casbin 2.0 + Wire DI 的轻量级、灵活、优雅且功能齐全的 RBAC 脚手架。

GoGo ModulesApache License 2.0gin-casbingo-rbac
demo.ginadmin.top
2.9k546
casbin/node-casbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser

TypeScriptnpmApache License 2.0casbinnodejs
casbin.org
2.7k218
apache/casbin-jcasbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Java

JavaMavenApache License 2.0casbinjava
casbin.org
2.6k491
casbin/jcasbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Java

JavaMavenApache License 2.0casbinjava
casbin.org
2.5k471
suyuan32/simple-admin-core

Simple Admin是一个基于Go Zero开发面向小型到大型项目的分布式微服务后端管理系统脚手架,提供丰富的后台管理功能,支持k8s快速部署,助力快速开发高并发微服务集群,适合学习和商用。Simple Admin is a powerful microservice framework for large management system. It is based on go-zero and supports several advanced features. It can help you to develop a microservice back-end management system in a short time.

GoGo ModulesApache License 2.0gogolang
doc.ryansu.tech/zh
2k336
opsre/go-ldap-admin

🌉 基于Go+Vue实现的openLDAP后台管理项目

GoGo ModulesApache License 2.0gogolang
ldapdoc.eryajf.net
2k327
apache/casbin-pycasbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Python

PythonPyPIApache License 2.0casbinpython
casbin.org
1.7k215
casbin/pycasbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Python

PythonPyPIApache License 2.0casbinpython
casbin.org
1.5k196