impact-factoring/accounts-user-provider 问题修复 & 功能扩展

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

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

impact-factoring/accounts-user-provider

最新稳定版本:1.0.22

Composer 安装命令:

composer require impact-factoring/accounts-user-provider

包简介

A Laravel User provider for Impact Factoring Accounts

README 文档

README

This package provides a Laravel user provider that integrates with Impact Factoring Accounts, allowing you to authenticate and manage users directly from the Accounts Server.

Quick Start

  1. composer require impact-factoring/accounts-user-provider
  2. php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
  3. php artisan migrate
  4. Update auth.php and User.php (see below)
  5. Add IMPACT_FACTORING_ACCOUNTS_BASE_URL to .env

Requirements:

  • Laravel 11+
  • php 8.2+

Installation:

Install the package using Composer:

composer require impact-factoring/accounts-user-provider

After package installation, run the following commands:

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider"
php artisan migrate

Configuration

Once migration is done, update the following files:

auth.php:

Change the user provider driver from 'eloquent' to 'impact-factoring-accounts-user-provider':

'providers' => [
    'users' => [
        'driver' => 'impact-factoring-accounts-user-provider',
        'model' => App\Models\User::class,
    ],
],

User.php:

Extend your local User model with the User model from the package:

use ImpactFactoring\Accounts\Models\User as Authenticatable;

Remove $hidden property from your local User model, to ensure all user attributes from Accounts are accessible.

.env:

Add the following environment variable:

IMPACT_FACTORING_ACCOUNTS_BASE_URL=<your_base_url_here>

Set this variable to where your local Accounts server is hosted. For example: http://localhost:8081.

Authentication routes

This package contains two authentication routes:

  • POST '/login' -> Process login request
  • POST '/logout' -> Process logout request (route name: 'logout')

You are free to use whatever frontend you desire, but processing needs to be done by these two routes.

So, make sure you don't have any routes that may be in conflict with these two.

Middleware

This package registers a middleware with the alias `accounts.auth` This middleware ensures the user is authenticated via Accounts.

You can use this middleware on your own routes.

Example:

Route::get('/', [HomeController::class, 'index'])->middleware('accounts.auth')

Scheduled Command

The package automatically registers a command that will synchronize roles and permissions from Accounts. This command will run every hour. You can also manually start this command:

php artisan accounts:sync-roles-and-permissions

Development

This package contains a Docker Compose file. Use the following Composer scripts to run and debug in an isolated environment

Usage

Initial composer install

composer docker-install

To test the package (powered by: Orchestra Testbench)

composer test

Run a debug container

composer debug

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固