{"id":20135539,"url":"https://github.com/raisely/alsocan","last_synced_at":"2025-04-09T17:32:50.782Z","repository":{"id":57176862,"uuid":"228300880","full_name":"raisely/alsocan","owner":"raisely","description":"AlsoCan is an authorization library. It's a replacement for CanCan with additional features","archived":false,"fork":false,"pushed_at":"2023-11-14T11:45:45.000Z","size":7,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-23T19:39:12.462Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/raisely.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}},"created_at":"2019-12-16T04:14:22.000Z","updated_at":"2024-05-19T19:42:08.000Z","dependencies_parsed_at":"2022-09-04T11:11:27.525Z","dependency_job_id":null,"html_url":"https://github.com/raisely/alsocan","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/raisely%2Falsocan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Falsocan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Falsocan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raisely%2Falsocan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raisely","download_url":"https://codeload.github.com/raisely/alsocan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247780356,"owners_count":20994705,"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":[],"created_at":"2024-11-13T21:15:24.866Z","updated_at":"2025-04-09T17:32:50.603Z","avatar_url":"https://github.com/raisely.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"AlsoCan is an authorization library. It's a replacement for CanCan with additonal features:\n\nFeatures: \n* Export all permissions of a given user to load them up on the front end\n* Support for explicity deny\n* Rich debugging output to show exactly why an action was allowed or denied\n* Wildcard actions\n* Zero dependencies\n\nUsage\n\n```\nnpm install alsocan\n```\n\n```\nconst AlsoCan = require('./alsoCan');\n\nconst alsoCan = new AlsoCan({\n\ttargetCompare: (instance, model) =\u003e instance instanceof model,\n\tuserCompare: (user, role) =\u003e user.role === role,\n    // Will print debug info to the console if truthy\n\tdebug: process.env.DEBUG_AUTHORIZATION,\n\tdefaultUser: user =\u003e user || { name: 'general public', permission: 'public' }\n});\n\nclass Posts {};\nconst isSameOrg = (user, target, ctx, action) =\u003e user.organisationId === target.organisationId;\nconst isOwner = (user, target, ctx, action) =\u003e user.id === target.userId;\n\nallow('ADMIN', ['manage'], Posts, isSameOrg);\nallow('USER', ['edit*'], Posts, isOwner);\n\n// Authorize access to a record, throws if not allowed\nalsoCan.authorize(user, 'edit', record, ctx);\n// Returns true if the user can perform the action\nconst can = alsoCan.can(user, 'edit', record, ctx);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraisely%2Falsocan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraisely%2Falsocan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraisely%2Falsocan/lists"}