    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>vaporbase :: Authorization in Rails</title>
        <link>http://www.vaporbase.com/</link>
        <description>the knowledge base that almost is</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Vaporbase Admin</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:admin@parkerhill.com" /> 
       <sy:updatePeriod>hourly</sy:updatePeriod> 
       <sy:updateFrequency>1</sy:updateFrequency> 
       <docs>http://backend.userland.com/rss</docs>

<!-- show a header for the current publication type -->
        <h2>Postings</h2>


<div class="xar-mod-head"><span class="xar-mod-title">rails</span></div>

<table border="0" cellpadding="1" cellspacing="0">
<tr>
    <td valign="top">
        Browse in :
   </td>
   <td valign="top">

                                    <a href="http://www.vaporbase.com/postings/">All</a>

                 &gt;                     <a href="http://www.vaporbase.com/postings/c36/">subjects</a>

                 &gt;                     <a href="http://www.vaporbase.com/postings/c42/">rails</a>
<br />
</td>
</tr>
</table>






<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xd</em>
and <em>user-summary-[publicationtype].xd</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles
The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Authorization in Rails</h1>
<p><strong>Author:</strong>&nbsp;linoj</p>
<p>
<strong>Date:</strong> May 04, 2007 5:18:11 PM  or Fri, 04 May 2007 17:18:11 </p>
<p><strong>Summary:</strong>&nbsp;Here's a review of several authorization add-on's for Rails. Whereas &quot;authentication&quot; refers to managing user login credentials, &quot;authorization&quot; is about managing role-based permissions to access specific areas of your site.  [May 15, added Super Simple Authorization to the list]</p>
<p><strong>Body:</strong>&nbsp;<p>Not everyone is clear on the distinction between &quot;authentication&quot; and &quot;authorization&quot;. Basically <em>authentication</em> manages a list of users and their sessions, handles the login process by checking credentials (e.g. password), and registration. You can then restrict access to areas of your site based on whether a user is logged in or not. For Ruby on Rails applications, you can get authentication with the ActsAsAuthenticated (&quot;AAA&quot;) or RestfulAuthentication plug-ins (among others), or build your own. </p><p><em>Authorization</em> adds granularity. In addition to simply asking if you&#39;re logged in, different users can have different permissions , or &quot;roles&quot;. Thus normal Users may be able to post comments,  Moderators may be able to edit/delete comments, and Administrators may have full admin capability such as the ability to modify/remove users. <br /> </p><p>Here is a survey of a number of authorization add-ons available.</p><h2>Super Simple Authorization</h2><p>I recently watched the <a href="http://www.railscasts.com/episodes/20">RailsCast #20 &quot;Restricting Access&quot;</a> and decided to add it to this article. So here it is, at the top of our list.</p><p>If you have a User table (using AAA or RA) you can extend the table with an &quot;admin&quot; attribute, and then query current_user.admin? to test for authorization. Simple enough. You could extend this idea by having different booleans for editor, moderator and other roles you may require. </p><p>The screencast goes even simpler. If you really only want to restrict access to specific admin functions on an otherwise public site, you may not even need a Users table and registration at all. Instead your login page just asks the user for a password, which you store in the current session. Then you use an admin? method (to the application controller) which compares this against a hardcoded password.</p><h2>Authorization Recipe</h2><p>&quot;Authorizing Users with Roles&quot;, Recipe 32 in <em>Rails Recipes</em> by Chad Fowler. (Published June 2006).<br /></p><p>Builds from an existing User model, as described in Recipe 31 &quot;Authenticating Your Users&quot;, or generated with AAA.  </p><p>This recipe builds two new models for Roles and Rights, such that Users have Roles, Roles have Rights: (HABTM = has_and_belongs_to_many)<br /></p><ul><li>User HABTM roles</li><li>Role HABTM users</li><li>Role HABTM rights</li><li>Right HABTM roles</li></ul><p>A <em>right</em> specifies a Controller name and Action name. Add a before_filter in your controllers to check_authorization, which determines whether the current user has rights to the incoming action call. If not he&#39;s redirected to an error page. </p><p>Simple enough, and bare bones. The implementation is not RESTful but that wouldn&#39;t be hard to change. More complexity is left as an exercise to the reader.</p><h2>Simple_access_control</h2><p><a href="http://opensvn.csie.org/mabs29/plugins/simple_access_control">http://opensvn.csie.org/mabs29/plugins/simple_access_control</a>   </p><p>The simple_access_control plugin is basically the same as described above by Chad Fowler, offered in a plug-in, if you prefer. Tests are provided.  </p><h2>acl_system2</h2><p><a href="http://prometheus.hki.uni-koeln.de/pandora-doc/plugins/acl_system2/">http://prometheus.hki.uni-koeln.de/pandora-doc/plugins/acl_system2/</a>  </p><p><a href="http://opensvn.csie.org/ezra/rails/plugins/dev/acl_system2/">http://opensvn.csie.org/ezra/rails/plugins/dev/acl_system2/</a></p><p>(Revision 146, February 2006, very low activity, no forum) </p><p>Like the aforementioned, the acl_system2 plugin provides simple declarative authorization for protecting controller/actions using roles. It provides a flexible permissions string parser that appears quite convenient. For example, a controller can declare:</p><pre>access_control [:new, :create, :update, :edit] =&gt; &#39;(admin | user | moderator)&#39;,<br />                 :delete =&gt; &#39;admin&#39;</pre><p> while allows users, moderators, and admins to create and update items, but only admins to delete items. You can specify callback methods for redirecting or doing other stuff (e.g. setting flash messages) when access is permitted or denied. A helper method, restrict_to, is provided for views, e.g.</p><pre>&lt;% restrict_to &quot;(admin | moderator) &amp; !blacklist&quot; do %&gt;</pre><pre>  &lt;%= link_to &quot;Admin &amp; Moderator only link&quot;, :action =&gt;&#39;foo&#39; %&gt;</pre><pre>&lt;% end %&gt; </pre><h2>ActiveACL Plugin</h2><p><a href="http://activeacl.rubyforge.org/">http://activeacl.rubyforge.org/</a>  </p><p><a href="http://rubyforge.org/projects/activeacl">http://rubyforge.org/projects/activeacl</a> </p><p><a href="http://phpgacl.sourceforge.net/demo/phpgacl/docs/manual.html">http://phpgacl.sourceforge.net/demo/phpgacl/docs/manual.html</a> </p><p>(Release 0.2.1, December 2006, very low activity) </p><p>ActiveACL (as in <em>active control lists</em>) is based on PhpGacl and claims to be highly scalable, having optimized database access and caching. Permissions range from simple (controller/action) to object level, are assigned at runtime, and may be grouped and inherited.</p><p>To me, the documentation and implementation seems overly complicated and confusing. ActiveACL creates and manages ten (10) tables in the database. The <a href="http://phpgacl.sourceforge.net/demo/phpgacl/docs/manual.html">phpgacl manual</a>  is helpful though. Here&#39;s how I think it works (mapping their terminology to more common words):<br /> </p><p>Let&#39;s say we group our users (&quot;requesters&quot;) into roles (&quot;groups&quot;). Each user may or may not access different objects (&quot;targets&quot;) on the site. Targets can be models, individual objects in a model, controllers, and individual actions in a controller. </p><p>We assign access restrictions to each role group, and/or to individual requesters; those lower in the  tree override permissions higher up. So if &quot;John&quot; is an &quot;Moderator&quot; with access to all Articles, we can  keep him from accessing a specific article (e.g. &quot;Privacy Policy&quot;) by creating an access-denied for that one instance. </p><p>ActiveACL adds another table, called Section which is simply a way of categorizing access objects for the user interface (e.g. &quot;Rooms&quot;, &quot;Floors&quot;, &quot;People&quot;) but have nothing to do with actual groups in the tree. (This seems to add unnecessary complexity because our models most likely already have attributes for organizing large data sets). </p><p>ActiveACL can be used not just for managing user groups/roles, but other application domains like  server permissions, or maybe even modeling of engineering constraints. </p><h2>Authorization Plugin</h2><p><a href="http://www.writertopia.com/developers/authorization">http://www.writertopia.com/developers/authorization</a>  </p><p><a href="http://rubyforge.org/projects/authorization/">http://rubyforge.org/projects/authorization/</a> </p><p>(Version 1.0, September, 2006, low activity) </p><p>The Authorization plug-in provides role based authorization, along with a number of Railsey sugar like dynamic methods and a little grammer parser that potentially enhances the programming experience and readability of your code (a la domain specific languages, DSL). It is compatible with ActsAsAuthenticated plugin out of the box. Documentation is comprehensible, and good test coverage is provided.<br /></p><p>User objects just need to implement a <em>has_role?</em> method, using the provided <em>acts_as_authorized_user</em>. And models then use <em>acts_as_authorizable</em>. </p><p>Roles can be authorized for the entire application, a model class, or a specific object. The plugin provides a way of checking authorization at the class or instance method level using <em>permit</em> and <em>permit?</em> methods. It also provides english-like dynamic methods like &quot;user.is_manager_of project&quot; (where &quot;user&quot; acts as authorized, &quot;manager&quot; is a role, and &quot;project&quot; is an authorizable model). You can specify how control is redirected if authorization is denied. </p><p>Roles are set by <em>has_role</em> and <em>accepts_role</em> methods, with optional scope (such as <em>user.has_role &#39;site_admin&#39;</em> , or <em>user.has_role &#39;moderator&#39;, group</em>).  Models set roles for specific users (such as <em>project.accepts_role &#39;manager&#39;, user</em>). Then, dynamic methods let you say things like <em>user.is_manager_of? project</em>     </p><p>Cool! </p><h2>Goldberg</h2><p><a href="http://goldberg.240gl.org/">http://goldberg.240gl.org/</a> </p><p><a href="http://rubyforge.org/projects/goldberg/">http://rubyforge.org/projects/goldberg/</a> </p><p>(Version 0.2.0, April 2007, active) </p><p>The Goldberg plugin is an example of a high level generator that includes both authorization and authentication. It&#39;s like a framework built on top of the Rails framework, but actually sits beside it because you continue to develop your Rails app as usual, Goldberg does not interfere. You don&#39;t have to write any Goldberg-specific code in your application or use its API.</p><p>You define Roles (which can be has subgroup hierarchy), and assign permissions to the roles. A permssion is a controller/action that the role may access. Then you assign users to roles.  </p><p>Goldberg installs as application-wide before-filters (if not exactly, at least conceptually) that examines the routed controller/action against its database of permissions (&quot;credentials&quot;) for the current logged in user. Credentials are stored in the current session minimizing the need for database access between page loads.  </p><p>That&#39;s just the beginning. Goldberg also provides a little hierarchical page manager (approaching a CMS) for static content; a menu manager for redirecting to pages or any arbitrary controller/action; and a theme system for dynamically re-skinning your application. It does not impose a specific markup on you, however. Finally there is an API for custom access control within your application.   </p><h2>Defense in Depth -- Model Level Security </h2><p><a href="http://www.perens.com/FreeSoftware/ModelSecurity/Tutorial.html">http://www.perens.com/FreeSoftware/ModelSecurity/Tutorial.html</a>  </p><p><a href="http://rubyforge.org/projects/model-security/">http://rubyforge.org/projects/model-security/</a> </p><p>(Release 0.0.9 November, 2005, inactive)<br /></p><p>Second level of defense. You still use your views to hide links to unauthorized actions, and set before_filter&#39;s in controllers to prevent unauthorized action methods from executing. But should someone get through, the model can also provide security.</p><p>The <em>ModelSecurity</em> gem is a generator. It provides for example <em>let_read, let_write</em>, and <em>let_access</em> added to model declarations, allow fine grained permissions to a whole model or separate attributes.</p><p>Includes a user model and UserSuport mixin. (Seems to been written before AAA so integration with AAA requires investigation). </p><p>Includes a ModelSecurityHelper which makes fields conform to the model security settings (eg makes form fields hidden or read-only).</p><p>Looks like a well thought-out generalized solution. My concern is the performance overhead this generalization requires, whether it plays well with various other helpers, AJAX, etc. Maybe its too scaffold oriented,  and simply just overkill.  </p><h2>Conclusions</h2><p>If your requirements are pretty simple, just a few roles like Visitor, User, and Admin, and don&#39;t need a lot of granularity (just control access to specific controller/actions) then you could use the convenient acl_system2, or just roll your own.</p><p>If you&#39;re looking for a high level, well designed tool to build fairly conventional sites quickly in Rails, then Goldberg is a good shot. It has a lot of commonly needed features built in. Why rebuild it yourself each time? </p><p>On the other hand, if you&#39;re building an application with more complex authorization requirements, the Authorization plugin seems a very good bet. For most people it may be overkill. But any kind of groupware or social networking site may benefit from this one.<br /></p><p>&nbsp;</p></p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
        <p>Last modified on May 15, 2007 9:54:54 PM by <a href="http://www.vaporbase.com/roles/3">linoj</a></p>
        <p>



