CakePHP 1.2 の ACL: 初期設定

コマンドに関するざっくり説明。

http://aranworld.com/article/162/cakephp-acl-tutorial-initial-setup

管理用テーブルの作成。

ACL 管理用のテーブルを作成する。app ディレクトリ上で、以下を実行。

 cake schema run create DbAcl

ARO や ACO 管理コマンドのヘルプを表示。

 cake acl help

ARO を作成してみる。

 cake acl create aro root guests
 cake acl create aro guests users
 cake acl create aro users admins

ACO を作成してみる。

 cake acl create aco root site
 cake acl create aco site Articles
 cake acl create aco site Recipes
 cake acl create aco site Lists

ARO と ACO を紐付けてみる。

 cake acl grant admins '*'
 cake acl grant users Articles read
 cake acl grant users Recipes read
 cake acl grant users Recipes update

PostgreSQL だと、aros_acos テーブルにレコード追加時にエラーが発生したが、
一応出来てるみたい。RC2のバグ?

Warning: pg_query(): Query failed: ERROR:  relation "public" does not exist in 
/home/okinaka/public_html/cake/libs/model/datasources/dbo/dbo_postgres.php on line 152

Warning: <span style = "color:Red;text-align:left">
<b>SQL Error:</b> ERROR:  relation "public" does not exist</span>
 in /home/okinaka/public_html/cake/libs/model/datasources/dbo_source.php on line 512
<p style = "text-align:left"><b>Query:</b> SELECT currval('public') as max </p>

設定の確認

コマンドラインで設定を確認してみる。

 $ cake acl check users Recipes read
users is allowed.
 $ cake acl check users Recipes delete
users is not allowed.
 $ cake acl check admins Lists create
admins is allowed.