承接 mostbyte/auth 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

mostbyte/auth

最新稳定版本:4.3.1

Composer 安装命令:

composer require mostbyte/auth

包简介

Mostbyte authorization system from identity service

README 文档

README

Authorization package for Laravel applications using Mostbyte Identity Service.

Requirements

Dependency Version
PHP >= 8.4
Laravel 11.x, 12.x

Version Compatibility

Laravel Version Package Version
< 10.x 2.x
11.x, 12.x 3.x

Installation

Install via Composer:

composer require mostbyte/auth

Or add manually to composer.json:

{
  "require": {
    "mostbyte/auth": "^3.0"
  }
}

Then run:

composer update

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="Mostbyte\Auth\AuthServiceProvider"

Environment Variables

Variable Description Default
IDENTITY_BASE_URL Identity service URL https://auth.mostbyte.uz
LOCAL_DEVELOPMENT Enable mock responses true

Warning Set LOCAL_DEVELOPMENT=false in production. Otherwise, all HTTP requests to the identity service will return fake responses.

Usage

Basic Middleware Usage

use Mostbyte\Auth\Middleware\IdentityAuth;

Route::middleware(IdentityAuth::class)->get('/foo', function () {
    return 'bar';
});

With No-Domain Parameter

use Mostbyte\Auth\Middleware\IdentityAuth;

Route::middleware(IdentityAuth::using('no-domain'))->get('/foo', function () {
    return 'bar';
});

Register as Alias

In bootstrap/app.php (Laravel 11+):

->withMiddleware(function (Middleware $middleware) {
    $middleware->alias([
        'identity' => \Mostbyte\Auth\Middleware\IdentityAuth::class,
    ]);
})

Then use in routes:

Route::middleware('identity')->get('/foo', function () {
    return 'bar';
});

Accessing Authenticated User

// Get authenticated user
$user = auth()->user();

// Access relationships
$company = auth()->user()->company;
$role = auth()->user()->role;

// Get token
$token = auth()->user()->getToken();

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-17