{"id":39620031,"url":"https://github.com/yl/apikey-auth","last_synced_at":"2026-01-18T08:24:53.391Z","repository":{"id":57014031,"uuid":"156344895","full_name":"yl/apikey-auth","owner":"yl","description":"API key Authentication for Laravel and Lumen.","archived":false,"fork":false,"pushed_at":"2019-06-20T09:25:54.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-03T07:42:28.213Z","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/yl.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":"2018-11-06T07:40:57.000Z","updated_at":"2019-06-20T09:25:13.000Z","dependencies_parsed_at":"2022-08-21T14:50:28.549Z","dependency_job_id":null,"html_url":"https://github.com/yl/apikey-auth","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/yl/apikey-auth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yl%2Fapikey-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yl%2Fapikey-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yl%2Fapikey-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yl%2Fapikey-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yl","download_url":"https://codeload.github.com/yl/apikey-auth/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yl%2Fapikey-auth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28534143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2026-01-18T08:24:52.761Z","updated_at":"2026-01-18T08:24:53.382Z","avatar_url":"https://github.com/yl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# apikey-auth\n\nAPI key Authentication for Laravel and Lumen.\n\n## 安装\n\n```bash\ncomposer require leonis/apikey-auth\n```\n\n## 配置\n\n### Laravel\n\n1. 在 `config/app.php` 注册 ServiceProvider (Laravel 5.5 及以上无需手动注册)\n\n    ```php\n    'providers' =\u003e [\n        // ...\n        Leonis\\ApiKeyAuth\\Providers\\ServiceProvider::class\n     ],\n     ```\n\n2. 创建配置文件：\n\n    ```bash\n    php artisan vendor:publish --provider=\"Leonis\\ApiKeyAuth\\ApiKeyAuthServiceProvider\"\n    ```\n\n3. 运行数据库迁移\n\n    ```bash\n    php artisan migrate\n    ```\n\n### lumen\n\n1. 在 `bootstrap/app.php` 注册 ServiceProvider\n\n    ```php\n    $app-\u003eregister(Leonis\\ApiKeyAuth\\Providers\\ServiceProvider::class);\n    ```\n\n2. 复制配置和数据库迁移文件  \n\n    将 `vendor/leonis/apikey-auth/config/config.php` 拷贝到 `config` 目录下，并将文件名改成 `api_key.php`;\n    将 `vendor/leonis/apikey-auth/database/migrations` 目录中的文件拷贝到 `database/migrations` 目录下。\n\n3. 运行数据库迁移\n\n    ```bash\n    php artisan migrate\n    ```\n\n## 使用\n\n1. 修改 `auth.php` 配置文件中的 `guards` :\n    ```php\n    'guards' =\u003e [\n            // ...\n    \n            'api' =\u003e [\n                'driver' =\u003e 'api_key',\n                'provider' =\u003e 'users',\n            ],\n        ],\n    ```\n\n2. 为用户生成 Api Key :\n    ```php\n    ApiKey::fromUser(User::first());\n    ApiKey::fromId($user-\u003eid);\n    ```\n\n3. 请求 API :\n\n    TODO\n    \n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyl%2Fapikey-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyl%2Fapikey-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyl%2Fapikey-auth/lists"}