定制 amin3536/laravel-api-user-provider 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

amin3536/laravel-api-user-provider

Composer 安装命令:

composer require amin3536/laravel-api-user-provider

包简介

this package help you to provide your user from different service ( useful in micro service specially )

README 文档

README

Latest Version on Packagist Total Downloads tests workflow StyleCI

this pack help you to provide your user from different service ( useful in micro service )

how this package work

this package use bearer token in header's request and provide user from Sec Service (Auth service)

Installation

Via Composer

$ composer require amin3536/laravel-api-user-provider

Usage

simple usage this driver : change your auth.php in config like below

<?php

return [
    
        //.......
    /*
    |--------------------------------------------------------------------------
    | Authentication Guards
    |--------------------------------------------------------------------------
    */
    'guards' => [
        'web' => [
            'driver' => 'session',
            'provider' => 'users',
        ],

        'api' => [
            'driver' => 'api-token',
            'provider' => 'users',
        ],

        'admin-api' => [
            'driver' => 'api-token',
            'provider' => 'admins',
        ],
    ],

    /*
    |--------------------------------------------------------------------------
    | User Providers
    |--------------------------------------------------------------------------
    |
    */

    'providers' => [
        'users' => [
            'driver' => 'api-provider',
            'model' => App\Models\User::class,
           //merged with base_url or you can use full path api here  =>http://localhost/api/admin/
            'url' => '/api/v1/user/'
        ],
        'admins' => [
            'driver' => 'api-provider',
            'model' => App\Models\Admin::class,
            'url' => '/api/v1/admin/'
        ],
    ],
     /*
        |--------------------------------------------------------------------------
        | Base url path to to call Auth Service 
        |--------------------------------------------------------------------------
        |
        */
        'base-url'=>'localhost',
        'TimeoutForRequestAuthServer'=>2
    //.......
];

advance

if you want use custom Deserializer class ,the class must be implement DeserializerInterface and add below code in boot method of AuthServiceProvider .

<?php
    //...
    public function boot()
    {

        $this->app->when(ExternalUserProvider::class)
            ->needs(DeserializerInterface::class)
            ->give(function () {
                return new JsonToModel();
            });
    }
    

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.

统计信息

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

GitHub 信息

  • Stars: 11
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固