承接 onix-systems-php/hyperf-impersonate 相关项目开发

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

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

onix-systems-php/hyperf-impersonate

最新稳定版本:v1.0.0

Composer 安装命令:

composer require onix-systems-php/hyperf-impersonate

包简介

Hyperf Impersonate is a plugin that allows to you to authenticate as your users

关键字:

README 文档

README

Includes the following classes:

  • Contract:
    • Impersonatable;
  • Controller:
    • ImpersonateController;
  • DTO:
    • ImpersonateInfoDTO;
    • ImpersonateLeaveDTO;
    • ImpersonateTakeDTO;
  • Event:
    • LeaveImpersonation
    • TakeImpersonation
  • Exception:
    • AlreadyImpersonatingException;
    • CantBeImpersonatedException;
    • CantImpersonateException;
    • CantImpersonateSelfException;
    • NotImpersonatingException;
    • ProtectedAgainstImpersonationException;
  • Middleware:
    • ProtectFromImpersonation;
  • Resource:
    • ResourceInfoImpersonate;
    • ResourceLeaveImpersonate;
    • ResourceTakeImpersonate;
  • Service:
    • ImpersonateService;
  • Trait
    • Impersonatable

Install:

composer require onix-systems-php/hyperf-impersonate

Publish config:

php bin/hyperf.php vendor:publish onix-systems-php/hyperf-impersonate -i config

Publish translations:

php bin/hyperf.php vendor:publish onix-systems-php/hyperf-impersonate -i en_us_translation
php bin/hyperf.php vendor:publish onix-systems-php/hyperf-impersonate -i ua_uk_translation

Import impersonate routes:

require_once './vendor/onix-systems-php/hyperf-auth/publish/routes.php';

Add line to config/autoload/swagger.php for swagger:

'vendor/onix-systems-php/hyperf-impersonate/src/',

Basic Usage

use OnixSystemsPHP\HyperfImpersonate\Contract\Impersonatable as ImpersonatableInterface;
use OnixSystemsPHP\HyperfImpersonate\Trait\Impersonatable;

class User extends ... implements ImpersonatableInterface
{
    use Impersonatable;
}

Advanced Usage

Defining impersonation authorization

By default all users can impersonate an user. You need to add the method canImpersonate() to your user model:

public function canImpersonate(): bool
{
    return in_array($this->getRole(), UserRoles::GROUP_ADMINS);
}

By default all users can be impersonated. You need to add the method canBeImpersonated() to your user model to extend this behavior:

public function canBeImpersonated(): bool
{
    return in_array($this->getRole(), UserRoles::GROUP_USERS);
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-16