<div>
   <p class="xar-cm-note xar-sub">
 Note: Comments are owned by the poster. We are not responsible for their content. </p>
</div>
    <div class="xar-accent-outline xar-cm-comment">
    <div>
         <a name="84"></a>
                <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" class="xar-cm-actions">
                    <div>
                        <input type="hidden" name="header[modid]" value="151" />
                        <input type="hidden" name="header[itemtype]" value="9" />
                        <input type="hidden" name="header[objectid]" value="124" />
                        <input type="hidden" name="header[pid]" value="84" />
                        <input type="hidden" name="receipt[returnurl][decoded]" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
                        <input type="hidden" name="receipt[returnurl][encoded]" value="http%3A%2F%2Fwww.vaporbase.com%2Fpostings%2FAuthorization_in_Rails%3F%26amp%3Bdepth%3D1%26amp%3Border%3D1%26amp%3Bsortby%3D2%26amp%3Brender%3Dflat" />
                        <input type="hidden" name="receipt[action]" value="reply" /> 
                        <input type="submit" name="submit" id="submit-reply84" value="Reply" />
                   </div>
               </form>

                <h4>Authorization in Rails</h4>
<!-- show changelog -->
<!-- end changelog -->
           <span class="xar-sub">
 Posted by:                     Anonymous on                 May 17, 2007 02:42 PM</span>
       </div>
       <div class="xar-accent xar-cm-comment">
                Very nice overview, thanks! 

