承接 moeen-basra/laravel-passport-otp-grant 相关项目开发

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

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

moeen-basra/laravel-passport-otp-grant

最新稳定版本:v1.1.0

Composer 安装命令:

composer require moeen-basra/laravel-passport-otp-grant

包简介

Laravel Passport One Time Pin Grant

README 文档

README

This is a small package for laravel passport otp authentication easy to integrate.

How to

Following are a few steps you need to follow to make it work.

  1. Install this package using the composer
composer require moeen-basra/laravel-passport-otp-grant
  1. Implement the MoeenBasra\OneTimePinGrant\Interfaces\OneTimePinGrantUserInterface on your desired provider model.
use Illuminate\Foundation\Auth\User as BaseUser;
use MoeenBasra\OneTimePinGrant\Interfaces\OneTimePinGrantUserInterface;

class User extends BaseUser implements OneTimePinGrantUserInterface
{
    //...
    
    /**
     * {@inheritDoc}
     */
    public function findAndValidateForPassportOtpGrant(string $mobile_number, string $code)
    {
        if (!OneTimePin::validate($mobile_number, $code)) {
            return null;
        }
        
        return static::firstOrCreate([
            'mobile_number' => $mobile_number
        ]);
    }
}
  1. This step is optional, add the service provider under the providers array in config/app.php.
   'providers' => [
        //...
        MoeenBasra\OneTimePinGrant\OneTimePinGrantServiceProvider::class,
    ]

That's it now you can call the otp login using same params you use for other passport end points

curl --location --request POST 'https://api.example.com/oauth/token' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--form 'username="mobile_number"' \
--form 'password="code"' \
--form 'grant_type="otp"' \
--form 'client_id="client_id"' \
--form 'client_secret="client_secret"' \
--form 'scope="*"'

More

You can check out the Laravel Passport official documentation for more details.

Contributions

You are welcome, you can create a pull request. You will be credited for any contribution.

Issues

If you are facing any problem feel free to report here.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-01-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固