{"id":49290456,"url":"https://github.com/apache/casbin-express-authz","last_synced_at":"2026-04-26T00:01:34.589Z","repository":{"id":46937395,"uuid":"144398704","full_name":"apache/casbin-express-authz","owner":"apache","description":"Casbin authorization middleware for Express.js: https://github.com/expressjs/express","archived":false,"fork":false,"pushed_at":"2026-04-08T05:37:54.000Z","size":729,"stargazers_count":61,"open_issues_count":4,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-04-25T00:17:03.266Z","etag":null,"topics":["authorization","casbin","express","expressjs","middleware","node-casbin"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/node-casbin","language":"TypeScript","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/apache.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-11T15:57:52.000Z","updated_at":"2026-03-10T13:01:22.000Z","dependencies_parsed_at":"2024-06-21T14:18:24.488Z","dependency_job_id":"545cc4ef-935c-481d-a7be-dcf04bdd6ac2","html_url":"https://github.com/apache/casbin-express-authz","commit_stats":{"total_commits":48,"total_committers":9,"mean_commits":5.333333333333333,"dds":0.6041666666666667,"last_synced_commit":"ac649cd5901417a22a9c802f84659df580a4c253"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/apache/casbin-express-authz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-express-authz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-express-authz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-express-authz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-express-authz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/casbin-express-authz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fcasbin-express-authz/sbom","scorecard":{"id":691807,"data":{"date":"2025-08-11","repo":{"name":"github.com/node-casbin/express-authz","commit":"c3ac90149a31c9da7695a446c46e6427c89d3b3e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":4,"reason":"Found 6/15 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/node-casbin/express-authz/main.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/node-casbin/express-authz/main.yml/master?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 21 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"33 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-h452-7996-h45h","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T02:29:04.475Z","repository_id":46937395,"created_at":"2025-08-22T02:29:04.475Z","updated_at":"2025-08-22T02:29:04.475Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32280981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","express","expressjs","middleware","node-casbin"],"created_at":"2026-04-26T00:01:33.759Z","updated_at":"2026-04-26T00:01:34.580Z","avatar_url":"https://github.com/apache.png","language":"TypeScript","readme":"# Express-Authz\n\n[![NPM version][npm-image]][npm-url]\n[![NPM download][download-image]][download-url]\n[![GitHub Actions](https://github.com/node-casbin/express-authz/workflows/main/badge.svg)](https://github.com/node-casbin/express-authz/actions)\n[![Coverage Status](https://coveralls.io/repos/github/node-casbin/express-authz/badge.svg?branch=master)](https://coveralls.io/github/node-casbin/express-authz?branch=master)\n[![Release](https://img.shields.io/github/release/node-casbin/express-authz.svg)](https://github.com/node-casbin/express-authz/releases/latest)\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/casbin-express-authz.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/casbin-express-authz\n[download-image]: https://img.shields.io/npm/dm/casbin-express-authz.svg?style=flat-square\n[download-url]: https://npmjs.org/package/casbin-express-authz\n\nExpress-Authz is an authorization middleware for [Express](https://github.com/expressjs/express), it's based on `Node-Casbin`: [https://github.com/casbin/node-casbin](https://github.com/casbin/node-casbin).\n\n## Installation\n\n### use casbin v2.x\n\n```shell\nnpm install casbin@2 casbin-express-authz@1 --save\n```\n\n### use casbin v3.x\n\n```shell\nnpm install casbin@3 casbin-express-authz@2 --save\n```\n\nor you can simply use,\n\n```shell\nnpm install express casbin casbin-express-authz --save\n```\n\n## Usage with Basic HTTP Authentication\n\nBy default casbin-authz supports HTTP Basic Authentication of the form `Authentication: Basic {Base64Encoded(username:password)}`\n\n## Usage with Other HTTP Authentication\n\nTo use other HTTP Authentication like `Bearer/Digest` you can use a custom middleware to define the `res.locals.username` variable and casbin-authz will automatically pick up the value from the variable.\n\n```js\nconst { newEnforcer } = require('casbin');\nconst express = require('express');\nconst { authz } = require('casbin-express-authz');\n\nconst app = express();\nconst enforcer = await newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv');\n\n// set userinfo\napp.use((req, res, next) =\u003e {\n  res.locals.username = getUsernameFromToken(); // Your custom function for retrieving username\n  next();\n});\n\n// use authz middleware\napp.use(authz({ newEnforcer: enforcer }));\n\n// response\napp.use((req, res, next) =\u003e {\n  res.status(200).json({ status: 'OK' });\n});\n\napp.listen(3000);\n```\n\n### Usage with customized authorizer\n\nThis package provides `BasicAuthorizer`, it uses HTTP Basic Authentication as the authentication method. If you want to use another authentication method like OAuth, you needs to implement Authorizer as below:\n\n```typescript\nimport { Enforcer, newEnforcer } from 'casbin';\nimport { authz, Authorizer } from 'casbin-express-authz';\nimport * as express from 'express';\n\nconst app = express();\n\nclass MyAuthorizer implements Authorizer {\n  private e: Enforcer;\n\n  constructor(e: Enforcer) {\n    this.e = e;\n  }\n\n  checkPermission(): Promise\u003cboolean\u003e {\n    // do something\n    return true;\n  }\n}\nconst e = await newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv');\n\napp.use(\n  authz({\n    newEnforcer: e,\n    authorizer: new MyAuthorizer(e),\n  })\n);\n\napp.listen(3000);\n```\n\n### Usage with customized authorizer class\n\nWhen the authorizer needs the request and response object to check the permission, one can pass the constructor of the customized `Authorizer` class instead of an instance.\n\n```typescript\nimport { Enforcer, newEnforcer } from 'casbin';\nimport { authz, AuthorizerConstructor } from 'casbin-express-authz';\nimport { Request, Response } from 'express';\n\nconst app = express();\n\nclass MyAuthorizer implements Authorizer {\n  private e: Enforcer;\n  private req: Request;\n  private res: Respons;\n\n  constructor(req:Request, res:Respons, e: Enforcer) {\n    this.e = e;\n    this.req = req\n    this.res = res\n  }\n\n  checkPermission(): Promise\u003cboolean\u003e {\n    // do something\n    return true;\n  }\n}\nconst e = await newEnforcer('examples/authz_model.conf', 'examples/authz_policy.csv');\n\napp.use(\n  authz({\n    newEnforcer: e,\n    authorizer: MyAuthorizer,\n  })\n);\n\napp.listen(3000);\n```\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\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%2Fapache%2Fcasbin-express-authz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fcasbin-express-authz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fcasbin-express-authz/lists"}