Skip to content
Easily add login proxy to your Laravel API
Branch: master
Clone or download
Latest commit 2769109 Mar 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
src fixed typo Mar 11, 2019
tests Add basic tests Mar 12, 2019
.gitignore
.scrutinizer.yml Upgrade PHP analysis engine for Scrutinizer Mar 6, 2019
.styleci.yml Init Mar 4, 2019
.travis.yml
CHANGELOG.md Update changelog Mar 7, 2019
LICENSE.md Init Mar 4, 2019
README.md
composer.json
phpunit.xml.dist

README.md

Easily add login proxy to your Laravel API

Latest Version on Packagist Build Status StyleCI Quality Score Total Downloads

The signifly/laravel-janitor package allows you to easily add a login proxy to your Laravel API.

Documentation

To get started you have to either install laravel/passport or tymon/jwt-auth. Please refer to their documentation for how to configure those packages.

NOTE: For now the supported versions for tymon/jwt-auth is 1.0.0-rc.*.

Installation

You can install the package via composer:

$ composer require signifly/laravel-janitor

The package will automatically register itself.

You can optionally publish the config file with:

$ php artisan vendor:publish --tag="janitor-config"

After pulling in the package and (optionally) publishing the config, then add the routes to your routes/api.php file:

Janitor::routes();

It will by default add routes for the following:

  • login by username and password (/login)
  • refresh current user access token (/login/refresh)
  • log the user out (/logout)
  • send password reset email (/password/email)
  • reset password (/password/reset)

You can also define a specific set of routes by passing a Closure:

Janitor::routes(function ($router) {
    // Login and logout routes
    $router->forAuthentication();

    // Password reset routes
    $router->forPasswordReset();
});

Finally, add JANITOR_DRIVER=driver-name to your .env file.

NOTE: It does not support a default driver and throws an InvalidArgumentException if omitted.

Resetting passwords

In order to use the reset password implementation in an API, you have to add a custom reset password notification to your user model.

// App\User.php

/**
 * Send the password reset notification.
 *
 * @param  string  $token
 * @return void
 */
public function sendPasswordResetNotification($token)
{
    $this->notify(new ResetPasswordNotification($token));
}

The notification should format a correct link to your client app's reset password url.

Testing

$ composer test

Security

If you discover any security issues, please email dev@signifly.com instead of using the issue tracker.

Credits

License

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

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.