i am trying to get running some ACL plugin/gem under Hobo and spent a lot of time trying to get Simple Access Control plugin running :-/

Perhaps, i give up with S.A.C. and try acl_system2 now 
                <p>
                    <a href="http://www.vaporbase.com/?module=comments&amp;func=display&amp;cid=84" title="Permalink" rel="bookmark">
                       #
                   </a>
               </p>

       </div>

</div>

    <div class="xar-accent-outline xar-cm-comment">
    <div>
         <a name="125"></a>
                <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" class="xar-cm-actions">
                    <div>
                        <input type="hidden" name="header[modid]" value="151" />
                        <input type="hidden" name="header[itemtype]" value="9" />
                        <input type="hidden" name="header[objectid]" value="124" />
                        <input type="hidden" name="header[pid]" value="125" />
                        <input type="hidden" name="receipt[returnurl][decoded]" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
                        <input type="hidden" name="receipt[returnurl][encoded]" value="http%3A%2F%2Fwww.vaporbase.com%2Fpostings%2FAuthorization_in_Rails%3F%26amp%3Bdepth%3D1%26amp%3Border%3D1%26amp%3Bsortby%3D2%26amp%3Brender%3Dflat" />
                        <input type="hidden" name="receipt[action]" value="reply" /> 
                        <input type="submit" name="submit" id="submit-reply125" value="Reply" />
                   </div>
               </form>

                <h4>acl_system2</h4>
