{"id":19423238,"url":"https://github.com/atomjoy/apilogin","last_synced_at":"2026-05-12T21:37:36.251Z","repository":{"id":183075839,"uuid":"669562053","full_name":"atomjoy/apilogin","owner":"atomjoy","description":"Multi guard authentication API with sessions in Laravel.","archived":false,"fork":false,"pushed_at":"2024-02-12T11:55:10.000Z","size":169,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-07T18:53:38.949Z","etag":null,"topics":["laravel-api-auth","laravel-api-authentication"],"latest_commit_sha":null,"homepage":"https://github.com/atomjoy/apilogin","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atomjoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-07-22T17:20:02.000Z","updated_at":"2024-02-09T11:42:24.000Z","dependencies_parsed_at":"2024-01-20T15:26:04.989Z","dependency_job_id":"1af312ce-d14a-45c0-b507-72ff0cb3dd04","html_url":"https://github.com/atomjoy/apilogin","commit_stats":null,"previous_names":["atomjoy/apilogin"],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomjoy%2Fapilogin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomjoy%2Fapilogin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomjoy%2Fapilogin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomjoy%2Fapilogin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomjoy","download_url":"https://codeload.github.com/atomjoy/apilogin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240603062,"owners_count":19827635,"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":["laravel-api-auth","laravel-api-authentication"],"created_at":"2024-11-10T13:37:29.953Z","updated_at":"2026-05-12T21:37:36.208Z","avatar_url":"https://github.com/atomjoy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel API Authentication\r\n\r\nMulti guard authentication API with sessions in Laravel.\r\n\r\n## How to install\r\n\r\nInstall databases and update with composer.\r\n\r\n```sh\r\n# Update\r\ncomposer update\r\n\r\n# Create permissions migrations\r\nphp artisan vendor:publish --provider=\"Spatie\\Permission\\PermissionServiceProvider\"\r\n\r\n# Then change the beginning of the permission migration file name to\r\n2023_01_01_100000_create_permission_tables.php\r\n```\r\n\r\n## Databases\r\n\r\n```sh\r\n# notifications, storage\r\nphp artisan notifications:table\r\nphp artisan storage:link\r\n\r\n# Create tables\r\nphp artisan migrate\r\n\r\n# Refresh tables\r\nphp artisan migrate:fresh\r\n```\r\n\r\n### Add in User model\r\n\r\nAdd profil, address, notifications relations (required).\r\n\r\n```php\r\n\u003c?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Atomjoy\\Apilogin\\Contracts\\HasProfilAddress;\r\nuse Atomjoy\\Apilogin\\Contracts\\HasRolesPermissions;\r\nuse Spatie\\Permission\\Traits\\HasRoles;\r\n\r\nclass User extends Authenticatable\r\n{\r\n    use HasApiTokens, HasFactory, Notifiable;\r\n    use HasProfilAddress, HasRolesPermissions;\r\n    use HasRoles;\r\n\r\n    /**\r\n    * Model table.\r\n    */\r\n    protected $table = 'users';\r\n\r\n    /**\r\n    * Auth guard.\r\n    */\r\n    protected $guard = 'web';\r\n\r\n    /**\r\n    * Append user relations (optional).\r\n    */\r\n    protected $with = ['profile', 'roles'];\r\n\r\n    // ...\r\n}\r\n```\r\n\r\n### Activation page\r\n\r\n```php\r\n\u003c?php\r\n\r\nuse Atomjoy\\Apilogin\\Http\\Controllers\\ActivateController;\r\n\r\n# Email activation link route\r\nRoute::get('/activate/{id}/{code}', [ActivateController::class, 'index'])-\u003ename('activation');\r\n```\r\n\r\n### Run server\r\n\r\n```sh\r\nphp artisan serve --host=localhost --port=8000\r\n```\r\n\r\n## Routes prefix: /web/api\r\n\r\nRoutes in file routes/web.php\r\n\r\n## Validation request\r\n\r\nRoute params search in: src/Http/Requests\r\n\r\n## Overwrite email, translations, config\r\n\r\n```sh\r\nphp artisan lang:publish\r\nphp artisan vendor:publish --tag=apilogin-config--force\r\nphp artisan vendor:publish --tag=apilogin-views --force\r\nphp artisan vendor:publish --tag=apilogin-lang --force\r\n# Permissions seeder migrations\r\nphp artisan db:seed --class=ApiloginPermissionsSeeder\r\n```\r\n\r\n## Default admin credentials\r\n\r\nChange before running the migration. See migration file 2023_08_04_105808_create_admin_users_table.php.\r\n\r\n```php\r\n// config/apilogin.php\r\nreturn [\r\n  // Admin users emails (email with dns mx)\r\n  'super_admin_email' =\u003e 'superadmin@gmail.com',\r\n  'admin_email' =\u003e 'admin@gmail.com',\r\n  'worker_email' =\u003e 'worker@gmail.com',\r\n\r\n  // Admin users passsword\r\n  'super_admin_password' =\u003e 'Password123#',\r\n  'admin_password' =\u003e 'Password123#',\r\n  'worker_password' =\u003e 'Password123#',\r\n]\r\n```\r\n\r\n### Overwrite s3 disk (avatar, images upload), admin emails\r\n\r\nDisable amazon S3 disk overwriting if you have it installed (optional).\r\n\r\n```php\r\n// config/apilogin.php\r\nreturn [\r\n  // Disable Storage::disk s3 to public overwrite\r\n  'overwrite_disk_s3' =\u003e false,\r\n]\r\n```\r\n\r\n## Tests\r\n\r\nCopy testsuite Apilogin from phpunit.xml\r\n\r\n```sh\r\n\u003ctestsuite name=\"Apilogin\"\u003e\r\n  \u003cdirectory suffix=\"Test.php\"\u003e./vendor/atomjoy/apilogin/tests/Dev\u003c/directory\u003e\r\n\u003c/testsuite\u003e\r\n```\r\n\r\n### Mysql user and db\r\n\r\n```sql\r\nCREATE DATABASE IF NOT EXISTS laravel CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\r\nCREATE DATABASE IF NOT EXISTS laravel_testing CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;\r\n\r\nGRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY 'toor' WITH GRANT OPTION;\r\nGRANT ALL PRIVILEGES ON *.* TO root@127.0.0.1 IDENTIFIED BY 'toor' WITH GRANT OPTION;\r\n```\r\n\r\n### Comment fallback route\r\n\r\nChenge or comment the fallback route while testing!\r\n\r\n```php\r\n\u003c?php\r\n// Add login route\r\nRoute::get('/login', function () {\r\n  return view('vue');\r\n})-\u003ename('login');\r\n\r\n// Disable in testing\r\nif (!app()-\u003erunningUnitTests()) {\r\n  // Vue catch all\r\n  Route::fallback(function () {\r\n    return view('vue');\r\n  });\r\n}\r\n```\r\n\r\n### 2FA auth\r\n\r\nTwo factor auth redirection url (vue).\r\n\r\n```sh\r\n/login/f2a/{hash}\r\n/admin/login/f2a/{hash}\r\n```\r\n\r\n### Run tests\r\n\r\n```sh\r\nphp artisan test --stop-on-failure --testsuite=Apilogin\r\n```\r\n\r\n### Local package Laravel composer.json\r\n\r\n```json\r\n{\r\n  \"repositories\": [\r\n  {\r\n   \"type\": \"path\",\r\n   \"url\": \"packages/atomjoy/apilogin\"\r\n  }\r\n ],\r\n \"require\": {\r\n  \"atomjoy/apilogin\": \"dev-main\",\r\n }\r\n}\r\n```\r\n\r\n## Notifications config\r\n\r\nRun first: php artisan notifications:table\r\n\r\n```php\r\n\u003c?php\r\n\r\nuse App\\Models\\User;\r\nuse Atomjoy\\Apilogin\\Notifications\\Contracts\\NotifyMessage;\r\nuse Atomjoy\\Apilogin\\Notifications\\DbNotify;\r\nuse Illuminate\\Support\\Facades\\Route;\r\n\r\nRoute::get('/', function () {\r\n  $msg = new NotifyMessage();\r\n  $msg-\u003esetContent('Hello max your LINK_SIGNUP and LINK_SIGNIN link (Register LINK_SIGNUP).');\r\n  $msg-\u003esetLink('LINK_SIGNUP', 'https://example.com/signup', 'Sign Up');\r\n  $msg-\u003esetLink('LINK_SIGNIN', 'https://example.com/signin', 'Sign In');\r\n\r\n  $user = User::first();\r\n  $user-\u003enotify(new DbNotify($msg));\r\n  $user-\u003enotifyNow(new DbNotify($msg));\r\n\r\n  return $user-\u003enotifications()-\u003eoffset(0)-\u003elimit(15)-\u003eget()-\u003eeach(function ($n) {\r\n    $n-\u003eformatted_created_at = $n-\u003ecreated_at-\u003eformat('Y-m-d H:i:s');\r\n  });\r\n});\r\n```\r\n\r\n## LICENSE\r\n\r\nThis project is licensed under the terms of the GNU GPLv3 license.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomjoy%2Fapilogin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomjoy%2Fapilogin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomjoy%2Fapilogin/lists"}