{"id":19481682,"url":"https://github.com/cellajs/permission-manager","last_synced_at":"2025-04-25T15:32:16.253Z","repository":{"id":229201359,"uuid":"776093925","full_name":"cellajs/permission-manager","owner":"cellajs","description":"Module designed to facilitate Role-Based Access Control (RBAC) and Attribute-Based Access Control (ABAC) permissions within a hierarchical application structure.","archived":false,"fork":false,"pushed_at":"2024-04-18T15:41:34.000Z","size":1170,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-31T05:22:47.006Z","etag":null,"topics":["abac","access-control","mit-license","nodejs","package","permissions","policy","rbac","roles","tool","typescript"],"latest_commit_sha":null,"homepage":"https://cellajs.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cellajs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-03-22T17:07:46.000Z","updated_at":"2024-07-11T13:40:15.000Z","dependencies_parsed_at":"2024-04-16T11:44:28.247Z","dependency_job_id":"4789e790-508f-4fc6-9ede-5006cc2d6dd3","html_url":"https://github.com/cellajs/permission-manager","commit_stats":null,"previous_names":["cellajs/permission-manager"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cellajs%2Fpermission-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cellajs%2Fpermission-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cellajs%2Fpermission-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cellajs%2Fpermission-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cellajs","download_url":"https://codeload.github.com/cellajs/permission-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224007984,"owners_count":17240293,"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":["abac","access-control","mit-license","nodejs","package","permissions","policy","rbac","roles","tool","typescript"],"created_at":"2024-11-10T20:06:05.573Z","updated_at":"2024-11-10T20:06:06.929Z","avatar_url":"https://github.com/cellajs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"./.github/banner.png\" /\u003e\n\u003cbr /\u003e\n\n[cellajs.com](https://cellajs.com) \u0026centerdot; prerelease version \u0026centerdot; MIT license \u0026centerdot; ![Dutch](https://raw.githubusercontent.com/stevenrskelton/flag-icon/master/png/16/country-4x3/nl.png) ![Europe](https://raw.githubusercontent.com/stevenrskelton/flag-icon/master/png/16/country-4x3/europeanunion.png)\n\n![Node.js](https://img.shields.io/badge/Node.js-%2343853D?logo=node.js\u0026logoColor=white) \u0026middot; ![TypeScript](https://img.shields.io/badge/TypeScript-%23007ACC?logo=typescript\u0026logoColor=white) \u0026middot; ![Tap.js](https://img.shields.io/badge/Tap.js-%23375A81?logo=tap\u0026logoColor=white)\n\n\u003c/div\u003e\n\n#### Prerelease\n\n\u003e ❗ Please be aware this is a prerelease. It does not meet production requirements yet.\n\n#### Contents\n- [Description](#Description)\n- [Installation](#Installation)\n- [Test](#Test)\n- [Quick Start](#Quick-Start)\n- [Roadmap](#Roadmap)\n- [License](#License)\n\n#### Additional Resources\n\u003e Explore more detailed documentation and resources to enhance your understanding and implementation of the Permission Manager module.\n- [API's](APIS.md)\n\n## Description\nThe permission-manager is a tool designed to facilitate Role-Based Access Control (RBAC) and Attribute-Based Access Control (ABAC) permissions within a hierarchical application structure. \n\nThis first release is primarily integrated with [cella.js](https://cellajs.com/about) and will be utilized for [Shareworks applications](https://www.shareworks.nl/).\n\n\n## Installation\nInstall the module via npm:\n```bash\nnpm install --save @cellajs/permission-manager\n```\n\n## Test\nRun tests with npm:\n```bash\nnpm run test\n```\n\n## Quick Start\n\nImplementing the Permission Manager involves 4 steps:\n\n| Step | Subject | Description |\n|----------|----------|----------|\n| 1 | *Hierarchical structure | Define the hierarchical structure of your application, distinguishing between actors, contexts, roles, and products.|\n| 2 | *Access Policies | Establish access policies based on a many-to-many relationship between different contexts and their corresponding roles, ensuring precise control over permissions. |\n| 3 | _(Optional)_ Adapters | Optionally configure adapters to seamlessly integrate the permission manager within your application ecosystem. |\n| 4 | *Integrate | Integrate the permission manager into middleware layers or directly into application logic to enforce access control throughout the application's execution flow. |\n\n\u003e ❗ During the setup of your application, it's recommended to import and configure the permission manager to establish access control mechanisms. \nThis ensures that access to different parts of your application is properly regulated based on predefined roles and permissions.\n\n```typescript\n// 1. Define Hierarchical Structure:\nimport { Context, Product } from '@cellajs/permission-manager';\n\nconst community = new Context('community', ['admin', 'member']);\nconst subCommunity = new Context('subCommunity', ['follower'], new Set([community]));\n\nnew Product('post', new Set([subCommunity]));\n\n// 2. Establish access policies:\nimport { PermissionManager, AccessPolicyConfiguration } from '@cellajs/permission-manager';\n\nconst permissionManager = new PermissionManager('permissionManager');\npermissionManager.accessPolicies.configureAccessPolicies(({ subject, contexts }: AccessPolicyConfiguration) =\u003e {\n    switch (subject.name) {\n      case 'community':\n        contexts.community.admin({ create: 0, read: 1, update: 1, delete: 0 });\n        contexts.community.member({ create: 0, read: 1, update: 0, delete: 0 });\n        break;\n      case 'subCommunity':\n        contexts.community.admin({ create: 1, read: 1, update: 1, delete: 1 });\n        contexts.subCommunity.follower({ create: 0, read: 1, update: 0, delete: 0 });\n        break;\n      case 'post':\n        contexts.community.admin({ create: 1, read: 1, update: 1, delete: 1 });\n        contexts.subCommunity.follower({ create: 1, read: 1, update: 0, delete: 0 });\n        break;\n    };\n});\n\n// 3. Optionally configure adapters (see API's documentation)\n\n// 4. Integrate into middleware layers\nconst memberships = [{ contextName: 'community', contextKey: 1, roleName: 'admin', ancestors: {}}];\nconst subject = { name: 'community', key: 1 };\n\nconst isAllowed = permissionManager.isPermissionAllowed(memberships, 'read', subject);\nconst canDo = permissionManager.getActorPolicies(memberships, subject);\n}\n```\n\n## Roadmap\nHere are the future steps planned for the development of this project:\n\n- **Add tests:** Implement comprehensive testing to ensure code stability and reliability.\n  \n- **Create more attribute-based features:** Expand the functionality of the project by introducing additional attribute-based features.\n\n- **Write technical documentation:** Document the technical aspects of the project to facilitate understanding and collaboration among developers.\n\n- **Create documentation for different complex implementations:** Provide documentation for various complex implementations to assist users in understanding and utilizing advanced features.\n\n\n## License\nMIT License\n\nCopyright (c) 2024 @cellajs/permission-manager\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcellajs%2Fpermission-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcellajs%2Fpermission-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcellajs%2Fpermission-manager/lists"}