shabushabu/tightrope

This package is abandoned and no longer maintained. No replacement package was suggested.

Opinionated authentication helper for Laravel Passport

v0.1.6 2020-12-13 14:34 UTC

This package is auto-updated.

Last update: 2022-12-13 18:51:51 UTC


README

Tightrope

PHPUnit Tests GitHub license GitHub license

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

License

The MIT License (MIT). Please see License File for more information.