cakephp sessionacl component
DESCRIPTION
CakePHP新春勉強会@東京 LTTRANSCRIPT
![Page 1: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/1.jpg)
ACLを高速化するコンポーネント
Jan 2011
CakePHP新春勉強会@東京from 福岡サテライト
![Page 2: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/2.jpg)
About Me
• WEB Developer / PHP / CakePHP / HTML / CSS / jQuery / MySQL / iPhone / 佐賀 / 福岡 / 島根 / 熊本 / プリン / キイロイトリ / ミッフィー / no more トマト
• BLOG: http://php-tips.com/
• TWITTER: @nojimage
名前: 野島 隆(のじま たかし)所属:イラスティックコンサルタンツ株式会社
![Page 3: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/3.jpg)
ACL Component
![Page 4: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/4.jpg)
Aclは重い
•権限を調べるcheckメソッドでは→Aroの取得→Acoの取得→Permissionの取得計3回のクエリを発行
![Page 5: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/5.jpg)
SessionACL Component
![Page 6: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/6.jpg)
SessionAcl
•http://bakery.cakephp.org/articles/macduy/2010/01/05/acl-caching-using-session
•Mac Duy Hai (macduy)
![Page 7: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/7.jpg)
SessionAcl
•AclComponentの代替えコンポーネント
•check()の結果をセッションにキャッシュ
→ 2回目以降の呼び出しが高速化
![Page 8: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/8.jpg)
How to use?
•bakery記事のコードをsession_acl.phpとしてapp/components/に保存<?phpclass AppController extends Controller {
// ...
// Aclの代わりにSessionAclを指定 public $components = array(‘SessionAcl’);
// ...
![Page 9: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/9.jpg)
wait!
•本当にAclComponent互換?
![Page 10: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/10.jpg)
wait!
•CakePHP1.3.6のAclComponent
のテストを走らせてみた
![Page 11: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/11.jpg)
wait!
•CakePHP1.3.6のAclComponent
のテストを走らせてみた→ いくつかのテストが失敗
![Page 12: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/12.jpg)
fixed!
•修正しましたhttps://gist.github.com/779479
![Page 13: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/13.jpg)
Attention!!
•セッションに権限情報を格納するのでログアウトするまでACLの変更が反映されない
![Page 14: CakePHP SessionAcl Component](https://reader034.vdocuments.mx/reader034/viewer/2022052619/555a8995d8b42abb628b50ad/html5/thumbnails/14.jpg)
ご静聴ありがとうございました