bonsaicms/auth
Composer 安装命令:
composer require bonsaicms/auth
包简介
Bonsai CMS backend auth package
关键字:
README 文档
README
This package is a part of Bonsai CMS.
Introduction
This package is a server-side (frontend agnostic) authentication backend for Laravel. It's designed to be used in a combination with an SPA (Single-Page-Application) frontend. It uses these Laravel packages under the hood:
Installation Steps
1. Install the package
$ composer require bonsaicms/auth
2. Update your .env file
Add the following lines to your .env file.
APP_PROTOCOL=http APP_DOMAIN="localhost:8080" APP_URL=${APP_PROTOCOL}://${APP_DOMAIN} SANCTUM_STATEFUL_DOMAINS=${APP_DOMAIN}
3. Publish package resources
$ php artisan vendor:publish --provider="BonsaiCms\Providers\AuthServiceProvider"
4. Register service provider
In your config/app.php file, add the following service provider class in the providers array.
'providers' => [ ... + App\Providers\BonsaiAuthServiceProvider::class, ]
5. Update your HTTP Kernel
Add the following lines to your App\Http\Kernel.php file.
protected $middlewareGroups = [ ... 'api' => [ + \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 'throttle:api', \Illuminate\Routing\Middleware\SubstituteBindings::class, ], + + 'fortify' => [ + \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, + \Illuminate\Routing\Middleware\SubstituteBindings::class, + ], ];
6. Update your User model
Update your app/Models/User.php model.
Your model should implement our interface BonsaiCms\Auth\AuthenticatableContract.
Your model should use our trait BonsaiCms\Auth\AuthenticatableTrait.
<?php namespace App\Models; + use Illuminate\Database\Eloquent\Model; + use BonsaiCms\Auth\AuthenticatableTrait; + use BonsaiCms\Auth\AuthenticatableContract; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Factories\HasFactory; - use Illuminate\Foundation\Auth\User as Authenticatable; - use Illuminate\Notifications\Notifiable; - class User extends Authenticatable + class User extends Model implements AuthenticatableContract { - use HasFactory, Notifiable; + use HasFactory, AuthenticatableTrait;
7. Run migrations
$ php artisan migrate
统计信息
- 总下载量: 50
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-30