{"id":17855361,"url":"https://github.com/arubacao/http-basic-auth-guard","last_synced_at":"2025-03-20T12:33:56.116Z","repository":{"id":56962328,"uuid":"54335506","full_name":"arubacao/http-basic-auth-guard","owner":"arubacao","description":"HTTP Basic Auth Guard for Lumen 5.x","archived":false,"fork":false,"pushed_at":"2019-04-24T13:51:29.000Z","size":74,"stargazers_count":40,"open_issues_count":0,"forks_count":10,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-24T04:11:38.788Z","etag":null,"topics":["guard","http-basic-auth","laravel","lumen"],"latest_commit_sha":null,"homepage":"","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/arubacao.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-20T19:14:34.000Z","updated_at":"2022-11-11T09:46:48.000Z","dependencies_parsed_at":"2022-08-21T08:20:49.320Z","dependency_job_id":null,"html_url":"https://github.com/arubacao/http-basic-auth-guard","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arubacao%2Fhttp-basic-auth-guard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arubacao%2Fhttp-basic-auth-guard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arubacao%2Fhttp-basic-auth-guard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arubacao%2Fhttp-basic-auth-guard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arubacao","download_url":"https://codeload.github.com/arubacao/http-basic-auth-guard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221763782,"owners_count":16877039,"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":["guard","http-basic-auth","laravel","lumen"],"created_at":"2024-10-28T02:04:02.132Z","updated_at":"2024-10-28T02:04:02.873Z","avatar_url":"https://github.com/arubacao.png","language":"PHP","readme":"# HTTP Basic Auth Guard\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Total Downloads][ico-downloads]][link-downloads]\n\n\u003e HTTP Basic Auth Guard is a Lumen Package that lets you use `basic` as your driver for the authentication guard in your application.\n\n\u003e The Guard brings back the missing stateless HTTP Basic Authentication possibilities for **Lumen \u003e=5.2**.\n\n## Explanation\nAs of Lumen 5.2 the **session storage** is not included anymore.  \nUnfortunately, for calling `Auth::onceBasic()`, `Auth::basic()`, or [alike](https://github.com/illuminate/auth/blob/v5.2.37/Middleware/AuthenticateWithBasicAuth.php#L38) \nyou'll need the [`session` driver](https://github.com/laravel/laravel/blob/v5.2.31/config/auth.php#L40) which requires the **session storage**.  \n**Therefore HTTP Basic Authentication does not work out-of-the-box anymore for Lumen `\u003e=5.2`.**  \nTo be honest, I have no idea why Taylor Otwell removed this functionality from Lumen 5.2.  \nMy best guess is, that he doesn't even know since my issue got [closed instantly](https://github.com/laravel/lumen-framework/issues/388) on github :smiley:   \nLuckily, this package brings the usual functionality back! \n\n## Requirements\n- Lumen **`5.2`** or **above** Installation.\n- **Note:** For Laravel 5.* or Lumen 5.1 HTTP Basic Auth still works out-of-the-box with the `session` driver: [Link](https://laravel.com/docs/5.2/authentication#stateless-http-basic-authentication).\n\n## Tested with\n- Lumen **`5.2`**, **`5.3`**, **`5.4`**, **`5.5`**, **`5.6`**, **`5.7`**\n- PHP **`5.6`**, **`7.0`**, **`7.1`**, **`7.2`**, **`7.3`**  \n\nCurrent master is for Lumen \u003e= `5.7`.\nFor Lumen \u003c= `5.6` Use version [`^1.0`](https://github.com/arubacao/http-basic-auth-guard/tree/1.0.4). \n\n## Installation\n\n### 1. Pull in package\n\n```bash\n$ composer require arubacao/http-basic-auth-guard\n```\n\n### 2. Read \u0026 Follow Official Lumen Documentation for Authentication\n\n[https://lumen.laravel.com/docs/5.7/authentication](https://lumen.laravel.com/docs/5.7/authentication)\n\n*Important*:\n\u003e Before using Lumen's authentication features, you should uncomment the call to register the `AuthServiceProvider` service provider in your `bootstrap/app.php` file.  \n\n```php\n// bootstrap/app.php\n\n// Uncomment the following line \n $app-\u003eregister(App\\Providers\\AuthServiceProvider::class);\n```\n\n\u003e Of course, any routes you wish to authenticate should be assigned the auth middleware, so you should uncomment the call to $app-\u003erouteMiddleware() in your bootstrap/app.php file:\n\n```php\n// bootstrap/app.php\n\n// Uncomment the following lines\n $app-\u003erouteMiddleware([\n    'auth' =\u003e App\\Http\\Middleware\\Authenticate::class,\n ]);\n```\n\n\u003e If you would like to use `Auth::user()` to access the currently authenticated user, you should uncomment the `$app-\u003ewithFacades()` method in your `bootstrap/app.php` file.\n\n```php\n// bootstrap/app.php\n\n// Uncomment the following lines\n $app-\u003ewithFacades();\n $app-\u003ewithEloquent();\n\n```\n\n### 3. Add the Service Provider\n\nOpen `bootstrap/app.php` and register the service provider:\n\n```php\n// bootstrap/app.php\n\n// Add the following line\n$app-\u003eregister(Arubacao\\BasicAuth\\BasicGuardServiceProvider::class);\n```\n\n### 4. Setup Guard Driver\n\n\u003e **Note:** In Lumen you first have to copy the config file from the directory `vendor/laravel/lumen-framework/config/auth.php`, create a `config` folder in your root folder and finally paste the copied file there.\n\n```bash\n$ mkdir config\n$ cp vendor/laravel/lumen-framework/config/auth.php config/\n```\n\nOpen your `config/auth.php` config file.  \nIn `guards` add a new key of your choice (`api` in this example).  \nAdd `basic` as the driver.  \nMake sure you also set `provider` for the guard to communicate with your database.\n\n```php\n// config/auth.php\n'guards' =\u003e [\n    'api' =\u003e [\n        'driver' =\u003e 'basic',\n        'provider' =\u003e 'users'\n    ],\n\n    // ...\n],\n\n'providers' =\u003e [\n    'users' =\u003e [\n        'driver' =\u003e 'eloquent',\n        'model'  =\u003e App\\User::class,\n    ],\n],\n```\n\n## Usage\nMiddleware protecting the route:\n\n```php\nRoute::get('api/whatever', ['middleware' =\u003e 'auth:api', 'uses' =\u003e 'NiceController@awesome']);\n```\n\nMiddleware protecting the controller:\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nclass NiceController extends Controller\n{\n    public function __construct()\n    {\n        $this-\u003emiddleware('auth:api');\n    }\n}\n```\n\n## Change log\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\nAny issues, feedback, suggestions or questions please use issue tracker [here](https://github.com/arubacao/http-basic-auth-guard/issues).\n\n## Security\nIf you discover any security related issues, please email arubacao@gmail.com instead of using the issue tracker.\n\n## License\nThe MIT License (MIT).\n\n[ico-version]: https://img.shields.io/packagist/v/arubacao/http-basic-auth-guard.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/arubacao/http-basic-auth-guard/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/arubacao/http-basic-auth-guard.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/arubacao/http-basic-auth-guard.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/arubacao/http-basic-auth-guard.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/arubacao/http-basic-auth-guard\n[link-travis]: https://travis-ci.org/arubacao/http-basic-auth-guard\n[link-scrutinizer]: https://scrutinizer-ci.com/g/arubacao/http-basic-auth-guard/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/arubacao/http-basic-auth-guard\n[link-downloads]: https://packagist.org/packages/arubacao/http-basic-auth-guard\n[link-author]: https://github.com/arubacao\n[link-contributors]: ../../contributors\n\n\n[![Analytics](https://ga-beacon.appspot.com/UA-77737156-2/readme?pixel)](https://github.com/arubacao/http-basic-auth-guard)\n","funding_links":[],"categories":["Packages and Middleware"],"sub_categories":["Videos"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farubacao%2Fhttp-basic-auth-guard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farubacao%2Fhttp-basic-auth-guard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farubacao%2Fhttp-basic-auth-guard/lists"}