Yii Framework v1.1.10 绫诲弬鑰

CAuthManager

system.web.auth
缁ф壙 abstract class CAuthManager » CApplicationComponent » CComponent
瀹炵幇 IApplicationComponent, IAuthManager
瀛愮被 CDbAuthManager, CPhpAuthManager
婧愯嚜 1.0
鐗堟湰 $Id: CAuthManager.php 3515 2011-12-28 12:29:24Z mdomba $
婧愮爜 framework/web/auth/CAuthManager.php
CAuthManager鏄巿鏉冪鐞嗙被鐨勫熀绫汇

CAuthManager缁ф壙浜CApplicationComponent锛屽疄鐜颁簡涓浜 鍦ㄦ巿鏉冪鐞嗙被涓殑閫氱敤鏂规硶銆

CAuthManager鍜屽畠鐨勫叿浣撳瓙绫诲疄鐜颁簡 鍩轰簬鐢ㄦ埛瑙掕壊璁块棶鎺у埗锛圧BAC锛夈

涓昏鎬濇兂鏄紝灞傜骇鏉冮檺鏄敱 鎺堟潈椤圭洰鏉ョ鐞嗙殑銆傞珮灞傜殑椤圭洰 缁ф壙浜嗕綆灞傜殑椤圭洰鏉冮檺銆傝鑹叉槸鏈楂樼骇鐨勬巿鏉冮」鐩紝 浼氳祴浜堢粰姣忎釜鐢ㄦ埛銆備竴涓敤鎴锋墍鎷ユ湁鐨勬潈闄愶紝 鏄敱浠栫殑瑙掕壊鎵缁ф壙鐨勬巿鏉冮」鐩喅瀹氱殑銆

