{"id":21158164,"url":"https://github.com/node-casbin/egg-authz","last_synced_at":"2025-07-09T12:33:47.196Z","repository":{"id":45411276,"uuid":"144382826","full_name":"node-casbin/egg-authz","owner":"node-casbin","description":"egg-authz is an authorization middleware for Egg.js based on Casbin","archived":false,"fork":false,"pushed_at":"2023-08-06T14:06:12.000Z","size":139,"stargazers_count":51,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-15T23:29:57.736Z","etag":null,"topics":["authorization","casbin","egg","egg-plugin","eggjs","koa2","middleware"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/node-casbin","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/node-casbin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-11T12:18:20.000Z","updated_at":"2024-09-08T01:27:38.000Z","dependencies_parsed_at":"2024-11-15T23:29:17.123Z","dependency_job_id":"15008ad8-d647-4bfe-b936-c91b507e1656","html_url":"https://github.com/node-casbin/egg-authz","commit_stats":{"total_commits":20,"total_committers":3,"mean_commits":6.666666666666667,"dds":0.4,"last_synced_commit":"a515f01d70a202bf962fd65e4f66ac7b507bb835"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-casbin%2Fegg-authz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-casbin%2Fegg-authz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-casbin%2Fegg-authz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/node-casbin%2Fegg-authz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/node-casbin","download_url":"https://codeload.github.com/node-casbin/egg-authz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225550870,"owners_count":17487192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorization","casbin","egg","egg-plugin","eggjs","koa2","middleware"],"created_at":"2024-11-20T12:16:52.090Z","updated_at":"2024-11-20T12:16:52.694Z","avatar_url":"https://github.com/node-casbin.png","language":"JavaScript","readme":"Egg-Authz \n====\n[![NPM version][npm-image]][npm-url]\n[![NPM download][download-image]][download-url]\n[![codebeat badge](https://codebeat.co/badges/9defa882-898c-4dcb-91a6-7e8f061ccaac)](https://codebeat.co/projects/github-com-node-casbin-egg-authz-master)\n[![Build Status](https://travis-ci.org/node-casbin/egg-authz.svg?branch=master)](https://travis-ci.org/node-casbin/egg-authz)\n[![Coverage Status](https://coveralls.io/repos/github/node-casbin/egg-authz/badge.svg?branch=master)](https://coveralls.io/github/node-casbin/egg-authz?branch=master)\n[![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord\u0026label=discord\u0026color=5865F2)](https://discord.gg/S5UjpzGZjN)\n\n[npm-image]: https://img.shields.io/npm/v/egg-authz.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/egg-authz\n[download-image]: https://img.shields.io/npm/dm/egg-authz.svg?style=flat-square\n[download-url]: https://npmjs.org/package/egg-authz\n\nEgg-Authz is an authorization middleware for [Egg](https://eggjs.org/), it's based on ``Node-Casbin``: [https://github.com/casbin/node-casbin](https://github.com/casbin/node-casbin).\n\n## 1. Installation\n### use casbin v2.x\n```shell\nnpm install casbin@2 egg-authz@2 --save\n```\n\n### use casbin v3.x\n```shell\nnpm install casbin@3 egg-authz@3 --save\n```\n\n## 2. Create a file in middleware directory to import the module.\n\n```js\n// app/middleware/authz.js\nmodule.exports = require('egg-authz')\n```\n\n```js\n// config/config.default.js\nconst casbin = require('casbin')\nmodule.exports = {\n  middleware: [ 'authz' ],\n  authz: {\n    enable: true,\n    newEnforcer: async() =\u003e {\n      // load the casbin model and policy from files, database is also supported.\n      const enforcer = await casbin.newEnforcer('authz_model.conf', 'authz_policy.csv')\n      return enforcer\n    }\n  }\n}\n```\n\n## 3. Enable the middleware in your config files.\n\n## How to control the access\n\nThe 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:\n\n1. ``subject``: the logged-on user name\n2. ``object``: the URL path for the web resource like \"dataset1/item1\"\n3. ``action``: HTTP method like GET, POST, PUT, DELETE, or the high-level actions you defined like \"read-file\", \"write-blog\"\n\n\nFor how to write authorization policy and other details, please refer to [the Casbin's documentation](https://casbin.org).\n\n## Getting Help\n\n- [Node-Casbin](https://github.com/casbin/node-casbin)\n\n## License\n\nThis project is licensed under the [Apache 2.0 license](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-casbin%2Fegg-authz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnode-casbin%2Fegg-authz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnode-casbin%2Fegg-authz/lists"}