<!-- show changelog -->
<!-- end changelog -->
           <span class="xar-sub">
 Posted by:                     Anonymous on                 September 18, 2007 10:15 PM</span>
       </div>
       <div class="xar-accent xar-cm-comment">
                Just as an FYI - I'm resurrecting acl_system2, with the blessings of its original author. It's new home is here:

<a href="http://rubyforge.org/projects/aclsystem" target="_blank">http://rubyforge.org/projects/aclsystem</a>

-Bill (bkocik at gmail dot com)                <p>
                    <a href="http://www.vaporbase.com/?module=comments&amp;func=display&amp;cid=125" title="Permalink" rel="bookmark">
                       #
                   </a>
               </p>

       </div>

</div>

    <div class="xar-accent-outline xar-cm-comment">
    <div>
         <a name="173"></a>
                <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" class="xar-cm-actions">
                    <div>
                        <input type="hidden" name="header[modid]" value="151" />
                        <input type="hidden" name="header[itemtype]" value="9" />
                        <input type="hidden" name="header[objectid]" value="124" />
                        <input type="hidden" name="header[pid]" value="173" />
                        <input type="hidden" name="receipt[returnurl][decoded]" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
                        <input type="hidden" name="receipt[returnurl][encoded]" value="http%3A%2F%2Fwww.vaporbase.com%2Fpostings%2FAuthorization_in_Rails%3F%26amp%3Bdepth%3D1%26amp%3Border%3D1%26amp%3Bsortby%3D2%26amp%3Brender%3Dflat" />
                        <input type="hidden" name="receipt[action]" value="reply" /> 
                        <input type="submit" name="submit" id="submit-reply173" value="Reply" />
                   </div>
               </form>

                <h4>Authorization in Rails</h4>
