{"id":28246729,"url":"https://github.com/dotkernel/dot-rbac-route-guard","last_synced_at":"2026-02-12T21:30:59.621Z","repository":{"id":279791613,"uuid":"939943275","full_name":"dotkernel/dot-rbac-route-guard","owner":"dotkernel","description":"RBAC guard that use the RoutePermission","archived":false,"fork":false,"pushed_at":"2025-11-03T08:22:31.000Z","size":79,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-03T10:13:00.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://docs.dotkernel.org/dot-rbac-route-guard/","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/dotkernel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-27T11:10:01.000Z","updated_at":"2025-11-03T08:20:33.000Z","dependencies_parsed_at":"2025-02-27T17:59:49.555Z","dependency_job_id":"6adf63e8-e8fe-4185-bbcf-a8c41c230793","html_url":"https://github.com/dotkernel/dot-rbac-route-guard","commit_stats":null,"previous_names":["dotkernel/dot-rbac-route-guard"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dotkernel/dot-rbac-route-guard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-rbac-route-guard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-rbac-route-guard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-rbac-route-guard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-rbac-route-guard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotkernel","download_url":"https://codeload.github.com/dotkernel/dot-rbac-route-guard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-rbac-route-guard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29381746,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T20:34:40.886Z","status":"ssl_error","status_checked_at":"2026-02-12T20:23:00.490Z","response_time":55,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2025-05-19T10:07:49.314Z","updated_at":"2026-02-12T21:30:59.609Z","avatar_url":"https://github.com/dotkernel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dot-rbac-route-guard\n\n`dot-rbac-route-guard` is Dotkernel's RBAC Route guard component.\n\nDefines authorization guards that authorize users to access certain parts of an application based on various criteria.\nIf the authorization service can be used to check authorization on a narrow level, the guards are meant to work as gateways to bigger parts of an application.\nUsually, you'll want to use both methods in an application for increased security.\n\n## Documentation\n\nDocumentation is available at: https://docs.dotkernel.org/dot-rbac-route-guard/.\n\n## Badges\n\n![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-rbac-route-guard)\n![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-rbac-route-guard/0.2.0)\n\n[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-rbac-route-guard)](https://github.com/dotkernel/dot-rbac-route-guard/issues)\n[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-rbac-route-guard)](https://github.com/dotkernel/dot-rbac-route-guard/network)\n[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-rbac-route-guard)](https://github.com/dotkernel/dot-rbac-route-guard/stargazers)\n[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-rbac-route-guard)](https://github.com/dotkernel/dot-rbac-route-guard/blob/main/LICENSE.md)\n\n[![Build Static](https://github.com/dotkernel/dot-rbac-route-guard/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/dotkernel/dot-rbac-route-guard/actions/workflows/continuous-integration.yml)\n[![codecov](https://codecov.io/gh/dotkernel/dot-rbac-route-guard/graph/badge.svg?token=AINDYNvE5P)](https://codecov.io/gh/dotkernel/dot-rbac-route-guard)\n[![PHPStan](https://github.com/dotkernel/dot-rbac-route-guard/actions/workflows/static-analysis.yml/badge.svg?branch=main)](https://github.com/dotkernel/dot-rbac-route-guard/actions/workflows/static-analysis.yml)\n\n## Installation\n\nRun the following Composer command in your project's root directory:\n\n```shell\ncomposer require dotkernel/dot-rbac-route-guard\n```\n\nPlease note that this library is built around the authorization service defined in `dotkernel/dot-rbac`.\nRunning the above command will also install that library.\nYou'll have to first configure `dot-rbac` before using this library.\n\n## Configuration\n\nAs with many Dotkernel libraries, we focus on the configuration-based approach of customizing the module for your needs.\n\nAfter installing, merge `dot-rbac-route-guard`'s `ConfigProvider` with your application's config to make sure required dependencies and default library configuration are registered.\nCreate a configuration file for this library in your 'config/autoload' folder.\n\n### authorization-guards.global.php\n\nYou can copy the below code or use the existing `authorization-guards.global.php.dist` to create your version of `authorization-guards.global.php`.\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Dot\\Rbac\\Route\\Guard\\Guard\\GuardInterface;\n\nreturn [\n    'dot_authorization' =\u003e [\n        //define how it will treat non-matching guard rules, allow all by default\n        'protection_policy' =\u003e \\Dot\\Rbac\\Route\\Guard\\Guard\\GuardInterface::POLICY_ALLOW,\n        'event_listeners'   =\u003e [\n            [\n                'type'     =\u003e 'class or service name of the listener',\n                'priority' =\u003e 1,\n            ],\n        ],\n\n        //define custom guards here\n        'guard_manager' =\u003e [],\n\n        //register custom guards providers here\n        'guards_provider_manager' =\u003e [],\n\n        //define which guard provider to use, along with its configuration\n        //the guard provider should know how to build a list of GuardInterfaces based on its configuration\n        'guards_provider' =\u003e [\n            'type'    =\u003e 'ArrayGuards',\n            'options' =\u003e [\n                'guards' =\u003e [\n                    [\n                        'type'    =\u003e 'Route',\n                        'options' =\u003e [\n                            'rules' =\u003e [\n                                'premium' =\u003e ['admin'],\n                                'login'   =\u003e ['guest'],\n                                'logout'  =\u003e ['admin', 'user', 'viewer'],\n                                'account' =\u003e ['admin', 'user'],\n                                'home'    =\u003e ['*'],\n                            ],\n                        ],\n                    ],\n                    [\n                        'type'    =\u003e 'RoutePermission',\n                        'options' =\u003e [\n                            'rules' =\u003e [\n                                'premium' =\u003e ['premium'],\n                                'account' =\u003e ['my-account'],\n                                'logout'  =\u003e ['only-logged'],\n                            ],\n                        ],\n                    ],\n                ],\n            ],\n        ],\n\n        //overwrite default messages\n        'messages_options' =\u003e [\n            'messages' =\u003e [\n                //MessagesOptions::UNAUTHORIZED =\u003e 'You must sign in first to access the requested content',\n                //MessagesOptions::FORBIDDEN =\u003e 'You don\\'t have enough permissions to access the requested content',\n            ],\n        ],\n    ],\n];\n```\n\n## Register RbacGuardMiddleware in the pipeline\n\nThe last step to use this package is to register the middleware.\nThis middleware triggers the authorization event.\nYou MUST insert this middleware between the routing middleware and the dispatch middleware of the application, because the guards need the `RouteResult` in order to get the matched route and params.\n\n### middleware-pipeline.global.php\n\n```php\n//...\n\n'routing' =\u003e [\n    'middleware' =\u003e [\n        ApplicationFactory::ROUTING_MIDDLEWARE,\n\n        //...\n\n        \\Dot\\Rbac\\Guard\\Middleware\\RbacGuardMiddleware::class,\n\n        //...\n\n        ApplicationFactory::DISPATCH_MIDDLEWARE,\n    ],\n    'priority' =\u003e 1,\n],\n\n//...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-rbac-route-guard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotkernel%2Fdot-rbac-route-guard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-rbac-route-guard/lists"}