RE: [SMARTY] Security framework??

From: Date: Fri, 21 Feb 2003 23:01:33 +0000
Subject: RE: [SMARTY] Security framework??
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8107@lists.php.net to get a copy of this message
OK.. I like that.. Make the "acl" object have an enumerated set of binary attributes that are representative of permissions the user has... I appreciate the feedback.... -----Original Message----- From: Monte Ohrt [mailto:monte@ispi.net] Sent: Friday, February 21, 2003 2:42 PM To: Steve Cc: Smarty General Subject: Re: [SMARTY] Security framework?? Just out of "Best Practices" rules of thumb, I'd leave direct access to session vars out of the templates, let the application do that. Your template just needs to know what to display, not necessarily why. So something like this: {if $show_cool} ... {/if} Your application assigns the $show_cool value, which in this case is determined by the operations session variable... something the template shouldn't concern itself with. This way your application logic stays in the app, away from the template. If assigning $show_cool becomes a tedious issue, you do it at runtime with an object: {if $acl->show_cool()} ... {/if} Monte On Fri, 2003-02-21 at 16:33, Steve wrote: > I suppose this is an extension to the thread the other day on how you use > smarty.... > > I have built a rather easy to use security (permissions) framework that I > use with my Smarty applications. I'm wondering if there are others out > there who would be interested in it, helping develop it, etc. > > I'm sure it could use improvement, but thought I would see what others > think. I don't have it packaged up seperately, but would be willing to if > others wanted it. > > Here is the basic way it works: > > Each logged in user has an array of operations stored in their session's > operation array. This array of integers corresponds to system functions > that require permission to perform. > > Then, all that is needed to check if a user has permission is a simple: > > in the .php file: > if(@in_array(22,$_SESSION['operations'])) { > do database query for something cool; > } > > in the .tpl file: > {if @in_array(22,$smarty.session.operations)} > show something cool; > {/if} > > Now, it is important that the session information is secure (i use either a > secured directory or the database). > > I use a MVC type of architecture. This type of system allows the > permissions to affect both the business logic (only execute the database > query if authorized) and the display logic (only show the link to the admin > page if logged in as admin group). > > Anyone interested?? > > Steve -- Monte Ohrt <monte@ispi.net>

« previous php.smarty.general (#8107) next »