sitic / auth
具有OAuth、密码重置、电子邮件更改、角色和权限、REST API的用戶
dev-main
2021-09-14 14:36 UTC
Requires
- cviebrock/eloquent-sluggable: ^8.0
- doctrine/dbal: ^3.1
- dusterio/lumen-passport: ^0.3.4
- guzzlehttp/guzzle: ^7.3
- illuminate/mail: ^8.60
- laravel/lumen: 8.x-dev
- laravel/lumen-framework: ^8.0
- spatie/laravel-permission: ^5.1
This package is auto-updated.
Last update: 2024-09-14 21:43:52 UTC
README
此包用于用户管理。它允许执行CRUD用户操作,获取OAuth令牌,更改电子邮件/密码。
LUMEN实现
1. 安装包
composer require sitic/auth
2. 在 bootstrap/app.php 中添加
路由中间件
/* |-------------------------------------------------------------------------- | Register Middleware |-------------------------------------------------------------------------- | | Next, we will register the middleware with the application. These can | be global middleware that run before and after each request into a | route or middleware that'll be assigned to some specific routes. | */ $app->routeMiddleware([ 'auth' => App\Http\Middleware\Authenticate::class, 'permission' => Spatie\Permission\Middlewares\PermissionMiddleware::class, 'role' => Spatie\Permission\Middlewares\RoleMiddleware::class, ]);
服务提供者
/* |-------------------------------------------------------------------------- | Register Service Providers |-------------------------------------------------------------------------- | | Here we will register all of the application's service providers which | are used to bind services into the container. Service providers are | totally optional, so you are not required to uncomment this line. | */ $app->register(\Sitic\Auth\AuthServiceProvider::class);
应用程序路由
/* |-------------------------------------------------------------------------- | Load The Application Routes |-------------------------------------------------------------------------- | | Next we will include the routes file so that they can all be added to | the application. This will provide all of the URLs the application | can respond to, as well as the controllers that may handle them. | */ \Dusterio\LumenPassport\LumenPassport::routes($app, ['prefix' => 'api/v1/oauth']);
4. 安装Auth
php artisan sitic:auth
5. 运行迁移
php artisan migrate
7. 安装passport并将输出放入.env文件
php artisan passport:install
output to .env file
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
PASSPORT_LOGIN_ENDPOINT=/api/v1/oauth/token
PASSPORT_CLIENT_ID=<client_id>
PASSPORT_CLIENT_SECRET=<client_secret>