2017 © Pedro Peláez
 

library jwt-auth

Simple JWT auth implementation for Laravel.

image

desmart/jwt-auth

Simple JWT auth implementation for Laravel.

  • Friday, November 24, 2017
  • by DeSmart
  • Repository
  • 4 Watchers
  • 0 Stars
  • 2,017 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Laravel JWT Auth

Simple JWT auth implementation for Laravel., (*1)


Installation

Install package using Composer:, (*2)

composer require desmart/jwt-auth

Register the package's service provider in config/app.php:, (*3)

'providers' => [
        (...)
        DeSmart\JWTAuth\ServiceProvider::class,
    ],

Configuration

The package comes with a config file. In order to publish it, run the following command:, (*4)

php artisan vendor:publish

The config file allows you to change some options. Be sure to check it out., (*5)

Usage

The package allows to: 1. Authenticate a user, 2. Verify if the user is authenticated using route middleware., (*6)

User authentication

First, add the TokenRefreshMiddleware as a global middleware or to a middleware group (app/Http/Kernel.php). It will add the Authorization header to the response. This header will contain the JWT token, after successful authentication., (*7)

Then, inject \DeSmart\JWTAuth\Auth\Guard into your auth class and authenticate the user (credentials validation is up to you)., (*8)

public function authenticateUser(\DeSmart\JWTAuth\Auth\Guard $auth, $user) {
    if (true === $this->validateCredentails($user)) {
        $auth->loginUser($user);
    }
}

Token verification

Once a user has been authenticated, each request to your application should contain the Authorization header with the token obtained after succesful authentication., (*9)

Add AuthMiddleware to the your $routeMiddleware array (app/Http/Kernel.php):, (*10)

protected $routeMiddleware = [
        (...)
        'auth' => \DeSmart\JWTAuth\Middleware\AuthMiddleware::class,
    ];

Now, simply use the auth route middleware to check if a user is authenticated., (*11)

The Versions

24/11 2017

dev-master

9999999-dev

Simple JWT auth implementation for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kamil Fojuth

24/11 2017

1.0.4

1.0.4.0

Simple JWT auth implementation for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kamil Fojuth

26/04 2017

1.0.3

1.0.3.0

Simple JWT auth implementation for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kamil Fojuth

26/04 2017

1.0.2

1.0.2.0

Simple JWT auth implementation for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kamil Fojuth

27/03 2017

1.0.1

1.0.1.0

Simple JWT auth implementation for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kamil Fojuth

14/02 2017

1.0.0

1.0.0.0

Simple JWT auth implementation for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kamil Fojuth

14/01 2017

0.2.1

0.2.1.0

Simple JWT auth implementation for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kamil Fojuth

05/01 2017

0.2.0

0.2.0.0

Simple JWT auth implementation for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kamil Fojuth

12/11 2016

0.1.0

0.1.0.0

Simple JWT auth implementation for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kamil Fojuth