<!-- show changelog -->
<!-- end changelog -->
           <span class="xar-sub">
 Posted by:                     Anonymous on                 October 29, 2007 06:25 PM</span>
       </div>
       <div class="xar-accent xar-cm-comment">
                Very nice overview.  I had done my own Google search and evaluation, but had missed several of the ones you list here.

Thanks!                <p>
                    <a href="http://www.vaporbase.com/?module=comments&amp;func=display&amp;cid=173" title="Permalink" rel="bookmark">
                       #
                   </a>
               </p>

       </div>

</div>

    <div class="xar-accent-outline xar-cm-comment">
    <div>
         <a name="237"></a>
                <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" class="xar-cm-actions">
                    <div>
                        <input type="hidden" name="header[modid]" value="151" />
                        <input type="hidden" name="header[itemtype]" value="9" />
                        <input type="hidden" name="header[objectid]" value="124" />
                        <input type="hidden" name="header[pid]" value="237" />
                        <input type="hidden" name="receipt[returnurl][decoded]" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
                        <input type="hidden" name="receipt[returnurl][encoded]" value="http%3A%2F%2Fwww.vaporbase.com%2Fpostings%2FAuthorization_in_Rails%3F%26amp%3Bdepth%3D1%26amp%3Border%3D1%26amp%3Bsortby%3D2%26amp%3Brender%3Dflat" />
                        <input type="hidden" name="receipt[action]" value="reply" /> 
                        <input type="submit" name="submit" id="submit-reply237" value="Reply" />
                   </div>
               </form>

                <h4>Re: Authorization in Rails</h4>
<!-- show changelog -->
<!-- end changelog -->
           <span class="xar-sub">
 Posted by:                     Anonymous on                 December 13, 2007 12:51 AM</span>
       </div>
       <div class="xar-accent xar-cm-comment">
                Did I see role_requirement in this article? Great plugin. Simple. Powerful. I'm using it in my project with no problems and great results. Easy to implement model-object security as well. Check it out: <a href="http://code.google.com/p/rolerequirement/" target="_blank">http://code.google.com/p/rolerequirement/</a>                <p>
                    <a href="http://www.vaporbase.com/?module=comments&amp;func=display&amp;cid=237" title="Permalink" rel="bookmark">
                       #
                   </a>
               </p>

       </div>

</div>

    <div class="xar-accent-outline xar-cm-comment">
    <div>
         <a name="413"></a>
                <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" class="xar-cm-actions">
                    <div>
                        <input type="hidden" name="header[modid]" value="151" />
                        <input type="hidden" name="header[itemtype]" value="9" />
                        <input type="hidden" name="header[objectid]" value="124" />
                        <input type="hidden" name="header[pid]" value="413" />
                        <input type="hidden" name="receipt[returnurl][decoded]" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
                        <input type="hidden" name="receipt[returnurl][encoded]" value="http%3A%2F%2Fwww.vaporbase.com%2Fpostings%2FAuthorization_in_Rails%3F%26amp%3Bdepth%3D1%26amp%3Border%3D1%26amp%3Bsortby%3D2%26amp%3Brender%3Dflat" />
                        <input type="hidden" name="receipt[action]" value="reply" /> 
                        <input type="submit" name="submit" id="submit-reply413" value="Reply" />
                   </div>
               </form>

                <h4>Authorization in Rails</h4>
<!-- show changelog -->
<!-- end changelog -->
           <span class="xar-sub">
 Posted by:                     Anonymous on                 July 19, 2008 02:54 PM</span>
       </div>
       <div class="xar-accent xar-cm-comment">
                Is the information provided here still valid ?                <p>
                    <a href="http://www.vaporbase.com/?module=comments&amp;func=display&amp;cid=413" title="Permalink" rel="bookmark">
                       #
                   </a>
               </p>

       </div>

</div>

    <div class="xar-accent-outline xar-cm-comment">
    <div>
         <a name="417"></a>
                <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" class="xar-cm-actions">
                    <div>
                        <input type="hidden" name="header[modid]" value="151" />
                        <input type="hidden" name="header[itemtype]" value="9" />
                        <input type="hidden" name="header[objectid]" value="124" />
                        <input type="hidden" name="header[pid]" value="417" />
                        <input type="hidden" name="receipt[returnurl][decoded]" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
                        <input type="hidden" name="receipt[returnurl][encoded]" value="http%3A%2F%2Fwww.vaporbase.com%2Fpostings%2FAuthorization_in_Rails%3F%26amp%3Bdepth%3D1%26amp%3Border%3D1%26amp%3Bsortby%3D2%26amp%3Brender%3Dflat" />
                        <input type="hidden" name="receipt[action]" value="reply" /> 
                        <input type="submit" name="submit" id="submit-reply417" value="Reply" />
                   </div>
               </form>

                <h4>Re: Authorization in Rails</h4>
