All Projects → node-casbin → Egg Authz

node-casbin / Egg Authz

Licence: apache-2.0
egg-authz is an authorization middleware for Egg.js based on Casbin

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Egg Authz

Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (+276%)
Mutual labels:  koa2, egg, eggjs, egg-plugin
Egg Oauth2 Server
🌟 OAuth2 server plugin for egg.js based on node-oauth2-server
Stars: ✭ 174 (+248%)
Mutual labels:  egg, eggjs, egg-plugin
Egg 24time
A Twitter-like news and social server for Egg. 微信小程序社区全栈解决方案
Stars: ✭ 493 (+886%)
Mutual labels:  egg, eggjs, egg-plugin
Egg Graphql
Stars: ✭ 345 (+590%)
Mutual labels:  egg, eggjs, egg-plugin
Egg Router Plus
The missing router feature for eggjs
Stars: ✭ 117 (+134%)
Mutual labels:  egg, eggjs, egg-plugin
egg-sentry
Sentry Plugin For Egg.js
Stars: ✭ 18 (-64%)
Mutual labels:  egg, egg-plugin, eggjs
Laravel Authz
An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.
Stars: ✭ 136 (+172%)
Mutual labels:  middleware, authorization, casbin
Eggjs Note
《Egg.js 深入浅出学习笔记》(暂时停更)
Stars: ✭ 502 (+904%)
Mutual labels:  koa2, egg, eggjs
egg-rbac
Role Based Access Control for eggjs
Stars: ✭ 32 (-36%)
Mutual labels:  egg, egg-plugin, eggjs
Caddy Authz
Caddy-authz is a middleware for Caddy that blocks or allows requests based on access control policies.
Stars: ✭ 221 (+342%)
Mutual labels:  middleware, authorization, casbin
Negroni Authz
negroni-authz is an authorization middleware for Negroni
Stars: ✭ 152 (+204%)
Mutual labels:  middleware, authorization, casbin
Egg
🥚 Born to build better enterprise frameworks and apps with Node.js & Koa
Stars: ✭ 17,616 (+35132%)
Mutual labels:  koa2, egg, eggjs
egg-parameters
Merge all parameters (ctx.params, ctx.request.query, ctx.request.body) into ctx.params like Rails application.
Stars: ✭ 24 (-52%)
Mutual labels:  egg, egg-plugin, eggjs
Egg Cancan
cancancan like authorization plugin for Egg.js
Stars: ✭ 47 (-6%)
Mutual labels:  egg, eggjs, egg-plugin
Egg Mongoose
Stars: ✭ 386 (+672%)
Mutual labels:  egg, egg-plugin
Casbin Rs
An authorization library that supports access control models like ACL, RBAC, ABAC in Rust.
Stars: ✭ 375 (+650%)
Mutual labels:  authorization, casbin
Koa Webpack
Development and Hot Reload Middleware for Koa2
Stars: ✭ 429 (+758%)
Mutual labels:  middleware, koa2
Gorm Adapter
Gorm adapter for Casbin
Stars: ✭ 373 (+646%)
Mutual labels:  authorization, casbin
Egg Restfulapi
🏅 基于Egg.js 2.0 & {mongoose,jwt}RESTful API 模板,用于快速集成开发RESTful前后端分离的服务端。
Stars: ✭ 524 (+948%)
Mutual labels:  egg, egg-plugin
Egg Sequelize
Sequelize for Egg.js
Stars: ✭ 540 (+980%)
Mutual labels:  egg, egg-plugin

Egg-Authz

NPM version NPM download codebeat badge Build Status Coverage Status Gitter

Egg-Authz is an authorization middleware for Egg, it's based on Node-Casbin: https://github.com/casbin/node-casbin.

1. Installation

use casbin v2.x

npm install [email protected] [email protected] --save

use casbin v3.x

npm install [email protected] [email protected] --save

2. Create a file in middleware directory to import the module.

// app/middleware/authz.js
module.exports = require('egg-authz')
// config/config.default.js
const casbin = require('casbin')
module.exports = {
  middleware: [ 'authz' ],
  authz: {
    enable: true,
    newEnforcer: async() => {
      // load the casbin model and policy from files, database is also supported.
      const enforcer = await casbin.newEnforcer('authz_model.conf', 'authz_policy.csv')
      return enforcer
    }
  }
}

3. Enable the middleware in your config files.

How to control the access

The authorization determines a request based on {subject, object, action}, which means what subject can perform what action on what object. In this plugin, the meanings are:

  1. subject: the logged-on user name
  2. object: the URL path for the web resource like "dataset1/item1"
  3. action: HTTP method like GET, POST, PUT, DELETE, or the high-level actions you defined like "read-file", "write-blog"

For how to write authorization policy and other details, please refer to the Casbin's documentation.

Getting Help

License

This project is licensed under the Apache 2.0 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].