shabushabu / tightrope
Opinionated authentication helper for Laravel Passport
Fund package maintenance!
boris-glumpler
paypal.me/BorisGlumpler
Requires
- php: ^7.4
- ext-json: *
- illuminate/auth: ^7.0
- illuminate/hashing: ^7.0
- illuminate/http: ^7.0
- illuminate/support: ^7.0
- illuminate/validation: ^7.0
- laravel/passport: ^9.2
- psr/http-message: ^1.0
- symfony/http-foundation: ^5.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- nunomaduro/collision: ^4.2
- orchestra/testbench: ^5.0
- phpunit/phpunit: ^9.0
- symfony/var-dumper: ^5.0
This package is auto-updated.
Last update: 2022-12-13 18:51:51 UTC
README
Tightrope
Opinionated authentication helper for Laravel Passport.
Tightrope will give you all the authentication routes you might need for your API.
ToDo
- Add tests
- Ensure that events aren't being fired twice
- Pull email verification from BTTs
- Add config descriptions
- Journey to the center of Mars s
Installation
You can install the package via composer (‼️ at least once it has been published to Packagist...):
$ composer require shabushabu/tightrope
To make full use of Tightrope, some setup in the boot
method of your AppServiceProvider
is required:
Tightrope::routes(); Tightrope::registerUserUsing(function (Request $request) { // do your registration thing here, like // validation, saving the user, etc });
If you have something special that needs to happen when a user logs out, then use the Tightrope::logUserOutUsing
method:
Tightrope::logUserOutUsing(function (Request $request) { // do something with $request->user() });
Usage
Nothing more really needs to be done, apart from the above, but there are some areas that can be configured.
Routes
By default the following non-authenticated routes are registered:
POST /register
POST /login
POST /password/request
POST /password/resend
Additionally, the following authenticated routes are present:
GET /email/verify/{id}
POST /email/resend
POST /logout
The Tightrope::routes
method does accept a closure that you can use to modify the above routes.
The second argument accepts a options array, that is passed directly to the route group, so you could, for example, add a prefix.
Requests
Tightrope comes with two form requests, that you can override via the config:
ShabuShabu\Tightrope\Http\Requests\EmailPasswordRequest; ShabuShabu\Tightrope\Http\Requests\ResetPasswordRequest;
Events
Tightrope fires the following Laravel events:
Illuminate\Auth\Events\PasswordReset; Illuminate\Auth\Events\Attempting; Illuminate\Auth\Events\Registered; Illuminate\Auth\Events\Verified; Illuminate\Auth\Events\Logout; Illuminate\Auth\Events\Login;
Testing
Tests will be extracted from the original project in due time.
$ composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email boris@shabushabu.eu instead of using the issue tracker.
‼️ Caveats
Tightrope is still young and while it is tested, there will probs be bugs. I will try to iron them out as I find them, but until there's a v1 release, expect things to go 💥.
Credits
- All Contributors
- BTT, aka Boris Travelled Today, where Tightrope was extracted from
- Ivan Boyko [cc] for the tightrope icon
License
The MIT License (MIT). Please see License File for more information.