<!-- show changelog -->
<!-- end changelog -->
           <span class="xar-sub">
 Posted by:                     Anonymous on                 August 07, 2008 08:33 AM</span>
       </div>
       <div class="xar-accent xar-cm-comment">
                yep but acl_system2 is hosting on github now                <p>
                    <a href="http://www.vaporbase.com/?module=comments&amp;func=display&amp;cid=417" title="Permalink" rel="bookmark">
                       #
                   </a>
               </p>

       </div>

</div>

    <div class="xar-accent-outline xar-cm-comment">
    <div>
         <a name="537"></a>
                <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" class="xar-cm-actions">
                    <div>
                        <input type="hidden" name="header[modid]" value="151" />
                        <input type="hidden" name="header[itemtype]" value="9" />
                        <input type="hidden" name="header[objectid]" value="124" />
                        <input type="hidden" name="header[pid]" value="537" />
                        <input type="hidden" name="receipt[returnurl][decoded]" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
                        <input type="hidden" name="receipt[returnurl][encoded]" value="http%3A%2F%2Fwww.vaporbase.com%2Fpostings%2FAuthorization_in_Rails%3F%26amp%3Bdepth%3D1%26amp%3Border%3D1%26amp%3Bsortby%3D2%26amp%3Brender%3Dflat" />
                        <input type="hidden" name="receipt[action]" value="reply" /> 
                        <input type="submit" name="submit" id="submit-reply537" value="Reply" />
                   </div>
               </form>

                <h4>Authorization in Rails</h4>
<!-- show changelog -->
<!-- end changelog -->
           <span class="xar-sub">
 Posted by:                     Anonymous on                 January 28, 2009 03:32 AM</span>
       </div>
       <div class="xar-accent xar-cm-comment">
                Thought I'd update this as I was looking for information and just found a couple, more recent options. Take a look at AuthLogic and also Lockdown. Both seem pretty popular these days.                <p>
                    <a href="http://www.vaporbase.com/?module=comments&amp;func=display&amp;cid=537" title="Permalink" rel="bookmark">
                       #
                   </a>
               </p>

       </div>

</div>

    <div class="xar-accent-outline xar-cm-comment">
    <div>
         <a name="646"></a>
                <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" class="xar-cm-actions">
                    <div>
                        <input type="hidden" name="header[modid]" value="151" />
                        <input type="hidden" name="header[itemtype]" value="9" />
                        <input type="hidden" name="header[objectid]" value="124" />
                        <input type="hidden" name="header[pid]" value="646" />
                        <input type="hidden" name="receipt[returnurl][decoded]" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
                        <input type="hidden" name="receipt[returnurl][encoded]" value="http%3A%2F%2Fwww.vaporbase.com%2Fpostings%2FAuthorization_in_Rails%3F%26amp%3Bdepth%3D1%26amp%3Border%3D1%26amp%3Bsortby%3D2%26amp%3Brender%3Dflat" />
                        <input type="hidden" name="receipt[action]" value="reply" /> 
                        <input type="submit" name="submit" id="submit-reply646" value="Reply" />
                   </div>
               </form>

                <h4>Re: Authorization in Rails</h4>
<!-- show changelog -->
<!-- end changelog -->
           <span class="xar-sub">
 Posted by:                     Anonymous on                 March 09, 2010 10:40 PM</span>
       </div>
       <div class="xar-accent xar-cm-comment">
                The one thing that continues to bug me about all these systems is that they are not DRY.

I spend all this time specifying on my *controller* the types of user who are permitted to access a resource, and then over in the view I have to say the same thing all over again.

I am thinking it would make more sense to make a conditional link_to which determines which controller and action will be called, then asks that controller if the action is accessible, and only shows the link if it is.  A lot of these authorisation systems do have enough state information to be able to do this, so it's astonishing that nobody has completed the last part of the exercise.
                <p>
                    <a href="http://www.vaporbase.com/?module=comments&amp;func=display&amp;cid=646" title="Permalink" rel="bookmark">
                       #
                   </a>
               </p>

       </div>

