承接 desmart/jwt-auth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

desmart/jwt-auth

Composer 安装命令:

composer require desmart/jwt-auth

包简介

Simple JWT auth implementation for Laravel.

README 文档

README

Simple JWT auth implementation for Laravel.

Installation

Install package using Composer:

composer require desmart/jwt-auth

Register the package's service provider in config/app.php:

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

Configuration

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

php artisan vendor:publish

The config file allows you to change some options. Be sure to check it out.

Usage

The package allows to:

  1. Authenticate a user,
  2. Verify if the user is authenticated using route middleware.

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.

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

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.

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

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

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

统计信息

  • 总下载量: 2.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-11-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固