Download the PHP package elzdave/benevolent without Composer
On this page you can find all versions of the php package elzdave/benevolent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download elzdave/benevolent
More information about elzdave/benevolent
Files in elzdave/benevolent
Package benevolent
Short Description A custom user provider to authenticate users to REST API within Laravel framework.
License MIT
Homepage https://github.com/elzdave/benevolent
Informations about the package benevolent
Benevolent
Use Case
Imagine you built a Laravel-powered website, which needs to communicates to your external API server using REST API. Some of the HTTP requests needs to be authenticated by including access token to the Authorization header. To get the access token, you first authenticate the user to the API server, and then the server return the access token and user data in exchange. You store the access token to use it on every authenticated HTTP requests. All is well until you realize, that default Laravel authentication middleware cannot authenticate user to another server leveraging REST API, and you need to write new authentication logics to cover those requirements...
That's why this package exist. Just install this package, set the config, and you all done!
Installation
Laravel
Require this package in the project.
Publish the config after installation.
Usage
User Authentication
- At the
config/auth.php
, change theprovider
entry onguards.web
tobenevolent
-
Add the new entry on
.env
and.env.example
, change<your-external-API-base-URI>
to your authentication server's base URI, eg: https://server.api/v1 - Optional: adjust some settings to suit your API server design at
config/benevolent.php
Making Authenticated HTTP Request using Authorization header
If you want to make authenticated HTTP requests using the user's access token, use the Elzdave\Benevolent\Http\Http
facade with useAuth()
method
Change log
Please see the changelog for more information on what has changed recently.
Testing
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email the author instead of using the issue tracker.
Credits
- David Eleazar
- All contributors
License
MIT. Please see the license file for more information.