</div>

    <div class="xar-accent-outline xar-cm-comment">
    <div>
         <a name="670"></a>
                <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" class="xar-cm-actions">
                    <div>
                        <input type="hidden" name="header[modid]" value="151" />
                        <input type="hidden" name="header[itemtype]" value="9" />
                        <input type="hidden" name="header[objectid]" value="124" />
                        <input type="hidden" name="header[pid]" value="670" />
                        <input type="hidden" name="receipt[returnurl][decoded]" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
                        <input type="hidden" name="receipt[returnurl][encoded]" value="http%3A%2F%2Fwww.vaporbase.com%2Fpostings%2FAuthorization_in_Rails%3F%26amp%3Bdepth%3D1%26amp%3Border%3D1%26amp%3Bsortby%3D2%26amp%3Brender%3Dflat" />
                        <input type="hidden" name="receipt[action]" value="reply" /> 
                        <input type="submit" name="submit" id="submit-reply670" value="Reply" />
                   </div>
               </form>

                <h4>apple iphone for sale</h4>
<!-- show changelog -->
<!-- end changelog -->
           <span class="xar-sub">
 Posted by:                     Anonymous on                 July 22, 2010 03:01 AM</span>
       </div>
       <div class="xar-accent xar-cm-comment">
                I appreciate your bright ideas in this article. Great work!
We share the opinion on and I really enjoy reading your article.
                <p>
                    <a href="http://www.vaporbase.com/?module=comments&amp;func=display&amp;cid=670" title="Permalink" rel="bookmark">
                       #
                   </a>
               </p>

       </div>

</div>

<script type="text/javascript" src="modules/base/xartemplates/includes/submitonce.js"></script>
  <h3>Post a new comment</h3> 
  <form action="http://www.vaporbase.com/?module=comments&amp;func=reply" method="post" name="post" id="post" onSubmit="submitonce(this)" id="post"
 >
   <div class="xar-ib-wrapper xar-accent-outline">
<div class="xar-ib-actionpanel xar-accent">
         <span>
 BBCode Actions             : 
          </span>
          <span>
            <!-- New xaraya style link tag <xar:set name="$stylesheet">xarTplAddStyleLink('bbcode', 'bbcode')</xar:set> -->

<span>
    <input type="button" accesskey="z" name="addbbcode18" value=" p " onclick="bbstyle(18)" onmouseover="document.post.helpbox.value='Paragraph: [p]text[/p] (alt+z)'; return true" />
    <input type="button" accesskey="b" name="addbbcode0" value=" b " style="font-weight:bold;" onclick="bbstyle(0)" onmouseover="document.post.helpbox.value='Bold text: [b]text[/b] (alt+b)'; return true" />
    <input type="button" accesskey="i" name="addbbcode2" value=" i " style="font-style:italic;" onclick="bbstyle(2)" onmouseover="document.post.helpbox.value='Italic text: [i]text[/i] (alt+i)'; return true" />
    <input type="button" accesskey="u" name="addbbcode4" value=" u " style="font-style: underline;" onclick="bbstyle(4)" onmouseover="document.post.helpbox.value='Underline text: [u]text[/u] (alt+u)'; return true" />
    <input type="button" accesskey="q" name="addbbcode6" value="Quote" onclick="bbstyle(6)" onmouseover="document.post.helpbox.value='Quote text: [quote]text[/quote] (alt+q)'; return true" />
    <input type="button" accesskey="c" name="addbbcode8" value="Code" onclick="bbstyle(8)" onmouseover="document.post.helpbox.value='Code display: [code=xml]code[/code] (alt+c)'; return true" />
    <input type="button" accesskey="p" name="addbbcode14" value="Img" onclick="bbstyle(14)" onmouseover="document.post.helpbox.value='Insert image: [img]http://image_url[/img] (alt+p)'; return true" />
    <input type="button" accesskey="w" name="addbbcode16" value="URL" style="text-decoration: underline;" onclick="bbstyle(16)" onmouseover="document.post.helpbox.value='Insert URL: [url]http://url[/url] or [url=http://url]URL text[/url] (alt+w)'; return true" />
</span>
<label for="addbbcode20">
 Font color     :
