0

私の製品テーブル:

select * from products;
+------+----------------+
| id   | name           |
+------+----------------+
|    1 | product XYZ    |
|    2 | product XPTO   |
|    3 | procudt ABC    |
|    4 | procudt QWERTY |
|    5 | procudt 1234   |
+------+----------------+

次のように、一部のユーザー グループにモデル「製品」へのアクセスを許可/拒否できます。

$group->id = 3;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'controllers/Products');

$group->id = 4;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'controllers/Products/view');

ただし、次のような特定の製品へのアクセスをグループに許可/拒否する方法は次のとおりです。

$group->id = 5;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'product XYZ');

$group->id = 6;
$this->Acl->deny($group, 'controllers');
$this->Acl->allow($group, 'product XPTO');
$this->Acl->allow($group, 'product 1234');

?

4

1 に答える 1

1

行レベルのアクセス制御が必要です。CakePHP にはいくつかの方法があります (Cake の ACL 機能を使用する方法と使用しない方法があります)

ただし、覚えておくべきことの 1 つは、Cake のすぐに使用できる ACL 機能は、特定のデータベース行ではなく、コントローラー アクションに対するアクセス制御を実装するために設計されたということです。チェックする必要があるデータの量によっては、すぐに手に負えなくなる可能性があります。レコード レベルでのアクセスを本当にチェックする必要があるかどうかを確認するために、設計を再検討することをお勧めします。

于 2012-12-23T04:11:13.943 に答える