O Guia Definitivo do Yii 1.1
O Guia Definitivo do Yii 1.1
O Guia Definitivo do Yii 1.1
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
eturn array(<br />
'components'=>array(<br />
'db'=>array(<br />
'class'=>'CDbConnection',<br />
'connectionString'=>'sqlite:path/to/file.db',<br />
),<br />
'authManager'=>array(<br />
'class'=>'CDbAuthManager',<br />
'connectionID'=>'db',<br />
),<br />
),<br />
);<br />
We can then access the authManager application component using <strong>Yii</strong>::app()-<br />
>authManager.<br />
Defining Authorization Hierarchy<br />
Defining authorization hierarchy involves three steps: defining authorization items,<br />
establishing relationships between authorization items, and assigning roles to application<br />
users. The authManager application component provides a whole set of APIs to<br />
accomplish these tasks.<br />
To define an authorization item, call one of the following methods, depending on the type<br />
of the item:<br />
• CAuthManager::createRole<br />
• CAuthManager::createTask<br />
• CAuthManager::createOperation<br />
Once we have a set of authorization items, we can call the following methods to establish<br />
relationships between authorization items:<br />
• CAuthManager::addItemChild<br />
• CAuthManager::removeItemChild<br />
• CAuthItem::addChild<br />
• CAuthItem::removeChild<br />
And finally, we call the following methods to assign role items to individual users:<br />
• CAuthManager::assign<br />
• CAuthManager::revoke<br />
Below we show an example about building an authorization hierarchy with the provided<br />
APIs: