<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Krishna Sunuwar &#187; phpBricks</title>
	<atom:link href="http://www.krishnasunuwar.com.np/category/phpbricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.krishnasunuwar.com.np</link>
	<description>PHP programmer bloging programming, open soruce technologies</description>
	<lastBuildDate>Wed, 08 Sep 2010 16:06:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>phpBricks alpha preview</title>
		<link>http://www.krishnasunuwar.com.np/2010/01/phpbricks-alpha-preview/</link>
		<comments>http://www.krishnasunuwar.com.np/2010/01/phpbricks-alpha-preview/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 05:26:59 +0000</pubDate>
		<dc:creator>Krish</dc:creator>
				<category><![CDATA[phpBricks]]></category>
		<category><![CDATA[MVC framework]]></category>

		<guid isPermaLink="false">http://www.krishnasunuwar.com.np/?p=247</guid>
		<description><![CDATA[phpBricks is MVC framework for PHP programming language. It&#8217;s the framework so it may not be the way you want, but it&#8217;s the way I/we have found right. In early stage of my programming career, I see lot of resources and time was consuming to write same piece of validation code and I decide to save that [...]]]></description>
			<content:encoded><![CDATA[<p>phpBricks is MVC framework for PHP programming language. It&#8217;s the framework so it may not be the way you want, but it&#8217;s the way I/we have found right. In early stage of my programming career, I see lot of resources and time was consuming to write same piece of validation code and I decide to save that time by writing piece of code which can be reused. After then, I see series of such things one after another, like:</p>
<ol>
<li>Mix/Max of php and HTML code, which is pain in ASS to UI programmer, CSS guys.</li>
<li>Junk and vulnerable SQL statement, no way to make site secure.</li>
<li>Bunch of configuration variables and constants on config.php file.</li>
<li>Unmanaged structure of files, functions and classes.</li>
<li>Not proper modular structure which cause hard to maintenance application.</li>
<li>Personal interest of variable, function naming &#8211; lots of garbage and junk codes.</li>
<li>Writing and re-writing of code for same function within one projects and in multiple project.</li>
<li>No common standard and no central key. Different flow of each function/module, you never can say start and end when it comes to debugging.</li>
<li>And, I am seeing lot more others day by day&#8230;</li>
</ol>
<p>So, on process of eliminating those stuffs, I keep enhancing that piece of code with feedback and direct involvement of some handful colleague, phpBricks is made.</p>
<p>I understand it is same pain for all programmers until you know such framework exists (I bet hundreds of such framework exists, just google it). So here, it is my privileges to share that piece of code, now so called phpBricks. I have uploaded demo copy, naming alpha release at <a title="phpBricks" href="http://sourceforge.net/projects/phpbricks/">SourceForge</a>. I have been using it to build many commercial softwares. But I do not recommend you as this is alpha release and no sufficient resource will be found. If you want to use it, challenge the risk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krishnasunuwar.com.np/2010/01/phpbricks-alpha-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RBAC schemas (Entities Relationship) in phpBricks</title>
		<link>http://www.krishnasunuwar.com.np/2009/07/rbac-schemas-entities-relationship-in-phpbricks/</link>
		<comments>http://www.krishnasunuwar.com.np/2009/07/rbac-schemas-entities-relationship-in-phpbricks/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 02:55:14 +0000</pubDate>
		<dc:creator>Krish</dc:creator>
				<category><![CDATA[phpBricks]]></category>
		<category><![CDATA[RBAC]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.krishnasunuwar.com.np/?p=94</guid>
		<description><![CDATA[phpBricks saves roles, resources and permissions in database which looks following (more to come later): Update: RBAC model has been changed. This one is new model.]]></description>
			<content:encoded><![CDATA[<p>phpBricks saves roles, resources and permissions in database which looks following (more to come later):</p>
<p><img title="RBAC schemas (Entities Relationship) in phpBricks" src="http://i70.photobucket.com/albums/i88/s2krish/blug_new/rbac-model-1.jpg" alt="RBAC schemas (Entities Relationship) in phpBricks" /></p>
<p>Update: RBAC model has been changed. This one is new model.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krishnasunuwar.com.np/2009/07/rbac-schemas-entities-relationship-in-phpbricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RBAC &#8211; how do I code in phpBricks</title>
		<link>http://www.krishnasunuwar.com.np/2009/06/rbac-how-do-i-code-in-phpbricks/</link>
		<comments>http://www.krishnasunuwar.com.np/2009/06/rbac-how-do-i-code-in-phpbricks/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 02:39:55 +0000</pubDate>
		<dc:creator>Krish</dc:creator>
				<category><![CDATA[phpBricks]]></category>
		<category><![CDATA[RBAC]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.krishnasunuwar.com.np/?p=74</guid>
		<description><![CDATA[Last week, I wrote blog about RBAC architecture in phpBricks (http://tinyurl.com/rbac1). Today, I am going to give little snapshots about coding implementation. As you already know, RBAC is a component, but it is special provisioned component which works with core phpBricks. There is quick option which tells whether to apply RBAC or not. If you [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I wrote blog about RBAC architecture in phpBricks (<a href="http://tinyurl.com/rbac1">http://tinyurl.com/rbac1</a>). Today, I am going to give little snapshots about coding implementation. As you already know, RBAC is a component, but it is special provisioned component which works with core phpBricks. There is quick option which tells whether to apply RBAC or not. If you decide to apply RBAC set code in configuration like:<br />
<code>define('_RBAC', 1);</code></p>
<p>When RBAC is applied, an instance of RBAC is available in controller and views, but not in model classes. RBAC is not relevant in model because models are not supposed to contain any business logic. It is very much important to understand how each function is accessed to understand how RBAC determine authenticity. Each resource (or function) is identified with set of parameters, called CMA. Suppose you want to see list of users, that means calling index method of users. For that CMA parameter looks like (&#8216;c&#8217;=&gt;&#8217;user&#8217;, &#8216;m&#8217;=&gt;&#8217;users&#8217;, &#8216;a&#8217;=&gt;&#8217;index&#8217;).</p>
<p>In RBAC, permissions are assigned to roles not to users. Users inherit permission from their roles. So checking permission is done with combination of provided CMA parameters and roles. There is function called isPermission which takes 5 parameters. First three are CMA, fourth is primary_key (for advance business rule), and fifth is roles. Last two are optional.</p>
<p>For example, if you want to check that whether current loged in user has permission to see list of users or not:</p>
<p><code><br />
if($this-&gt;Auth-&gt;isPermission('user','users','index'))<br />
{<br />
// code to list users<br />
}<br />
else<br />
{<br />
// sorry permission denied.<br />
}</code><br />
<em>This works from view and controller.</em></p>
<p>Roles of user is collected at time of login and stored in session, which is available in $_SESSION['__userroles']. So if you don&#8217;t pass roles parameter, phpBricks suppose current user. Now your turn to think how do you check permission of a users who is not loged in.</p>
<p>&#8212;&#8212;&#8212;-</p>
<p>This blog is intended to alpha users of phpBricks. Thank you guys, you are source of energy. Thanks for suggestion, exceptions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krishnasunuwar.com.np/2009/06/rbac-how-do-i-code-in-phpbricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RBAC in phpBricks</title>
		<link>http://www.krishnasunuwar.com.np/2009/06/rbac-in-phpbricks/</link>
		<comments>http://www.krishnasunuwar.com.np/2009/06/rbac-in-phpbricks/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 02:22:31 +0000</pubDate>
		<dc:creator>Krish</dc:creator>
				<category><![CDATA[phpBricks]]></category>
		<category><![CDATA[RBAC]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://www.krishnasunuwar.com.np/?p=65</guid>
		<description><![CDATA[Role Based Permission Control (RBAC) is widely used security module in the industry, including Oracle, Microsoft Exchange Server (some form of it). When MAC and DAC unable to address business rule, a concept of RBAC is brought into practice.  In this model, users are not assigned permission directly but acquire from their role(s). Role, which [...]]]></description>
			<content:encoded><![CDATA[<p>Role Based Permission Control (RBAC) is widely used security module in the industry, including Oracle, Microsoft Exchange Server (some form of it). When MAC and DAC unable to address business rule, a concept of RBAC is brought into practice.  In this model, users are not assigned permission directly but acquire from their role(s). Role, which is created for job function in organization and each role are designated to perform set of operations. En employee can perform operation, which is assigned to his/her role(s). So, it is pretty straight forward.</p>
<p>I have implemented lightweight form of RBAC (lightweight is my personal terminology). It&#8217;s lightweight because it exactly address need of web application. RBAC itself is very huge while implementing whole features, it&#8217;s like giant elephant. In phpBricks, RBAC is included in user component. As shown in figure bellow, it consists of Users, Roles, Permissions and Resource Registry (Operations).</p>
<ul>
<li><strong>Users</strong>: Subject which access application. A user can have multiple roles e.g. Forum editor and CMS editor.</li>
<li><strong>Roles</strong>: Job title which consists list of operations (job). Roles can be two type, black list or white list (allow list or deny list)</li>
<li><strong>Permission</strong>: Indicate approval to access resources.</li>
<li><strong>Resource Registry</strong>: List of operations (action, also called method) which is grouped into component and module. Method represent actual operation or function where component and module are packges. phpBricks is smart that it collect all components, modules and methods, then build registry automatically so programmer don&#8217;t need to worry about accounting all these.</li>
</ul>
<p><img src="http://i70.photobucket.com/albums/i88/s2krish/blug_new/rbac-model.jpg" alt="RBAC in phpBricks" /></p>
<p><strong>How to define?</strong></p>
<p>From back-end when you access RBAC, it shows matrix of roles and resources (operations). Simply you can tick on check-box to allow or deny access. One important thing to remember is that role type. By default all operations are allowed in black-list role and all operations are denied in white-list roles. So by selecting operation under black-list role, you are banning access, but in white-list you are allowing.</p>
<p><strong>How it works?</strong></p>
<p>Resource is always identified by three parameters i.e. component, module and actions knows as CMA (fourth is optional i.e. primary key for advance business rule). So, whenever user try perform certain operation, based on CMA phpBricks authenticates.</p>
<p><strong>What next?</strong></p>
<p>Checking permission on realtime basis while access request is made, can cause performance to be slow. So, I am thinking permission caching technique.</p>
<p><strong>Recommended reading:</strong></p>
<p>Role-Based Access Control by David F. Ferraiolo (can be found it in Amazon)</p>
<p><strong>Note:</strong></p>
<p><strong></strong>In above text, following terminology may be confused while used interchangeably.</p>
<p>Operation=Function=Resource=Action=Method</p>
]]></content:encoded>
			<wfw:commentRss>http://www.krishnasunuwar.com.np/2009/06/rbac-in-phpbricks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
