{"id":22908846,"url":"https://github.com/ipunkt/roles","last_synced_at":"2025-06-30T21:07:10.623Z","repository":{"id":20895573,"uuid":"24183063","full_name":"ipunkt/roles","owner":"ipunkt","description":"Role based permission checking for the ipunkt/permissions package","archived":false,"fork":false,"pushed_at":"2014-09-24T13:09:13.000Z","size":248,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-11T19:33:03.596Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/ipunkt.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}},"created_at":"2014-09-18T09:57:37.000Z","updated_at":"2014-09-18T10:00:23.000Z","dependencies_parsed_at":"2022-08-26T19:01:06.909Z","dependency_job_id":null,"html_url":"https://github.com/ipunkt/roles","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ipunkt/roles","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipunkt%2Froles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipunkt%2Froles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipunkt%2Froles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipunkt%2Froles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ipunkt","download_url":"https://codeload.github.com/ipunkt/roles/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ipunkt%2Froles/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262850265,"owners_count":23374355,"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-12-14T03:32:36.615Z","updated_at":"2025-06-30T21:07:10.604Z","avatar_url":"https://github.com/ipunkt.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"ipunkt/roles\n==================\n\n# About\n\nRole based permission checking for ipunkt/permissions\n\n## Install\n\nAdd to your composer.json following lines\n\n\t\"require\": {\n\t\t\"ipunkt/roles\": \"dev-master\"\n\t}\n\n## Configuration\n\nAdd \n\n    'Ipunkt\\Roles\\RolesServiceProvider'\n    \nto your service provider list.\n\nMigrate by doing\n\n    php artisan migrate --package=ipunkt/roles\n\n## How it works\n\n- A resource type has actions which can be performed on it.\n- A Role has permissions to perform actions.\n- A permission can affect the whole resource type or just a single resource\n- A permission on a single resource takes precedence over a permission on the whole resource type\n- A User has Roles.\n\n### Special Names\n\nThe name `\\*` is special both for actions and resources.  \nWhen used for actions, it will match all actions  \nWhen used for resources, it will match all resources  \n\nNote however that other more specific permissions take precedence over this.\nExample:  \nRole Subadmin has permission allowing to do '\\*' on '\\*'\nRole Subadmin has permission forbidding to do '\\*' on 'supersecrettable'\n\n$userWithSubadmin-\u003ecan('anything', $superSecretModel) will return false, because \\*.supersecrettable is more specific than \\*.\\*\n\n## Use\n\n### Checking Permissions\n`Ipunkt\\Roles\\PermissionChecker\\RolePermissionChecker` will be set as the default permission checker for `ipunkt\\permissions`\nunless you disable it in the config.\n\nThere are 3 ways to use this package\n\n- Commands\n- Web Interface\n- Through the repositories\n\n### Commands\n\ncommand                 | parameters                    | description\n------------------------|-------------------------------|------------\nresource:make           | resource name                 | Creates a new resource with the given name\nresource:list           |                               | Lists all resources\nresource:destroy        | resource id                   | Destroy the resource with the given id\nresource:addaction      | resource id, action name      | Add an action with the given name to the resource with the given id\nresource:listactions    | resource id                   | List all actions the resource with the given id has\nresource:removeaction   | resource id, action name      | Remove the action with the given name on the resource with the given id\nroles:superuser         | user id                       | Assign the role 'Superuser' to the given user which has permission to do '\\*' on '\\*'. If necessary this roles will be created\n\n### Web Interface\n\nThe web interface protects itself through ipunkt/permissions, so make sure you have permission to do \\* on resources and roles.  \nTODO: config variable to disable the web interface entirely\n\n#### Resources\nAccess /permissions/privilege or the route permissions.privilege.index\n\n#### Creating Roles\nAccess /permissions/role or the route permissions.role.index\n\n### Through the repositories\n`Ipunkt\\Roles\\Roles\\RoleRepositoryInterface` is injected with the repository to work with roles.\n`Ipunkt\\Roles\\Resources\\ResourceRepositoryInterface` is injected with the repository to work with resources.\n\n## Advanced Use\nIt is theoreticaly possible to switch out the default eloquent roles to something else by implementing the RoleInterface,\nPermissionInterface and PrivilegeInterface for a different ORM/Database and replacing the repositories. However this remains\nuntested.\n\n### Assigning Roles\nThere is a package ipunkt/auth-roles which connects these roles with ipunkt/auth users and brings an interface to\nassign roles to them.\n\nIf you wish to implement your own connection to a user model make sure to overwrite\nIpunkt\\Permissions\\Repositories\\RoleRepositoryInterface in the IoC.\nThe simplest way to do this is extend EloquentRoleRepository and override allByUserId($id)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipunkt%2Froles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fipunkt%2Froles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fipunkt%2Froles/lists"}