{"id":36995156,"url":"https://github.com/tkhamez/slim-role-auth","last_synced_at":"2026-01-13T23:47:28.344Z","repository":{"id":57070408,"uuid":"146102047","full_name":"tkhamez/slim-role-auth","owner":"tkhamez","description":"Role-based authorization for the Slim framework","archived":false,"fork":false,"pushed_at":"2025-11-23T13:14:39.000Z","size":81,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-03T20:52:36.213Z","etag":null,"topics":["authorization","middleware","slim-framework"],"latest_commit_sha":null,"homepage":"","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/tkhamez.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-08-25T14:27:44.000Z","updated_at":"2025-11-23T13:14:01.000Z","dependencies_parsed_at":"2024-11-23T16:23:22.788Z","dependency_job_id":"3e6d8d85-66bd-46b6-b70f-fb66b2f36450","html_url":"https://github.com/tkhamez/slim-role-auth","commit_stats":{"total_commits":43,"total_committers":2,"mean_commits":21.5,"dds":"0.023255813953488413","last_synced_commit":"ed764800521a69f9d822add0f5121a26a8d11e0c"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/tkhamez/slim-role-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkhamez%2Fslim-role-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkhamez%2Fslim-role-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkhamez%2Fslim-role-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkhamez%2Fslim-role-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tkhamez","download_url":"https://codeload.github.com/tkhamez/slim-role-auth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tkhamez%2Fslim-role-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28405308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["authorization","middleware","slim-framework"],"created_at":"2026-01-13T23:47:28.262Z","updated_at":"2026-01-13T23:47:28.328Z","avatar_url":"https://github.com/tkhamez.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](http://poser.pugx.org/tkhamez/slim-role-auth/v)](https://packagist.org/packages/tkhamez/slim-role-auth) \n[![Total Downloads](http://poser.pugx.org/tkhamez/slim-role-auth/downloads)](https://packagist.org/packages/tkhamez/slim-role-auth) \n[![License](http://poser.pugx.org/tkhamez/slim-role-auth/license)](https://packagist.org/packages/tkhamez/slim-role-auth) \n[![PHP Version Require](http://poser.pugx.org/tkhamez/slim-role-auth/require/php)](https://packagist.org/packages/tkhamez/slim-role-auth)\n[![build](https://github.com/tkhamez/slim-role-auth/workflows/test/badge.svg)](https://github.com/tkhamez/slim-role-auth/actions)\n\n# Role-based authorization\n\nMiddleware for the [Slim 4](http://www.slimframework.com/) framework.\n\nFor Slim 3 use the 1.0.0 release.\n\n## Installation\n\nWith Composer:\n\n```\ncomposer require tkhamez/slim-role-auth\n```\n\n## Usage\n\nExample:\n\n```php\nuse Tkhamez\\Slim\\RoleAuth\\RoleMiddleware;\nuse Tkhamez\\Slim\\RoleAuth\\SecureRouteMiddleware;\n\n$app = Slim\\Factory\\AppFactory::create();\n\n// Deny access if a required role is missing.\n$app-\u003eadd(new SecureRouteMiddleware(\n    new Slim\\Psr7\\Factory\\ResponseFactory(), // Any implementation of Psr\\Http\\Message\\ResponseFactoryInterface.\n    [\n        // Route pattern  =\u003e Roles, the first \"starts-with\" match is used.\n        '/secured/public' =\u003e ['any'],\n        '/secured'        =\u003e ['user'],\n    ],\n    ['redirect_url' =\u003e null] // Adds the \"Location\" header instead of a 403 status code if set.\n));\n\n// Add roles to request attribute.\n$app-\u003eadd(new RoleMiddleware(\n    new App\\RoleProvider(), // Any implementation of Tkhamez\\Slim\\RoleAuth\\RoleProviderInterface.\n    ['route_pattern' =\u003e ['/secured']] // Optionally limit to these routes.\n));\n\n// Add routing middleware last, so the Slim router is available from the request.\n$app-\u003eaddRoutingMiddleware();\n```\n\n- The `SecureRouteMiddleware` denies access to a route if the required role is missing in the request object.\n- The `RoleMiddleware` class adds roles provided by the `RoleProvider` object to the request object.\n- You can add multiple role providers for different paths.\n\nFor more information, see the inline documentation of the classes.\n\n## Dev Env\n\n```shell\ndocker build --tag slim-role-auth .\ndocker run -it --mount type=bind,source=\"$(pwd)\",target=/app --workdir /app slim-role-auth /bin/sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkhamez%2Fslim-role-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftkhamez%2Fslim-role-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftkhamez%2Fslim-role-auth/lists"}