{"id":19854713,"url":"https://github.com/phwoolcon/admin","last_synced_at":"2025-06-26T16:33:21.102Z","repository":{"id":57041229,"uuid":"95212476","full_name":"phwoolcon/admin","owner":"phwoolcon","description":"Admin module for Phwoolcon","archived":false,"fork":false,"pushed_at":"2017-11-01T14:32:50.000Z","size":30,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T23:38:46.312Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phwoolcon.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":"2017-06-23T11:01:30.000Z","updated_at":"2017-06-23T11:02:12.000Z","dependencies_parsed_at":"2022-08-23T23:30:50.139Z","dependency_job_id":null,"html_url":"https://github.com/phwoolcon/admin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phwoolcon/admin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fadmin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fadmin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fadmin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fadmin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phwoolcon","download_url":"https://codeload.github.com/phwoolcon/admin/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fadmin/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262102358,"owners_count":23259244,"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-12T14:10:12.461Z","updated_at":"2025-06-26T16:33:21.057Z","avatar_url":"https://github.com/phwoolcon.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Phwoolcon Admin\nAdmin module for Phwoolcon\n\n## Features\n\n* Admin User and Roles model\n* Admin Login Auth\n* Admin ACL (route based)\n* Admin operation log\n\n## ACL HOWTOs\n### How/Where to define ACL resources\nThe ACl component will scan `admin/*` routes for corresponding controller methods as resources, and looking for `@acl-name` annotation as display name.\n\nTo skip ACL check for a whole controller, please set property `$skipAcl` as `true`.\n\nTo skip ACL check for a method, please set add a key-value `'methodName' =\u003e true,` in property `$skipAclMethod`.\n\n### How to apply ACL\nACL SHOULD be applied in the controller method `initialze()`.\n\n1. Use `Phwoolcon\\Admin\\Auth::getUser()` to get logged in admin user;\n1. Process `$skipAcl` and `$skipAclMethod`.\n1. Use `Acl::isAllowed($this-\u003euser, $controller, $action)` to check if the access is allowed to the user;\n\n```php\n\u003c?php\n\nnamespace My\\App\\Admin\\Controllers;\n\nuse Phwoolcon\\Admin\\Acl;\nuse Phwoolcon\\Admin\\Auth;\nuse Phwoolcon\\Admin\\Model\\Admin as AdminModel;\nuse Phwoolcon\\Controller;\nuse Phwoolcon\\Controller\\Admin;\nuse Phwoolcon\\Exception\\HttpException;\n\n/**\n * @acl-name Manage Blogs\n */\nclass BlogController extends Controller\n{\n    use Admin {\n        Admin::initialize as _initialize;\n    }\n\n    protected $skipAcl = false;\n    protected $skipAclMethod = [\n        'thisIsAnOpenMethod' =\u003e true,\n    ];\n    /**\n     * @var AdminModel\n     */\n    protected $user;\n\n    public function initialize()\n    {\n        $this-\u003e_initialize();\n        $user = Auth::getUser();\n        if (!$user) {\n            $this-\u003esession-\u003eset('admin_redirect_url', secureUrl($this-\u003erequest-\u003egetURI()));\n            throw new HttpException('Moved Temporarily', 302, ['Location' =\u003e secureUrl('/admin/auth')]);\n        }\n        $this-\u003euser = $user;\n        $this-\u003echeckAcl();\n    }\n\n    protected function checkAcl()\n    {\n        if ($this-\u003eskipAcl) {\n            return;\n        }\n        $controller = $this-\u003erouter-\u003egetControllerName();\n        $action = $this-\u003erouter-\u003egetActionName();\n        if (!empty($this-\u003eskipAclMethod[$action])) {\n            return;\n        }\n        if (Acl::isAllowed($this-\u003euser, $controller, $action)) {\n            return;\n        }\n        throw new HttpException('Forbidden', 403);\n    }\n\n    /**\n     * @acl-name List all blogs\n     */\n    public function getList()\n    {\n        // blah blah blah\n    }\n\n    /**\n     * @acl-name Access a blog\n     */\n    public function getEdit()\n    {\n        // blah blah blah\n    }\n\n    /**\n     * @acl-name Create a blog\n     */\n    public function postCreate()\n    {\n        // blah blah blah\n    }\n\n    /**\n     * @acl-name Update a blog\n     */\n    public function postEdit()\n    {\n        // blah blah blah\n    }\n\n    /**\n     * This method will be open to all admins\n     */\n    public function thisIsAnOpenMethod()\n    {\n        // blah blah blah\n    }\n}\n```\n\n### How to refresh ACL resources\nThe ACL resources will be refreshed after the cache is cleared.\n\nIn most cases, you just need to run `bin/dump-autoload` after you updated ACL definitions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphwoolcon%2Fadmin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphwoolcon%2Fadmin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphwoolcon%2Fadmin/lists"}