浣跨敤鎺堟潈绠$悊鍣ㄥ寘鍚袱涓柟闈€傜涓锛屾巿鏉冪瓑绾у拰浠诲姟 蹇呴』瑕佹棦瀹氱殑銆侰AuthManager鍜屽畠鐨勫瓙绫 鎻愪緵API鏉ュ畬鎴愯繖涓换鍔°傚紑鍙戜汉鍛橀渶瑕佸紑鍙戜竴浜汫UI锛 浣胯繖浜涙搷浣滄洿鍔犵洿瑙傜殑灞曠ず缁欐渶缁堢敤鎴枫傜浜岋紝寮鍙戜汉鍛樺湪绋嬪簭閲岄潰閫傚綋鐨勪綅缃 璋冪敤IAuthManager::checkAccess鏉ユ娴嬪綋鍓嶇敤鎴 鏄惁鍚湁璇ユ搷浣滅殑鏉冮檺銆

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
authItems array 杩斿洖鎸囧畾绫诲瀷鍜岀敤鎴风殑鎺堟潈椤广 IAuthManager
behaviors array 杩欎釜搴旂敤缁勪欢闄勫姞鐨勮涓恒 杩欐琛屼负灏嗗湪搴旂敤缁勪欢璋冪敤init鏃堕檮鍔犲湪搴旂敤缁勪欢涓娿 璇峰弬鐓CModel::behaviors濡備綍鎸囧畾姝ゅ睘鎬у笺 CApplicationComponent
defaultRoles array 闅愬紡璧嬩簣缁欐墍鏈夌敤鎴风殑瑙掕壊鍚嶅瓧鍒楄〃銆 杩欎簺瑙掕壊涓嶉渶瑕佹樉寮忚祴浜堢粰鎵鏈夌敤鎴枫 褰撹皟鐢checkAccess锛屼細棣栧厛妫鏌ヨ繖浜涜鑹层 涓轰簡鑳藉鎻愰珮绋嬪簭鏁堢巼锛岃繖鏍风殑瑙掕壊瓒婂皯瓒婂ソ銆 涓涓吀鍨嬬殑鐢ㄦ硶鏄紝瀹氫箟涓涓渁uthenticated鈥濊鑹诧紝鐒跺悗 鎶婂畠鍏宠仈鍒颁竴涓笟鍔¢昏緫瑙勫垯锛岃繖涓鍒欐槸鐢ㄦ潵楠岃瘉褰撳墠鐢ㄦ埛鐨勩 鐒跺悗鍦ㄨ繖涓睘鎬у0鏄庘渁uthenticated鈥濅互渚垮簲鐢ㄥ埌 鎵鏈夌殑楠岃瘉鐢ㄦ埛銆 CAuthManager
isInitialized boolean 妫鏌ュ簲鐢ㄧ粍浠舵槸鍚﹀凡缁忓垵濮嬪寲銆 CApplicationComponent
operations array 杩斿洖鎿嶄綔銆 CAuthManager
roles array 杩斿洖瑙掕壊銆 CAuthManager
showErrors boolean 鍏佽涓氬姟瑙勫垯閿欒鎶ュ憡銆 CAuthManager
tasks array 杩斿洖浠诲姟銆 CAuthManager

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
addItemChild() 娣诲姞涓涓巿鏉冮」浣滀负鍙︿竴涓巿鏉冮」鐨勫瓙鎺堟潈椤广 IAuthManager
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
assign() 涓虹敤鎴峰垎閰嶄竴涓巿鏉冮」銆 IAuthManager
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
checkAccess() 妫鏌ユ寚瀹氱敤鎴风殑鎵ц鏉冮檺銆 IAuthManager
clearAll() 绉婚櫎鎵鏈夋巿鏉冩暟鎹 IAuthManager
clearAuthAssignments() 绉婚櫎鎵鏈夋巿鏉冨垎閰嶄俊鎭 IAuthManager
createAuthItem() 鍒涘缓涓涓巿鏉冮」銆 IAuthManager
createOperation() 鍒涘缓涓涓搷浣溿 CAuthManager
createRole() 鍒涘缓涓涓鑹层 CAuthManager
createTask() 鍒涘缓涓涓换鍔° CAuthManager
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
executeBizRule() 鎵ц鎸囧畾鐨勪笟鍔¤鍒欍 CAuthManager
getAuthAssignment() 杩斿洖鎺堟潈椤瑰垎閰嶄俊鎭 IAuthManager
getAuthAssignments() 杩斿洖鎸囧畾鐢ㄦ埛鐨勬巿鏉冮」鍒嗛厤淇℃伅銆 IAuthManager
getAuthItem() 杩斿洖鎸囧畾鍚嶅瓧鐨勬巿鏉冮」 IAuthManager
getAuthItems() 杩斿洖鎸囧畾绫诲瀷鍜岀敤鎴风殑鎺堟潈椤广 IAuthManager
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getIsInitialized() 妫鏌ュ簲鐢ㄧ粍浠舵槸鍚﹀凡缁忓垵濮嬪寲銆 CApplicationComponent
getItemChildren() 杩斿洖鎸囧畾鎺堟潈椤圭殑瀛愭巿鏉冮」銆 IAuthManager
getOperations() 杩斿洖鎿嶄綔銆 CAuthManager
getRoles() 杩斿洖瑙掕壊銆 CAuthManager
getTasks() 杩斿洖浠诲姟銆 CAuthManager
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasItemChild() 杩斿洖涓涓艰〃绀虹埗鎺堟潈椤规槸鍚﹀瓨鍦ㄥ瓙鎺堟潈椤广 IAuthManager
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
init() 鍒濆鍖栧簲鐢ㄧ粍浠躲 CApplicationComponent
isAssigned() 杩斿洖涓涓艰〃绀哄垽鏂巿鏉冮」鏄惁鍒嗛厤缁欐寚瀹氱敤鎴枫 IAuthManager
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent
removeAuthItem() 绉婚櫎鎸囧畾鎺堟潈椤广 IAuthManager
removeItemChild() 浠庣埗鎺堟潈椤逛腑绉婚櫎瀛愭巿鏉冮」銆 IAuthManager
revoke() 鎾ら攢涓涓敤鎴峰垎閰嶇殑鎺堟潈椤广 IAuthManager
save() 淇濆瓨鎺堟潈鏁版嵁鍒版寔涔呭瓨鍌ㄣ IAuthManager
saveAuthAssignment() 淇濆瓨淇敼鐨勬巿鏉冧俊鎭 IAuthManager
saveAuthItem() 淇濆瓨鎺堟潈椤瑰埌鎸佷箙瀛樺偍銆 IAuthManager

鍙椾繚鎶ゆ柟娉

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
checkItemChildType() 妫鏌ラ」鐩被鍨嬩互纭畾涓涓瓙椤圭洰宸茬粡璧嬩簣缁欎竴涓埗椤圭洰銆 CAuthManager

灞炴ц缁

defaultRoles 灞炴
public array $defaultRoles;

