{"id":15937558,"url":"https://github.com/zofe/auth-module","last_synced_at":"2026-02-14T03:15:02.334Z","repository":{"id":91604975,"uuid":"607606573","full_name":"zofe/auth-module","owner":"zofe","description":"auth module for rapyd-livewire laravel application","archived":false,"fork":false,"pushed_at":"2025-03-29T10:36:47.000Z","size":140,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-23T21:36:26.470Z","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/zofe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2023-02-28T10:11:35.000Z","updated_at":"2024-10-26T13:14:22.000Z","dependencies_parsed_at":"2024-10-26T15:28:37.685Z","dependency_job_id":"7bcd267d-6818-4d11-a537-0bd7aa7c22be","html_url":"https://github.com/zofe/auth-module","commit_stats":{"total_commits":49,"total_committers":1,"mean_commits":49.0,"dds":0.0,"last_synced_commit":"4236b80639fcbc1e6e47ace765172e63a123874a"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"purl":"pkg:github/zofe/auth-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zofe%2Fauth-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zofe%2Fauth-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zofe%2Fauth-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zofe%2Fauth-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zofe","download_url":"https://codeload.github.com/zofe/auth-module/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zofe%2Fauth-module/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29433304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T02:20:56.896Z","status":"ssl_error","status_checked_at":"2026-02-14T02:11:29.478Z","response_time":53,"last_error":"SSL_read: 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":"2024-10-07T05:03:34.744Z","updated_at":"2026-02-14T03:15:02.256Z","avatar_url":"https://github.com/zofe.png","language":"PHP","readme":"# Rapyd Admin - Auth Module\n\nThis is the auth module of [Rapyd Admin](https://github.com/zofe/rapyd-admin), a Laravel application bootstrap for your projects\n\nIt embed:\n\n- login, registration, two factor authentication\n- role/permission management\n- user management\n- impersonation features.\n- component permissions, and priority \"role based\"\n\n\n# Login / Registration \u0026 Two factor authentication\n\nThis module give you out of the box a fortify implementation https://laravel.com/docs/10.x/fortify#main-content \nwith a bootstrap layout and default configuration you can customize on ./config/fortify.php \n\n\n# Permissions \u0026 Models\n\nTwo Models will be provided by this module:\n - Role\n - Permission\n\nAs you can imagine the role is a characteristic you can associate with a user, permissions are the \"actions granted\" for that role.\n\nThe module has a configuration file that allows you to define roles, permissions, and the relationship between them.\n\nThe editable configuration is provided in ./config/permission.php\nThen you need to run the provided seeder.\n\nthese features are based on the library:\nhttps://github.com/spatie/laravel-permission\n\n\n# Impersonation \n\nOne of the necessary features in the implementation of a backend is to impersonate other users/customers, this module has this functionality built in\n\nThis module include a trait `App\\Modules\\Auth\\Traits\\Impersonate` to check roles if user can impersonate other and to check if user can be impersonated.\n\nBy default, this trait add check if You are admin and the user you want to impersonate is not an admin (using roles).\n\nfor a custom implementation override `canImpersonate()` and `canBeImpersonated()` in your model\n\n```php\n\nuse App\\Modules\\Auth\\Traits\\Impersonate;\n\nclass User extends Model\n{\n  use Impersonate;\n\n```\n\nthis features is based on the library\nhttps://github.com/lab404/laravel-impersonate\n\n\n\n# Component roles \u0026 permissions\n\n\n\n## Authorize trait\n\nThis module include a trait `App\\Modules\\Auth\\Traits\\Authorize` to check roles or permissions before build/render/execute component actions.\n\nyou can just include the trait, then add authorize check at booted time in your components:\n\n```php\n\nuse App\\Modules\\Auth\\Traits\\Authorize;\n\nclass CompaniesEdit extends Component\n{\n    use Authorize;\n\n    public function booted()\n    {\n        $this-\u003eauthorize('admin|edit users');\n    }\n```\n\nthis will check if one of role or permission is applied to the logged-in user, otherwise it gives a permission error.\n\n## Limit trait\n\nThis module include a trait `App\\Modules\\Auth\\Traits\\Limit` to add global scopes in your application, specific for role you need to jailroot eloquent models to specific query scopes. \n\n\n```php\n\u003c?php\n\nnamespace App\\Modules\\Companies\\Livewire;\n\nuse App\\Models\\Company;\nuse App\\Modules\\Auth\\Traits\\Limit;\nuse Livewire\\Component;\n\nclass CustomersTable extends Component\n{\n    use Limit;\n\n    public function booted()\n    {\n        $this-\u003elimit();\n    }\n\n\n```\n\nlimit inside booted method will deal with all classes in Modules/*/Limits/LimitName.php\nto add specific global scopes.\nIn the example below a global scope is added on Company model to be sure to bind queries on companies to those that are either the same as the logged-in user or are \"daughters\" of the one to which the logged-in user belongs.\n\n\n```php\n\u003c?php\n\nnamespace App\\Modules\\Companies\\Limits;\n\nuse App\\Models\\Company;\nuse Illuminate\\Contracts\\Database\\Eloquent\\Builder;\nuse Illuminate\\Support\\Facades\\DB;\n\nclass CompanyLimit\n{\n    public static function limit($except = [])\n    {\n        $user = auth()-\u003euser();\n\n        Company::addGlobalScope('onlyMine', function (Builder $builder) use (auth()-\u003euser()) {\n            $builder-\u003ewhere('parent_id', $user-\u003ecompany_id)\n                -\u003eorWhere('id', $user-\u003ecompany_id)\n        });\n    }\n\n}\n\n```\n\n\n\n# Component priority role based\n\nThis module include a middleware out of the box, that search for priority component instead of the one defaulted by the route.\n\nBy \"priority component\" we mean a component that is prefixed with the \"Rolename\" of the logged-in user\ne.g., despite the defined route :\n\n`Route::get('/companies/view/{company:id}', CompaniesView::class)`\n\n`Customer` role user the middleware looks for `CustomerCompaniesView::class` and dispenses that if it exists.\n\nthis allows you to extend livewire components and adapt features and views potentially for each `role` to be managed (if you need to do so).\n\nJust configure your prefixes in the config:\n```php\n    'role_to_component_prefix' =\u003e [\n        'customer' =\u003e 'customer'\n    ],\n```\n\nadd the middleware in your app/Http/Kernel.php\n\n```php\n    protected $middlewareGroups = [\n        'web' =\u003e [\n            //..\n            \\App\\Modules\\Auth\\Http\\Middleware\\ComponentByRole::class,\n        ],\n    ]\n```\n\n\n# Component role to component specific routes\n\nassuming you're using Ticket open source module, \nyou can customize that a custom role i.e. \"customer\" can open ticket using:\n\n\n```php\n    'role_to_component_class' =\u003e [\n        'customer' =\u003e [\n            'tickets.tickets.table' =\u003e \\App\\Components\\Tickets\\UserTicketsTable::class,\n            'tickets.tickets.view' =\u003e \\App\\Components\\Tickets\\UserTicketsView::class\n        ],\n\n    ],\n```\n\nthis way the routes `tickets.tickets.table` and `tickets.tickets.view` will be server by your custom implementation of components\n(which can extend the default ticket module components)\n\n\n# Installation \u0026 configuration \n\nThis module is part of [Rapyd Admin](https://github.com/zofe/rapyd-admin) package\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzofe%2Fauth-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzofe%2Fauth-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzofe%2Fauth-module/lists"}