承接 daydiff/yii2-auth-chain 相关项目开发

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

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

daydiff/yii2-auth-chain

Composer 安装命令:

composer require daydiff/yii2-auth-chain

包简介

Yii2 authorization chain

README 文档

README

Latest Version on Packagist Software License Build Status

What is it for?

For applications with hierarhical access roles system.

Any examples? It's not clear

You have an application - API. You have two roles here:

  • admin - they can watch statistics and edit clients;
  • client - they can see own statistics and set settings.

You need to allow admins to authorize as clients without knowing their passwords just from admin interface. And you need to allow admins to get back to their own privilegis/account without re-logining. And of course you need to log all changes made by admins as clients properly, so you always knew who actually made some changes.

Install

$ composer require daydiff/yii2-auth-chain

Usage

Register application component:

'components' => [
    'authChain' => [
        'class' => 'Daydiff\AuthChain\Service'
    ],
]

You need to declare a member class implementing \Daydiff\AuthChain\MemberInterface

//Member.php
namespace app\foo\bar;

class Member implements \Daydiff\AuthChain\MemberInterface
{
    private $id;
    private $login;

    /**
     * @inheritdoc
     */
    function getId()
    {
        return $this->id;
    }

    /**
     * @inheritdoc
     */
    function getLogin()
    {
        return $this->login;
    }

    /**
     * @inheritdoc
     */
    function setId($id)
    {
        $this->id = $id;
        return $this;
    }

    /**
     * @inheritdoc
     */
    function setLogin($login)
    {
        $this->login = $login;
        return $this;
    }
}

In your action used to authorize as client:

public function actionAuthAs($id)
{
    $user = \Yii::$app->getIdentity()->getUser();
    $member = new app\foo\bar\Member();
    $member->setId($user->id)
        ->setLogin($user->login);
    \Yii::$app->authChain->push($member);

    //and then you do authorization work
}

When you need to know who user actually is:

$member = \Yii::$app->authChain->last();
$realUserId = $member->getId();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-06-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固