{"id":20433969,"url":"https://github.com/cable8mm/auth-by-key","last_synced_at":"2026-04-20T14:32:37.000Z","repository":{"id":220410503,"uuid":"751576358","full_name":"cable8mm/auth-by-key","owner":"cable8mm","description":"API Key Authorization for Laravel \u0026 Nova","archived":false,"fork":false,"pushed_at":"2024-03-09T15:07:44.000Z","size":138,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-21T23:57:47.542Z","etag":null,"topics":["apikey-authentication","authorization","composer-package","laravel","php8"],"latest_commit_sha":null,"homepage":"https://www.palgle.com/auth-by-key/","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/cable8mm.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}},"created_at":"2024-02-01T22:00:49.000Z","updated_at":"2024-03-11T04:08:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"d97d87f5-6ddc-46ec-88e3-b3fdea125e54","html_url":"https://github.com/cable8mm/auth-by-key","commit_stats":null,"previous_names":["cable8mm/auth-by-key"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/cable8mm/auth-by-key","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cable8mm%2Fauth-by-key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cable8mm%2Fauth-by-key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cable8mm%2Fauth-by-key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cable8mm%2Fauth-by-key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cable8mm","download_url":"https://codeload.github.com/cable8mm/auth-by-key/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cable8mm%2Fauth-by-key/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32050904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T11:35:06.609Z","status":"ssl_error","status_checked_at":"2026-04-20T11:34:48.899Z","response_time":94,"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":["apikey-authentication","authorization","composer-package","laravel","php8"],"created_at":"2024-11-15T08:23:06.611Z","updated_at":"2026-04-20T14:32:36.971Z","avatar_url":"https://github.com/cable8mm.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Auth By Key\n\n[![code-style](https://github.com/cable8mm/auth-by-key/actions/workflows/code-style.yml/badge.svg)](https://github.com/cable8mm/auth-by-key/actions/workflows/code-style.yml)\n[![run-tests](https://github.com/cable8mm/auth-by-key/actions/workflows/run-tests.yml/badge.svg)](https://github.com/cable8mm/auth-by-key/actions/workflows/run-tests.yml)\n![Packagist Version](https://img.shields.io/packagist/v/cable8mm/auth-by-key)\n![Packagist Downloads](https://img.shields.io/packagist/dt/cable8mm/auth-by-key)\n![Packagist Dependency Version](https://img.shields.io/packagist/dependency-v/cable8mm/auth-by-key/php)\n![Packagist Stars](https://img.shields.io/packagist/stars/cable8mm/auth-by-key)\n![Packagist License](https://img.shields.io/packagist/l/cable8mm/auth-by-key)\n\nWe are also able to use Laravel's first-party libraries for authorization, but it might not be lightweight. Yes, as a user Eloquent model, this can help with the problem. Only requests that pass through the 'auth-by-key' layer can proceed to the next stage through Laravel request.\n\nWe have provided the API Documentation on the web. For more information, please visit https://www.palgle.com/auth-by-key/ ❤️\n\n## Installation\n\nRun `composer require cable8mm/auth-by-key`.\n\nRun the migrations\n\n    $ php artisan migrate\n\n1 new database tables will be created:\n\n- api_keys\n\n## Managing Keys\n\nGenerate a new key using `php artisan apikey:generate {name}`. The name argument is the name of your API key. All new keys are active by default.\n\n```bash\n$ php artisan apikey:generate app1\n\n// API key created\n// Name: app1\n// Key: 0ZdNlr7LrQocaqz74k6usQsOsqhqSIaUarSTf8mxnHuQVh9CvKAfpUy94VvBmFMq\n```\n\nDeactivate a key using `php artisan apikey:deactivate {name}`.\n\n```bash\n$ php artisan apikey:deactivate app1\n\n// Deactivated key: app1\n```\n\nActivate a key using `php artisan apikey:activate {name}`.\n\n```bash\n$ php artisan apikey:activate app1\n\n// Activated key: app1\n```\n\nDelete a key. You'll be asked to confirm. Keys are [soft-deleted](https://laravel.com/docs/eloquent#soft-deleting) for record keeping.\n\n```bash\n$ php artisan apikey:delete app1\n\n// Are you sure you want to delete API key 'app1'? (yes/no) [no]:\n// \u003e yes\n\n// Deleted key: app1\n```\n\nList all keys. The -D or --deleted flag includes deleted keys\n\n```bash\n$ php artisan apikey:list -D\n\n// +----------+----+-------------+---------------------+------------------------------------------------------------------+\n// | Name     | ID | Status      | Status Date         | Key                                                              |\n// +----------+----+-------------+---------------------+------------------------------------------------------------------+\n// | app1     | 5  | deleted     | 2017-11-03 13:54:51 | 0ZdNlr7LrQocaqz74k6usQsOsqhqSIaUarSTf8mxnHuQVh9CvKAfpUy94VvBmFMq |\n// | app2     | 1  | deleted     | 2017-11-02 22:34:28 | KuKMQbgZPv0PRC6GqCMlDQ7fgdamsVY75FrQvHfoIbw4gBaG5UX0wfk6dugKxrtW |\n// | app3     | 3  | deactivated | 2017-11-02 23:12:34 | IrDlc7rSCvUzpZpW8jfhWaH235vJAqFwyzVWpoD0SLGzOimA6hcwqMvy4Nz6Hntn |\n// | app4     | 2  | active      | 2017-11-02 22:48:13 | KZEl4Y2HMuL013xvg6Teaa7zHPJhGy1TDhr2zWzlQCqTxqTzyPTcOV6fIQZVTIU3 |\n// +----------+----+-------------+---------------------+------------------------------------------------------------------+\n```\n\n## Usage\n\n### Implementing Authorization\n\nA new `auth.apikey` route middleware has been registered for you to use in your routes or controllers. Below are examples on how to use middleware, but for detailed information, check out [Middleware](https://laravel.com/docs/middleware) in the Laravel Docs.\n\nRoute example\n\n```php\nRoute::get('api/user/1', function () {\n    //\n})-\u003emiddleware('auth.apikey');\n\n```\n\nController example\n\n```php\nclass UserController extends Controller\n{\n    /**\n     * Instantiate a new controller instance.\n     *\n     * @return void\n     */\n    public function __construct()\n    {\n        $this-\u003emiddleware('auth.apikey');\n    }\n}\n```\n\n### Authorizing Requests\n\nIn order to pass the `auth.apikey` middleware, requests must include an `X-Authorization` header as part of the request, with its value being an active API key.\n\n    X-Authorization: KuKMQbgZPv0PRC6GqCMlDQ7fgdamsVY75FrQvHfoIbw4gBaG5UX0wfk6dugKxrtW\n\n## Unauthorized Requests\n\nRequests that do not pass authorization will receive an HTTP 401 Status Code with the following response\n\n```json\n{\n  \"errors\": [\n    {\n      \"message\": \"Unauthorized\"\n    }\n  ]\n}\n```\n\n## Laravel Nova\n\nPublish the nova resource file\n\n```sh\nphp artisan vendor:publish --tag=auth-by-key-nova\n```\n\nIf you will typically need to overwrite,\n\n```sh\nphp artisan vendor:publish --tag=auth-by-key-nova --force\n```\n\n## Fix coding style\n\n```sh\ncomposer lint\n```\n\n## Test\n\n```sh\ncomposer test\n```\n\n## License\n\nThe Auth By Key package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcable8mm%2Fauth-by-key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcable8mm%2Fauth-by-key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcable8mm%2Fauth-by-key/lists"}