{"id":45742581,"url":"https://github.com/whilesmartphp/laravel-oauth-apps","last_synced_at":"2026-02-25T15:27:34.027Z","repository":{"id":304505391,"uuid":"1018188519","full_name":"whilesmartphp/laravel-oauth-apps","owner":"whilesmartphp","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-26T14:08:45.000Z","size":107,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"dev","last_synced_at":"2025-10-19T23:53:16.370Z","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/whilesmartphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2025-07-11T19:03:41.000Z","updated_at":"2025-09-26T14:08:50.000Z","dependencies_parsed_at":"2025-09-17T23:11:25.535Z","dependency_job_id":"b99db192-4717-4fbe-8dcd-6a94142825dd","html_url":"https://github.com/whilesmartphp/laravel-oauth-apps","commit_stats":null,"previous_names":["whilesmartphp/laravel-app-authentication","whilesmartphp/laravel-oauth-apps"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/whilesmartphp/laravel-oauth-apps","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Flaravel-oauth-apps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Flaravel-oauth-apps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Flaravel-oauth-apps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Flaravel-oauth-apps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whilesmartphp","download_url":"https://codeload.github.com/whilesmartphp/laravel-oauth-apps/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whilesmartphp%2Flaravel-oauth-apps/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29827684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T14:53:59.163Z","status":"ssl_error","status_checked_at":"2026-02-25T14:53:23.002Z","response_time":61,"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":"2026-02-25T15:27:28.314Z","updated_at":"2026-02-25T15:27:34.022Z","avatar_url":"https://github.com/whilesmartphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WhileSmart Laravel Oauth Apps Package\n\nA Laravel package providing out-of-the-box authentication for applications and API key management.\n\n## Features\n\n* **Application Management:**\n    * Users (managed by an external system) can register and manage their applications.\n    * Each application gets a unique ID.\n* **API Key Generation and Revocation:**\n    * Users can generate API keys for their applications.\n    * API keys have configurable expiration dates.\n    * Ability to revoke API keys.\n* **API Key Authentication:**\n    * Middleware to protect API routes using API keys.\n* **OpenAPI Documentation:**\n    * Easily generate API documentation using packages like `l5-swagger`.\n* **Configurable Settings:**\n    * Easily customize settings via a configuration file.\n\n## Installation\n\n### 1. Require the package\n\n   ```bash\n   $ composer require whilesmart/laravel-oauth-apps\n   ```\n\nThis package uses Laravel/passport. Please run the command below if you do not yet have passport configured\n\n```bash\n$ php artisan install:api --passport\n```\n\nAdditionally, this command will ask if you would like to use UUIDs as the primary key value of the Passport Client model\ninstead of auto-incrementing integer\n. Select UUID\n\nOr simply run\n\n```bash\n$ php artisan passport:install --uuids\n```\n\n### 2. Publish the configuration and migrations:\n\nYou do not need to publish the migrations and configurations except if you want to make modifications. You can choose to\npublish\nthe migrations, routes, controllers separately or all at once.\n\n#### 2.1 Publishing only the routes\n\nRun the command below to publish only the routes.\n\n```bash\n$ php artisan vendor:publish --tag=laravel-oauth-apps-routes\n$ php artisan migrate\n```\n\nThe routes will be available at `routes/oauth-apps.php`. If `register_routes` in `config/oauth-apps.php`\nis `true` (default), the routes will be automatically registered with the defined `route_prefix` (default `api`). If you\nwish to disable auto-registration and manually control the route definition, set `register_routes` to `false` in your\nconfig and then `require 'oauth-apps.php';` in your `api.php` file.\n\n```php\nrequire 'oauth-apps.php';\n```\n\n#### 2.2 Publishing only the migrations\n\n+If you would like to make changes to the migration files, run the command below to publish only the migrations.\n\n```bash\n$ php artisan vendor:publish --tag=laravel-oauth-apps-migrations\n$ php artisan migrate\n```\n\nThe migrations will be available in the `database/migrations` folder.\n\n#### 2.3 Publish only the controllers\n\nTo publish the controllers, run the command below\n\n```bash\n$ php artisan vendor:publish --tag=laravel-oauth-apps-controllers\n$ php artisan migrate\n```\n\nThe controllers will be available in the `app/Http/Controllers/Api/Auth` directory.\nFinally, change the namespace in the published controllers to your namespace.\n\n#### Note: Publishing the controllers will also publish the routes. See section 2.1\n\n#### 2.4 Publish  the config\n\nTo publish the config, run the command below\n\n```bash\nphp artisan vendor:publish --tag=laravel-app-authentication-config\n```\n\nThe config file will be available in the `config/oauth-apps.php`.\nThe config file has the folowing variables:\n\n- `register_routes`: Default `true`. Auto registers the routes. If you do not want to auto-register the routes, set the\n  value to `false\n- `route_prefix`: Default `api`. Defines the prefix for the auto-registered routes.\n\n#### 2.5 Publish Locals\n\n```bash\nphp artisan vendor:publish --tag=laravel-oauth-apps-locals\n ```\n\nThe locales will be available in the `resources/lang/\u003clocale\u003e/oauth-apps.php`.\n\n#### 2.6 Publish OpenAPI Documentations\n\n```bash\nphp artisan vendor:publish --tag=laravel-oauth-apps-docs\n```\n\nThe documentation will be available in the `app/Http/Interfaces` directory.\n\n#### 2.7 Publish everything\n\nTo publish the migrations, routes and controllers, you can run the command below\n\n```bash\n$ php artisan vendor:publish --tag=laravel-oauth-apps\n$ php artisan migrate\n```\n\n#### Note: See section 2.1 above to make the routes accessible\n\n3. **Optional: OpenAPI Documentation:**\n\n    * Install and configure an OpenAPI package (e.g., `darkaonline/l5-swagger`).\n    * Add necessary annotations to your controllers.\n\n## Configuration\n\n* The configuration file `config/oauth-apps.php` allows you to customize various settings\n\n## Usage\n\n### API Endpoints\n\nAfter installation, the following API endpoints will be available:\n\n* **Application Management:**\n    * `POST /api/apps`: Create a new application.\n    * `GET /api/apps`: List user's applications.\n    * `DELETE /api/apps/{app}`: Delete an application.\n* **API Key Management:**\n    * `POST /apps/{app}/api-keys`: Generate a new API key.\n    * `DELETE /apps/{app}/api-keys/{apiKey}`: Revoke an API key.\n    * `POST /apps/{app}/regenerate-secret`: Regenerate app secret.\n\n### Example API Key Generation Request\n\nPOST /apps/{app}/api-keys\n\n(Where `{app}` is the id of the app)\n\n### API Key Authentication\n\nAdd the `Whilesmart\\LaravelOauthApps\\Http\\Middleware\\EnforceHeaderAuth` middleware to your `Kernel.php` if\nyou are using Laravel \u003c11\n\n```php\n    protected $routeMiddleware = [\n        ...,\n        'AuthenticateApiKey' =\u003e \\Whilesmart\\LaravelOauthApps\\Http\\Middleware\\EnforceHeaderAuth::class,\n    ];\n\n```\n\nor `bootstrap/app.php` if you are using Laravel 11+\n\n```php\nreturn Application::configure(basePath: dirname(__DIR__))\n    -\u003ewithRouting(\n    web: __DIR__.'/../routes/web.php',\n        // api: __DIR__.'/../routes/api.php',\n        commands: __DIR__.'/../routes/console.php',\n        // channels: __DIR__.'/../routes/channels.php',\n        health: '/up',\n    )\n    -\u003ewithMiddleware(function (Middleware $middleware) {\n        ...\n        $middleware-\u003ealias(['auth.api.key'=\u003e \\Whilesmart\\LaravelOauthApps\\Http\\Middleware\\EnforceHeaderAuth::class]);\n\n    })\n    -\u003ewithExceptions(function (Exceptions $exceptions) {\n        //\n    })-\u003ecreate();\n```\n\nTo protect your API routes, use the `auth.api.key` middleware. Applications authenticate using the API Keys.\n\n```php\n// routes/api.php\nRoute::middleware('auth.api.key')-\u003egroup(function () {\n    // Your protected routes here\n      Route::get('/test-auth-app', function (Request $request) {\n            return response()-\u003ejson($request-\u003eapp);\n        });\n});\n```\n\nTo use the API, provide the id generated for the application in the **X-Client-ID** header, and the secret in the *\n*X-Client-Secret**\n\nUse ```$request-\u003eapp``` to get the app object in your controllers.\n\nPlease feel free to contribute by submitting pull requests or reporting issues.\n\n### License\n\nThis package is open-source software licensed under the [MIT license](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Flaravel-oauth-apps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhilesmartphp%2Flaravel-oauth-apps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhilesmartphp%2Flaravel-oauth-apps/lists"}