ACLï¼ãã¡ã¤ã«å´ $this->Auth->authorize ã®è¨å®ã¯ï¼
ACLå ¥ãããã¨ãã¦ã¾ãããæå¾ã®(?)è©°ããControllerå´ã®è¨å®ã§ããã£ã¦ã¾ãã»ã»ã»
æ¤è¨ï¼èª¿æ»ä¸ã®ã¡ã¢ã
(追è¨ï¼è§£æ¶ãã¾ãããã解ã¯ãactionããããã¯ãcrudãã§ã)
参考サイトã§ã
AppController ã« $this->Auth->authorize = 'actions'; ã¨å ¥ãã¦ããã¾ãã
ã¨ããã¾ããããã®æ¹æ³ã ã¨ãactionãã¨ã«å
¨é¨aros_acosè¨å®ããªãã¦ã¯ãªããªãããã§ãã
controllerãModelåä½ã§ãããè¨å®ã ãã§ã¯ããªãã¤ã¬ã¯ãã«ã¼ãã®ã¨ã©ã¼ã«ãªãã¾ãã
ã¢ã¯ã·ã§ã³æ¯ã«å ¨é¨ã¡ããã¨è¨å®ããããããªããã¨å¼±æ°ã«ãªãã¤ã¤ã$this->Auth->authorizeã«ã¤ãã¦èª¿æ»ã
ããã¨ãä¾ç¤ºã«ãmodelãæå®ããªãããçãªãã¨ãæ¸ãã¦ããã¾ããã*1
ACO ãå©ç¨ããæãªã©ãã³ã³ããã¼ã©ä¸ã§ã®å¦çãè¡ããªãå ´åã¯ã©ãããã°ããã®ã§ããããï¼ãã®å ´åã authorize å¤æ°ããmodelãã«ã»ãããããã¨ã§ãèªè¨¼ã使ãã¢ãã«(ä¾ãã° User) ä¸ã® isAuthorized() ã¡ã½ãããã³ã¼ã«ããã¾ãã
http://book.cakephp.org/ja/view/396/authorize
ã§ãã追å ããisAuthorized() ã¡ã½ããä¾ã®ãå¼æ°ã¯ããããä½ããããã°ã»ã»ã»ï¼
cake/libs/auth.phpã§ãå®éã«isAuthorized()ã確èªã
ããã¨ã¾ãã$this->Auth->authorize = 'actions';ã®æå®ã§ACLãã§ãã¯ãå ¥ãéçããããã¾ããã
case 'actions': $valid = $this->Acl->check($user, $this->action()); break;
ã§ã¯èå¿ã®modelæå®ã
case 'model': $this->mapActions(); $action = $this->params['action']; if (isset($this->actionMap[$action])) { $action = $this->actionMap[$action]; } if (is_string($object)) { $object = $this->getModel($object); } (ä¸ç¥ï¼ if (method_exists($object, 'isAuthorized')) { $valid = $object->isAuthorized($user, $this->action(':controller'), $action);
ãªãã»ã©ã§ã¯ãã¢ãã«ã«è¿½å ããisAuthorizedã®ä¸ã§ã$this->Acl->check()ã®çµæã§ãè¿ãã°ããããã
æã£ã¦ãæ¬ã«ããã¨ã$this->Acl->check()ã§ACLã®è¨å®ãã§ãã¯ãã»ã»ã»ã»ã»ã»ã»ã»
ã¨æã£ã¦ã
ããã¿ã¨æ°ãã¤ãã¾ããã
case 'model'ãã®ä¸ã«ã»ã»ã»ã»
case 'crud': $this->mapActions(); if (!isset($this->actionMap[$this->params['action']])) { $err = 'Auth::startup() - Attempted access of un-mapped action "%1$s" in'; $err .= ' controller "%2$s"'; trigger_error( sprintf(__($err, true), $this->params['action'], $this->params['controller']), E_USER_WARNING ); } else { $valid = $this->Acl->check( $user, $this->action(':controller'), $this->actionMap[$this->params['action']] ); } break;
CRUDとは (Create, Read, Update, Delete) クラッド: - IT用語辞典バイナリ
ãããããã£ï¼ï¼ï¼ï¾ãï¾;ï¼
ããã«ã$this->actionMapãã¨ããã®ãä½ç©ã調ã¹ã¦ã¿ãã¨ã
var $actionMap = array( 'index' => 'read', 'add' => 'create', 'edit' => 'update', 'view' => 'read', 'remove' => 'delete' );
ã»ã»ã»ã»ã»ã»ã»ã»ã»ã»
ã¢ã¯ã·ã§ã³åããcrudã«å¤æããããã®ããããã³ã°ãã¼ã¼ã¼ã¼ï¼ï¼ï¾ãï¾;ï¼
ã¨ã
ããããã¨ã¯ã
ããã»ã»ã»ã§ããï¼ï¼
ããã¨ãæãã®ã§ãã
Modelã§Aclãåç
§ããããã°ããã
ããã¨ãauthã«ããã¦ãcrudãæ£è§£ã»ã»ã»ï¼
(追è¨ï¼ModelããAclãåç §ããã®ãåä»ãACLã¯èªè¨¼é¢é£ãªã®ã ããcrudè¨å®ãã¦Authæ¡å¼µã§ééã£ã¦ãªãã®ã§ã¯)
*1:追è¨ï¼ããã«æãããã¾ãã T_T