Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/larvatecn/laravel-passport-miniprogram
Mini Program Extension for Laravel.
https://github.com/larvatecn/laravel-passport-miniprogram
laravel
Last synced: 12 days ago
JSON representation
Mini Program Extension for Laravel.
- Host: GitHub
- URL: https://github.com/larvatecn/laravel-passport-miniprogram
- Owner: larvatecn
- License: mit
- Created: 2021-04-28T05:05:54.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-01-14T06:01:30.000Z (almost 3 years ago)
- Last Synced: 2024-04-20T08:46:22.648Z (8 months ago)
- Topics: laravel
- Language: PHP
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# laravel-passport-miniprogram
扩展Laravel Passport,支持小程序登录;
## 环境需求
- PHP >= 7.3
## Installation
```bash
composer require larva/laravel-passport-miniprogram -vv
```## 使用
在你的User模型类实现 `findAndValidateForPassportMiniProgram` 方法接收小程序提交的登录信息。
## 原理说明
验证用户登录,使用的是小程序内部的 auth.code2Session 获取到的 session_key 作为验证,服务器验证 session_key 和 openid ,则认为提交的 user_info 参数是可信的。
将会执行后续过程。你需要自行实现 findAndValidateForPassportMiniProgram 方法自己实现验证 session_key 的代码。## Usage
### Step 1 - Setting up the User model
On your `User` model and then add method `findAndValidateForPassportMiniProgram`.
`findAndValidateForPassportMiniProgram````php
namespace App;class User extends Authenticatable {
use HasApiTokens, Notifiable;/**
* Find user using social provider's user
*
* @param \Illuminate\Http\Request $request
*
* @return User|null|void
*/
public static function findAndValidateForPassportMiniProgram($request) {
}
}
```| id | provider | social_id | user_id | created_at | updated_at |
|-----|----------|----------------|---------|-------------------|-------------------|
| 1 | facebook | XXXXXXXXXXXXXX | 1 | XX-XX-XX XX:XX:XX | XX-XX-XX XX:XX:XX |
| 2 | github | XXXXXXXXXXXXXX | 2 | XX-XX-XX XX:XX:XX | XX-XX-XX XX:XX:XX |
| 3 | google | XXXXXXXXXXXXXX | 3 | XX-XX-XX XX:XX:XX | XX-XX-XX XX:XX:XX |**That's all folks**