</label>
<select name="addbbcode20" onchange="bbfontstyle('[color=' + this.form.addbbcode20.options[this.form.addbbcode20.selectedIndex].value + ']', '[/color]');this.selectedIndex=0;" onmouseover="document.post.helpbox.value='Font color: [color=red]text[/color] Tip: you can also use color=#FF0000'; return true">
   <option style="color:black; background-color: #FAFAFA" value="#444444" class="xar-bbcode-genmed">
 Default </option>
   <option style="color:darkred; background-color: #FAFAFA" value="darkred" class="xar-bbcode-genmed">
 Dark Red </option>
   <option style="color:red; background-color: #FAFAFA" value="red" class="xar-bbcode-genmed">
 Red </option>
   <option style="color:orange; background-color: #FAFAFA" value="orange" class="xar-bbcode-genmed">
 Orange </option>
   <option style="color:brown; background-color: #FAFAFA" value="brown" class="xar-bbcode-genmed">
 Brown </option>
   <option style="color:yellow; background-color: #FAFAFA" value="yellow" class="xar-bbcode-genmed">
 Yellow </option>
   <option style="color:green; background-color: #FAFAFA" value="green" class="xar-bbcode-genmed">
 Green </option>
   <option style="color:olive; background-color: #FAFAFA" value="olive" class="xar-bbcode-genmed">
 Olive </option>
   <option style="color:cyan; background-color: #FAFAFA" value="cyan" class="xar-bbcode-genmed">
 Cyan </option>
   <option style="color:blue; background-color: #FAFAFA" value="blue" class="xar-bbcode-genmed">
 Blue </option>
   <option style="color:darkblue; background-color: #FAFAFA" value="darkblue" class="xar-bbcode-genmed">
 Dark Blue </option>
   <option style="color:indigo; background-color: #FAFAFA" value="indigo" class="xar-bbcode-genmed">
 Indigo </option>
   <option style="color:violet; background-color: #FAFAFA" value="violet" class="xar-bbcode-genmed">
 Violet </option>
   <option style="color:white; background-color: #FAFAFA" value="white" class="xar-bbcode-genmed">
 White </option>
   <option style="color:black; background-color: #FAFAFA" value="black" class="xar-bbcode-genmed">
 Black </option>
</select>
<label for="addbbcode22">
 Font size     :
</label>
<select name="addbbcode22" onchange="bbfontstyle('[size=' + this.form.addbbcode22.options[this.form.addbbcode22.selectedIndex].value + ']', '[/size]')" onmouseover="document.post.helpbox.value='Font size: [size=x-small]small text[/size]'; return true">
   <option value="7" class="xar-bbcode-genmed">
 Tiny </option>
   <option value="9" class="xar-bbcode-genmed">
 Small </option>
   <option value="12" selected="selected" class="xar-bbcode-genmed">
 Normal </option>
   <option value="18" class="xar-bbcode-genmed">
 Large </option>
   <option value="24" class="xar-bbcode-genmed">
 Huge     </option>
</select>
<a href="javascript:bbstyle(-1)" class="xar-bbcode-genmed" onmouseover="document.post.helpbox.value='Close all open bbCode tags'; return true">Close Tags</a>
<span class="gensmall">
    <input type="text" name="helpbox" size="50" maxlength="100" class="helpline" value="Tip: Styles can be applied quickly to selected text." />
</span>         </span>
       </div>
       <div class="xar-ib-leftpanelshort">
         <p>
 Name :
              Anonymous</p>
         <label for="package-title">
 Title: </label>
            <input class="xar-ib-field" type="text" name="package[title]" id="package-title" value="Authorization in Rails" tabindex="1" />
         <label for="package-text">
 Comment: </label>
<textarea class="xar-ib-fieldtext" name="package[text]" id="package-text" tabindex="2"></textarea>

          <input type="hidden" name="header[modid]" id="header-modid" value="151" /> 
          <input type="hidden" name="header[objectid]" id="header-objectid" value="124" /> 
          <input type="hidden" name="header[itemtype]" id="header-itemtype" value="9" />
<input type="hidden" name="header[pid]" id="header-pid" value="0" />
          <input type="hidden" name="receipt[returnurl][decoded]" id="receipt-returnurl-decoded" value="http://www.vaporbase.com/postings/Authorization_in_Rails?&amp;depth=1&amp;order=1&amp;sortby=2&amp;render=flat" />
          <!--<input type="hidden" name="receipt[returnurl][encoded]" id="receipt-returnurl-encoded" value="#$receipt['returnurl']['encoded']#" />-->
          <input type="hidden" name="receipt[action]" id="receipt-action" /> 
          <input type="submit" id="receipt-action-preview" onclick="document.getElementById('receipt-action').value='preview'" value="Preview" /> 
          <input type="submit" id="receipt-action-submit" onclick="document.getElementById('receipt-action').value='submit'" value="Submit" />
       </div>
</div>
 </form>
</p>
        <p></p>
        <p></p>
</div>
   </channel>
</rss>
