bushart/apiauthentication 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

bushart/apiauthentication

最新稳定版本:1.0.5

Composer 安装命令:

composer require bushart/apiauthentication

包简介

A simple modified api authentication

README 文档

README

This is a Laravel package that provides easy-to-use API authentication using Laravel Passport. The package comes with pre-built controllers, middleware, and routes for registering users, authenticating users, and send opt on mail and phone number.

Features

  • Register new users
  • Authenticate existing users
  • Pre-built controllers, and routes for easy integration into your Laravel application
  • Send otp on mail and phone number

Installation package

To install the package, run the following command:

composer require bushart/apiauthentication

Install Laravel Passport

composer require laravel/passport

Next, you should execute the passport:install Artisan command

php artisan passport:install

Finally, in your application's config/auth.php configuration file, you should define an api authentication guard and set the driver option to passport. This will instruct your application to use Passport's TokenGuard when authenticating incoming API requests:

'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',
    ],
 
    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],

For more information please visit the link: Laravel Passport

Config file

  1. Add the service provider to app/config/app.php
bushart\productmanagement\ApiAuthenticationServiceProvider::class,

Step 2: Setup Database Configuration

After successfully installing the laravel app then after configuring the database setup. We will open the ".env" file and change the database name, username and password in the env file.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=Enter_Your_Database_Name
DB_USERNAME=Enter_Your_Database_Username
DB_PASSWORD=Enter_Your_Database_Password

Now, run migration with following command:

php artisan migrate

Configure sender mail address in laravel .env file

.env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=TLS

Create Twilio Account

First you need to create and add phone number. then you can easily get account SID, Token and Number.

Create Account from here: www.twilio.com.

Next add Twilio Phone Number

Next you can get account SID, Token and Number and add these in the .env file like bellow:

.env

TWILIO_ACCOUNT_SID=XXXXXXXXXXXXXXXXX
TWILIO_AUTH_TOKEN=XXXXXXXXXXXXX
TWILIO_NUMBER=+XXXXXXXXXXX

Usage

The package comes with pre-built controllers, and routes for registering users, authenticating users. To use these features, simply include the package's routes in your Laravel application's routes/api.php file:

You can then make API requests to the following endpoints:

  • /api/register: Register a new user
  • /api/login: Authenticate an existing user and retrieve an access token
  • /api/sendOtpEmail: send otp on mail
  • /api/sendOtpPhoneNumber: send otp on phone number
  • /api/verifyOtp: Verify otp

Note

Please add Accept:application/json in headers

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-11