闅愬紡璧嬩簣缁欐墍鏈夌敤鎴风殑瑙掕壊鍚嶅瓧鍒楄〃銆 杩欎簺瑙掕壊涓嶉渶瑕佹樉寮忚祴浜堢粰鎵鏈夌敤鎴枫 褰撹皟鐢checkAccess锛屼細棣栧厛妫鏌ヨ繖浜涜鑹层 涓轰簡鑳藉鎻愰珮绋嬪簭鏁堢巼锛岃繖鏍风殑瑙掕壊瓒婂皯瓒婂ソ銆 涓涓吀鍨嬬殑鐢ㄦ硶鏄紝瀹氫箟涓涓渁uthenticated鈥濊鑹诧紝鐒跺悗 鎶婂畠鍏宠仈鍒颁竴涓笟鍔¢昏緫瑙勫垯锛岃繖涓鍒欐槸鐢ㄦ潵楠岃瘉褰撳墠鐢ㄦ埛鐨勩 鐒跺悗鍦ㄨ繖涓睘鎬у0鏄庘渁uthenticated鈥濅互渚垮簲鐢ㄥ埌 鎵鏈夌殑楠岃瘉鐢ㄦ埛銆

operations 灞炴 鍙
public array getOperations(mixed $userId=NULL)

杩斿洖鎿嶄綔銆 杩欎釜鏂规硶鏄IAuthManager::getAuthItems鐨勫揩鎹锋柟寮

roles 灞炴 鍙
public array getRoles(mixed $userId=NULL)

杩斿洖瑙掕壊銆 杩欎釜鏂规硶鏄IAuthManager::getAuthItems鐨勫揩鎹锋柟寮忋

showErrors 灞炴 锛堝彲鐢ㄨ嚜 v1.1.3锛
public boolean $showErrors;

鍏佽涓氬姟瑙勫垯閿欒鎶ュ憡銆

tasks 灞炴 鍙
public array getTasks(mixed $userId=NULL)

杩斿洖浠诲姟銆 杩欎釜鏂规硶鏄IAuthManager::getAuthItems鐨勫揩鎹锋柟寮

鏂规硶璇︾粏

checkItemChildType() 鏂规硶
protected void checkItemChildType(integer $parentType, integer $childType)
$parentType integer 鐖堕」鐩殑绫诲瀷
$childType integer 瀛愰」鐩被鍨
婧愮爜锛 framework/web/auth/CAuthManager.php#159 (鏄剧ず)
protected function checkItemChildType($parentType,$childType)
{
    static 
$types=array('operation','task','role');
    if(
$parentType $childType)
        throw new 
CException(Yii::t('yii','Cannot add an item of type "{child}" to an item of type "{parent}".',
            array(
'{child}'=>$types[$childType], '{parent}'=>$types[$parentType])));
}

妫鏌ラ」鐩被鍨嬩互纭畾涓涓瓙椤圭洰宸茬粡璧嬩簣缁欎竴涓埗椤圭洰銆

createOperation() 鏂规硶
public CAuthItem createOperation(string $name, string $description='', string $bizRule=NULL, mixed $data=NULL)
$name string 椤圭洰鍚嶅瓧
$description string 椤圭洰鎻忚堪銆
$bizRule string 鍏宠仈鍒拌繖涓」鐩殑涓氬姟閫昏緫
$data mixed 褰撴墽琛屼笟鍔¤鍒欑殑鏃跺欐墍浼犻掔殑棰濆鐨勬暟鎹
{return} CAuthItem 鎺堟潈椤圭洰銆
婧愮爜锛 framework/web/auth/CAuthManager.php#99 (鏄剧ず)
public function createOperation($name,$description='',$bizRule=null,$data=null)
{
    return 
$this->createAuthItem($name,CAuthItem::TYPE_OPERATION,$description,$bizRule,$data);
}

鍒涘缓涓涓搷浣溿 杩欎釜鏂规硶鏄IAuthManager::createAuthItem鐨勫揩鎹锋柟寮忋

createRole() 鏂规硶
public CAuthItem createRole(string $name, string $description='', string $bizRule=NULL, mixed $data=NULL)
$name string 椤圭洰鍚嶅瓧
$description string 椤圭洰鎻忚堪銆
$bizRule string 鍏宠仈鍒拌繖涓」鐩殑涓氬姟瑙勫垯
$data mixed 鎵ц涓氬姟瑙勫垯鐨勬椂鍊欐墍浼犻掔殑棰濆鐨勬暟鎹
{return} CAuthItem 鎺堟潈椤圭洰
婧愮爜锛 framework/web/auth/CAuthManager.php#71 (鏄剧ず)
public function createRole($name,$description='',$bizRule=null,$data=null)
{
    return 
$this->createAuthItem($name,CAuthItem::TYPE_ROLE,$description,$bizRule,$data);
}

鍒涘缓涓涓鑹层 杩欎釜鏂规硶鏄IAuthManager::createAuthItem鐨勫揩鎹锋柟寮忋

