国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

鑒權(quán)數(shù)據(jù)限制bug反饋

掌柜

問(wèn)題描述

通過(guò)創(chuàng)建一個(gè)小程序表,添加字段admin_id,
admin添加兩個(gè)管理員,權(quán)限都為超級(jí)管理員的下級(jí)管理員。
新建小程序數(shù)據(jù),分別為用戶名admin 和 admin2各添加了兩個(gè)小程序
數(shù)據(jù)限制模式為auth,則admin和admin2可以互相看到對(duì)方同級(jí)數(shù)據(jù),并不是只看到自己的和下級(jí)的。
數(shù)據(jù)限制模式為personal,則admin和admin2只可以看到自己

crud類里面的auth限制里面為獲取權(quán)限范圍內(nèi)所有管理員ID

程序代碼或配置

  • AppletController

    /**
     * 開(kāi)啟auth數(shù)據(jù)限制
     * @var string
     */
    protected $dataLimit = 'personal';
    
    /**
     * 以admin_id為數(shù)據(jù)限制字段
     * @var string
     */
    protected $dataLimitField = 'admin_id';
  • CRUD

    /**
     * 查詢前置
     * @param Request $request
     * @return array
     * @throws BusinessException
     */
    protected function selectInput(Request $request): array
    {
        $field = $request->get('field');
        $order = $request->get('order', 'asc');
        $format = $request->get('format', 'normal');
        $limit = (int)$request->get('limit', $format === 'tree' ? 1000 : 10);
        $limit = $limit <= 0 ? 10 : $limit;
        $order = $order === 'asc' ? 'asc' : 'desc';
        $where = $request->get();
        $page = (int)$request->get('page');
        $page = $page > 0 ? $page : 1;
        $table = config('plugin.admin.database.connections.mysql.prefix') . $this->model->getTable();
    
        $allow_column = Util::db()->select("desc `$table`");
        if (!$allow_column) {
            throw new BusinessException('表不存在');
        }
        $allow_column = array_column($allow_column, 'Field', 'Field');
        if (!in_array($field, $allow_column)) {
            $field = null;
        }
        foreach ($where as $column => $value) {
            if (
                $value === '' || !isset($allow_column[$column]) ||
                is_array($value) && (empty($value) || !in_array($value[0], ['null', 'not null']) && !isset($value[1]))
            ) {
                unset($where[$column]);
            }
        }
        // 按照數(shù)據(jù)限制字段返回?cái)?shù)據(jù)
        if ($this->dataLimit === 'personal') {
            $where[$this->dataLimitField] = admin_id();
        } elseif ($this->dataLimit === 'auth') {
            $primary_key = $this->model->getKeyName();
            if (!Auth::isSupperAdmin() && (!isset($where[$primary_key]) || $this->dataLimitField != $primary_key)) {
                $where[$this->dataLimitField] = ['in', Auth::getScopeAdminIds(true)];
            }
        }
        return [$where, $format, $limit, $field, $order, $page];
    }

重現(xiàn)問(wèn)題的步驟

修改數(shù)據(jù)限制模式 無(wú)痕窗口登陸 兩個(gè)管理員賬號(hào)

操作系統(tǒng)環(huán)境及workerman/webman等具體版本

Mac系統(tǒng) 環(huán)境為PHP8.2.10

目前項(xiàng)目沒(méi)那么多級(jí),就簡(jiǎn)單重寫了下Crud這一段

如果是超級(jí)管理員就返回所有的,不是就只返回自己的。
權(quán)限這塊沒(méi)做判斷。

 // 按照數(shù)據(jù)限制字段返回?cái)?shù)據(jù)
        if ($this->dataLimit === 'personal') {
            $where[$this->dataLimitField] = admin_id();
        } elseif ($this->dataLimit === 'auth') {
            if (Auth::isSupperAdmin()) {
                $where[$this->dataLimitField] = ['in', Auth::getScopeAdminIds(true)];
            } else {
                $where[$this->dataLimitField] = admin_id();
            }
            // $primary_key = $this->model->getKeyName();
            // if (!Auth::isSupperAdmin() && (!isset($where[$primary_key]) || $this->dataLimitField != $primary_key)) {
            //     $where[$this->dataLimitField] = ['in', Auth::getScopeAdminIds(true)];
            // }
        }
        return [$where, $format, $limit, $field, $order, $page];
1141 1 0
1個(gè)回答

walkor 打賞

感謝反饋,admin后臺(tái)插件管理里升級(jí)下admin試下

  • 掌柜 2023-11-21

    響應(yīng)速度是真快啊大哥,剛反饋沒(méi)多久就更新了!

年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??