requireAuthã§CSRF対ç
主ã«CSRF対çç®çã§ãSecurityã³ã³ãã¼ãã³ãã®requireAuthãã§ãã¯ãå°å ¥ãã¾ããã
åºæ¬ã®å°å ¥ã¯ã§ãã¾ãããã対çããæ¹ããããããªæ¸å¿µããæ¹åãããç¹ãããã
å®è£
ã¯ã以ä¸ãåèã«ãã¾ããã
CakePHPでCSRF対策 - Shin x blog
éã
- ãã¥ã¼ãã¡ã¤ã«ã¸ã®Tokenåãè¾¼ã¿
ver.1.2.5ã§ã¯ã$form->create()ããã³$form->end()ãèªåã§è¡ãªã£ã¦ããã¾ãã
ã¨ãããããã®2ã¤ã使ããªãã¨ã¨ã©ã¼ã«ãªãã¾ããç¹ã«$form->end();ã
$form->end();ãçºè¡ããfieldãã¼ã¯ã³*1ãããã©ã¼ã æ¹ãããããã³ã°é²æ¢ã®ã«ã®ãªã®ã§ããã®æå³ã§ã$form->end();ã§éããã®ãéåã§ãã
- bakeãæ¸ããview
ver1.2.5ã§ã¯ãbakeã§ä½ã£ãviewã$form->create()ï¼$form->end()ä»æ§ã«ãªã£ã¦ããã®ã§ãã®ã¾ã¾ä½¿ãã¾ãã
- BlackHoleã®è¨å®
Cookbookãåèã«ãã¨ã©ã¼æã«ç°¡åãªã¡ãã»ã¼ã¸ãåºãããã«å®è£
ãã¾ããã
çã£ç½ã ã¨ä½ãèµ·ãã£ãã®ãããããªãã®ã§ ^^;
ä¸æºãæ¸å¿µãªã©
- å¥ã®ã¢ã¯ã·ã§ã³ã«ã¢ã¯ã»ã¹ããã¨ãã¼ã¯ã³ãåãã
åºå
¸
http://www.cmplc.cc/2008/04/05/515/
-
- ç¹å®ã®ã¢ã¯ã·ã§ã³ã§ã®ã¿ãã¼ã¯ã³ãçºè¡ãã
http://www.cmplc.cc/2008/05/06/519/
ã¨ãã対çãæãããã¦ã¾ããã
ãçªæä½ã§ç·¨éç»é¢2ã¤éããããæå³ããªãã»ã»ã»ã»
é·æç·¨éè¡ãªã£ãæå¥ã«æ¶ããããã¤ã¤ã«ãªãã¾ããããã»ã»ã»ã
- AUæºå¸¯ã§Tokenãåãåããªã
http://cakephp.jp/modules/newbb/viewtopic.php?topic_id=1899&forum=3
ã»ã»ã»ã»ãããfieldsetå¤ãã®ãæã£åãæ©ãã¦ç°¡åã§ãããã»ã»ã»çºè¨è
ããã¯æ°ä¹ãããªãæ¹æ³ã§ãããã
ãæºå¸¯ã¯ãåã£ãã¿ã°ä½¿ããªãã®ãæ¸å½ã
- requireAuthã«æå®ãã¦ãªãç»é¢ã®ãã©ã¼ã ã«ãTokenãå ¥ã
ãç¹ã«æºå¸¯ã¯ãè¦ããªããã±ããéããããªããã§ããã»ã»ã»
- ã¢ãã«ã®crudãããã³ã°ã§ãadd,update,deleteè¨å®ã®ã¢ã¯ã·ã§ã³ã¯å¿ ããã§ãã¯ãã¨ãã§ããªãã
主ãªå®è£ å·®å
Index: controllers/app_controller.php =================================================================== --- controllers/app_controller.php (revision 194) +++ controllers/app_controller.php (working copy) class AppController extends Controller { - var $components = array('AuthPlus', 'Acl'); + var $components = array('AuthPlus', 'Acl', 'Security'); /* ACL */ // 追å ã¢ã¯ã·ã§ã³ç¨ crudMap @@ -30,19 +31,26 @@ { parent::beforeFilter(); + // CSRFè¨å® + $this->Security->blackHoleCallback = "securityError"; + if ($this->AuthPlus) { // ACLé¢é£ $this->AuthPlus->actionPath = 'controllers/'; $this->AuthPlus->authorize = 'crud'; @@ -174,6 +182,12 @@ } } + + /* Security Error */ + function securityError($error) + { + die($error." ERROR!"); + } } Index: controllers/users_controller.php =================================================================== --- controllers/users_controller.php (revision 194) +++ controllers/users_controller.php (working copy) @@ -16,8 +16,24 @@ parent::beforeFilter(); + $this->Security->requireAuth( + "add", + "mobile_add", + "admin_add", + "edit", + "mobile_edit", + "admin_edit", + "change_password", + "mobile_change_password", + "admin_change_password", + "delete", + "mobile_delete", + "admin_delete" + ); +
*1:ä»®å