createTask() 鏂规硶
public CAuthItem createTask(string $name, string $description='', string $bizRule=NULL, mixed $data=NULL)
$name string 椤圭洰鍚嶅瓧
$description string 椤圭洰鎻忚堪銆
$bizRule string 鍏宠仈鍒拌繖涓」鐩殑涓氬姟瑙勫垯銆
$data mixed 鎵ц杩欎釜涓氬姟瑙勫垯鏃跺欐墍浼犻掔殑棰濆鐨勬暟鎹
{return} CAuthItem 楠岃瘉椤圭洰銆
婧愮爜锛 framework/web/auth/CAuthManager.php#85 (鏄剧ず)
public function createTask($name,$description='',$bizRule=null,$data=null)
{
    return 
$this->createAuthItem($name,CAuthItem::TYPE_TASK,$description,$bizRule,$data);
}

鍒涘缓涓涓换鍔° 杩欎釜鏂规硶鏄IAuthManager::createAuthItem鐨勫揩鎹锋柟寮忋

executeBizRule() 鏂规硶
public boolean executeBizRule(string $bizRule, array $params, mixed $data)
$bizRule string 瑕佹墽琛岀殑涓氬姟瑙勫垯銆
$params array 浼犻掔粰IAuthManager::checkAccess鐨勫弬鏁
$data mixed 鍏宠仈鍒版巿鏉冮」鐩垨鑰呬换鍔$殑棰濆鐨勬暟鎹
{return} boolean 杩欎釜涓氬姟瑙勫垯鏄惁杩斿洖true銆 濡傛灉涓氬姟瑙勫垯涓虹┖锛屽垯杩斿洖true銆
婧愮爜锛 framework/web/auth/CAuthManager.php#148 (鏄剧ず)
public function executeBizRule($bizRule,$params,$data)
{
    return 
$bizRule==='' || $bizRule===null || ($this->showErrors ? eval($bizRule)!=: @eval($bizRule)!=0);
}

鎵ц鎸囧畾鐨勪笟鍔¤鍒欍

getOperations() 鏂规硶
public array getOperations(mixed $userId=NULL)
$userId mixed 鐢ㄦ埛ID銆傚鏋滀笉涓簄ull锛岄偅涔堝彧浼氳繑鍥炶祴浜堢粰杩欎釜 鐢ㄦ埛鐨勬搷浣溿傚惁鍒欒繑鍥炴墍鏈夌殑鎿嶄綔銆
{return} array operations (name=>CAuthItem)
婧愮爜锛 framework/web/auth/CAuthManager.php#135 (鏄剧ず)
public function getOperations($userId=null)
{
    return 
$this->getAuthItems(CAuthItem::TYPE_OPERATION,$userId);
}

杩斿洖鎿嶄綔銆 杩欎釜鏂规硶鏄IAuthManager::getAuthItems鐨勫揩鎹锋柟寮

getRoles() 鏂规硶
public array getRoles(mixed $userId=NULL)
$userId mixed 鐢ㄦ埛ID銆傚鏋滀笉涓簄ull锛岄偅涔堝彧杩斿洖璧嬩簣缁欒繖涓敤鎴 鐨勮鑹层傚惁鍒欒繑鍥炴墍鏈夌殑瑙掕壊銆
{return} array 瑙掕壊锛坣ame=>CAuthItem锛
婧愮爜锛 framework/web/auth/CAuthManager.php#111 (鏄剧ず)
public function getRoles($userId=null)
{
    return 
$this->getAuthItems(CAuthItem::TYPE_ROLE,$userId);
}

杩斿洖瑙掕壊銆 杩欎釜鏂规硶鏄IAuthManager::getAuthItems鐨勫揩鎹锋柟寮忋

getTasks() 鏂规硶
public array getTasks(mixed $userId=NULL)
$userId mixed 鐢ㄦ埛ID銆傚鏋滀笉涓簄ull锛屽彧杩斿洖璧嬩簣缁欒繖涓敤鎴 浠诲姟銆傚惁鍒欒繑鍥炴墍鏈変换鍔°
{return} array tasks (name=>CAuthItem)
婧愮爜锛 framework/web/auth/CAuthManager.php#123 (鏄剧ず)
public function getTasks($userId=null)
{
    return 
$this->getAuthItems(CAuthItem::TYPE_TASK,$userId);
}

杩斿洖浠诲姟銆 杩欎釜鏂规硶鏄IAuthManager::getAuthItems鐨勫揩鎹锋柟寮

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.