{"id":13658055,"url":"https://github.com/sms-system/simple-abac","last_synced_at":"2026-02-24T21:08:02.358Z","repository":{"id":145818595,"uuid":"83349456","full_name":"sms-system/simple-abac","owner":"sms-system","description":"Simple Attribute-based access control module","archived":false,"fork":false,"pushed_at":"2017-03-03T16:39:56.000Z","size":8,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-10T11:39:08.589Z","etag":null,"topics":["abac","acl","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sms-system.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":"2017-02-27T19:42:18.000Z","updated_at":"2021-08-26T11:03:02.000Z","dependencies_parsed_at":"2023-06-12T03:30:27.005Z","dependency_job_id":null,"html_url":"https://github.com/sms-system/simple-abac","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sms-system%2Fsimple-abac","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sms-system%2Fsimple-abac/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sms-system%2Fsimple-abac/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sms-system%2Fsimple-abac/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sms-system","download_url":"https://codeload.github.com/sms-system/simple-abac/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250591967,"owners_count":21455473,"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","acl","nodejs"],"created_at":"2024-08-02T05:00:55.626Z","updated_at":"2026-02-24T21:08:02.324Z","avatar_url":"https://github.com/sms-system.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# simple-abac\n\nSimple Attribute-based access control module\n\n## Example\n\nFile `config/abac.js`:\n\n```js\nvar ABAC = require('simple-abac')\n\nconst ROLES = {\n  ADMIN: 'ADMIN',\n  USER: 'USER',\n  MANAGER: 'MANAGER'\n}\n\nmodule.exports = new ABAC({\n  '*': user =\u003e user.role == ROLES.ADMIN,\n  create_post: () =\u003e true,\n  edit_post: [\n    (user, post) =\u003e user.role == ROLES.USER \u0026\u0026 post.user_id == user.id,\n    (user, post) =\u003e user.role == ROLES.MANAGER,\n  ],\n  delete_post: { as: 'edit_post' }\n})\n```\n\nFile `app.js`:\n\n```js\nvar abac = require('./conf/abac')\n\nconst adminUser = {\n  id: 1,\n  role: 'ADMIN'\n}\nconst user = {\n  id: 2,\n  role: 'USER'\n}\nconst posts = [{\n  user_id: 2,\n  title: 'Post from user 2'\n}, {\n  user_id: 3,\n  title: 'Post from user 3'\n}]\n\nconsole.log('user #1 role: ' + adminUser.role)\nposts.forEach(post =\u003e {\n  if (abac.can( adminUser, 'delete_post', post )) {\n    console.log('You can delete post \"' + post.title + '\"')\n  } else {\n    console.log('You can\\'t delete post \"' + post.title + '\"')\n  }\n})\nconsole.log('\\n')\n\nconsole.log('user #2 role: ' + user.role)\nposts.forEach(post =\u003e {\n  if (abac.can( user, 'delete_post', post )) {\n    console.log('You can delete post \"' + post.title + '\"')\n  } else {\n    console.log('You can\\'t delete post \"' + post.title + '\"')\n  }\n})\nconsole.log('\\n')\n```\n\nResult `node app.js` :\n```\nuser #1 role: ADMIN\nYou can delete post \"Post from user 2\"\nYou can delete post \"Post from user 3\"\n\n\nuser #2 role: USER\nYou can delete post \"Post from user 2\"\nYou can't delete post \"Post from user 3\"\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsms-system%2Fsimple-abac","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsms-system%2Fsimple-abac","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsms-system%2Fsimple-abac/lists"}