<?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>steffenbartsch &#187; declarative_authorization</title>
	<atom:link href="http://steffenbartsch.com/blog/tag/declarative_authorization/feed/" rel="self" type="application/rss+xml" />
	<link>http://steffenbartsch.com/blog</link>
	<description>Security, Usability, Rails</description>
	<lastBuildDate>Thu, 15 Apr 2010 07:27:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>declarative_authorization 0.4</title>
		<link>http://steffenbartsch.com/blog/2009/11/declarative_authorization-0-4/</link>
		<comments>http://steffenbartsch.com/blog/2009/11/declarative_authorization-0-4/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 15:37:37 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Authorization]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=139</guid>
		<description><![CDATA[I just pushed the decl_auth 0.4 gem to gemcutter.
Major changes since the 0.3 release:


Improved DSL: allow nesting of has_many associations for if_permitted_to and if_attribute:

has_permission_on :companies, :to =&#62; :read do
  if_attribute :branches =&#62; &#123; 
      :manager =&#62; &#123; :last_name =&#62; is &#123; user.last_name &#125; &#125; &#125;
  if_permitted_to :read, :branches
end



Simplified [...]]]></description>
			<content:encoded><![CDATA[<p>I just pushed the decl_auth 0.4 gem to gemcutter.</p>
<p><strong>Major changes</strong> since the <a href="http://steffenbartsch.com/blog/2009/04/releasing-declarative_authorization-03/">0.3 release</a>:</p>
<ul>
<li>
<p><strong>Improved DSL</strong>: allow nesting of has_many associations for <a href="http://www.tzi.org/~sbartsch/declarative_authorization/master/classes/Authorization/Reader/AuthorizationRulesReader.html">if_permitted_to and if_attribute</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">has_permission_on <span style="color:#ff3333; font-weight:bold;">:companies</span>, <span style="color:#ff3333; font-weight:bold;">:to</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:read</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  if_attribute <span style="color:#ff3333; font-weight:bold;">:branches</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> 
      <span style="color:#ff3333; font-weight:bold;">:manager</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:last_name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> is <span style="color:#006600; font-weight:bold;">&#123;</span> user.<span style="color:#9900CC;">last_name</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
  if_permitted_to <span style="color:#ff3333; font-weight:bold;">:read</span>, <span style="color:#ff3333; font-weight:bold;">:branches</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</li>
<li>
<p><strong>Simplified controller authorization</strong> for RESTful controllers with <a href="http://www.tzi.org/~sbartsch/declarative_authorization/master/classes/Authorization/AuthorizationInController/ClassMethods.html">filter_resource_access</a>. Instead of multiple filter_access_to statements, one line is often sufficient:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> BranchController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
  filter_resource_access <span style="color:#ff3333; font-weight:bold;">:nested_in</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:companies</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</li>
<li>
<p><strong>Controller namespace handling</strong>.  Now, the decl_auth context in controllers is prefixed by the underscored namespace by default.  Thanks <a href="http://github.com/Odaeus/declarative_authorization/commit/4ae39f364b9b79837f489c51940bc4233235c384">for</a> <a href="http://github.com/ghart/declarative_authorization/commit/bc48aad2cb0b5319cc8dfd400b51b85a7a04bc55">all</a> <a href="http://github.com/mconnell/declarative_authorization/commit/1edc6d0399881c58fcf3325478869727cdbc9be1">those</a> <a href="http://github.com/viva/declarative_authorization/commit/f3376b1cf557e119511479acb2c702d9139d7c44">implementation</a> <a href="http://github.com/jeroenvandijk/declarative_authorization/commit/1f9c2e626440aab4167999a3bc32c79ab148af2d">suggestions</a> in the Github forks.</p>
</li>
<li>
<p><strong>Improved STI handling</strong> by allowing to explicitly define the model&#8217;s decl_auth context.  Just override AModel.decl_auth_context.</p>
</li>
<li>
<p><strong>Test helper</strong> to <a href="http://www.tzi.org/~sbartsch/declarative_authorization/master/classes/Authorization/TestHelper.html">test authorization rules</a>, e.g.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">with_user a_normal_user <span style="color:#9966CC; font-weight:bold;">do</span>
  should_not_be_allowed_to <span style="color:#ff3333; font-weight:bold;">:update</span>, <span style="color:#ff3333; font-weight:bold;">:conferences</span>
  should_not_be_allowed_to <span style="color:#ff3333; font-weight:bold;">:read</span>, an_unpublished_conference
  should_be_allowed_to <span style="color:#ff3333; font-weight:bold;">:read</span>, a_published_conference
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

</li>
<li>
<p><strong>permitted_to?/! on model level</strong>. You may now use <a href="http://www.tzi.org/~sbartsch/declarative_authorization/master/classes/Authorization/AuthorizationInModel.html">those methods</a> in models as you are used to from controllers and views.</p>
</li>
<li>
<p><strong>Switched to gemcutter</strong> for gem distribution.</p>
</li>
<li>
<p><strong>Change support </strong>in the development support backend (I&#8217;ll write a separate Blog post on decl_auth change support soon)</p>
</li>
</ul>
<p>And lots of smaller fixes: full <a href="http://github.com/stffn/declarative_authorization/blob/master/CHANGELOG">change log</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2009/11/declarative_authorization-0-4/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Releasing declarative_authorization 0.3</title>
		<link>http://steffenbartsch.com/blog/2009/04/releasing-declarative_authorization-03/</link>
		<comments>http://steffenbartsch.com/blog/2009/04/releasing-declarative_authorization-03/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 20:00:12 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Authorization]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=122</guid>
		<description><![CDATA[I just pushed the 0.3 release for declarative_authorization to github.  declarative_authorization helps Rails developers to implement authorization in a declarative manner, cleanly separating authorization rules from application code and reusing the same policy for access control in model, view and controller.
So, what&#8217;s new in 0.3? Apart from smaller fixes and improvements, a few major items:

Gemified [...]]]></description>
			<content:encoded><![CDATA[<p>I just pushed the 0.3 release for <a title="declarative_authorization at Github" href="http://github.com/stffn/declarative_authorization">declarative_authorization</a> to github.  declarative_authorization helps Rails developers to implement authorization in a declarative manner, cleanly separating authorization rules from application code and reusing the same policy for access control in model, view and controller.</p>
<p>So, what&#8217;s new in 0.3? Apart from smaller fixes and improvements, a few major items:</p>
<ul>
<li>Gemified the plugin</li>
<li>Allow to globally enable model security by calling ActiveRecord::Base.using_access_control</li>
<li>New operator intersects_with</li>
<li>AND&#8217;ing attribute conditions in has_permission_to blocks</li>
</ul>
<p>Also, helping you in handling complex policies and using declarative_authorization correctly, a Rails Engines-based GUI has been implemented, with <a title="Graphically Browse Your Authorization Rules" href="http://steffenbartsch.com/blog/2009/02/browse-your-authorization-rules-graphically/">graphical policy browser</a> and <a title="Using Your Authorization Framework Correctly?" href="http://steffenbartsch.com/blog/2009/03/using-your-authorization-framework-correctly/">usage analyzer</a>. The <a href="http://github.com/stffn/declarative_authorization/blob/0f44a3a48b5932d05576f00d9bbbc060b583894c/CHANGELOG">full changelog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2009/04/releasing-declarative_authorization-03/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Your Authorization Framework Correctly?</title>
		<link>http://steffenbartsch.com/blog/2009/03/using-your-authorization-framework-correctly/</link>
		<comments>http://steffenbartsch.com/blog/2009/03/using-your-authorization-framework-correctly/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 13:04:57 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Authorization]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=110</guid>
		<description><![CDATA[Many projects employ authorization frameworks to control and enforce permissions. Custom-built or off-the-shelf, how sure are you that your projects are using the framework in the correct way? And have authorization checks at all the necessary locations in your code base?
One way, of course, is code review. Have knowledgeable people point out the mistakes by [...]]]></description>
			<content:encoded><![CDATA[<p>Many projects employ authorization frameworks to control and enforce permissions. Custom-built or off-the-shelf, how sure are you that your projects are using the framework in the correct way? And have authorization checks at all the necessary locations in your code base?</p>
<p>One way, of course, is <a title="Build Security In: Code Analysis" href="https://buildsecurityin.us-cert.gov/daisy/bsi/articles/best-practices/code/214-BSI.html">code review</a>. Have knowledgeable people point out the mistakes by looking over the code. Complete code reviews may be prohibitively expensive, though. Being a cross-cutting concern, you need to look at a lot of code for authorization aspects.</p>
<p><a title="Build Security In: Adapting Penetration Testing for Software Development Purposes" href="https://buildsecurityin.us-cert.gov/daisy/bsi/articles/best-practices/penetration/655-BSI.html">Penetration tests</a>: definitely necessary. Still, penetration testing isn&#8217;t likely to find a one-time error in the usage of the authorization framework. Achieving a high coverage is very expensive.</p>
<p>So, what about authorization-focussed <strong>static analysis</strong>? It would definitely improve code review efficiency. Commercial static analysis tools still primarily <a title="Fortify Taxonomy: Software Security Errors" href="http://www.fortify.com/vulncat/en/vulncat/index.html">look for programming errors</a>, though. As authorization checks are typically employed in a structured manner, they can be easily analyzed if the framework is known well by static analysis rule developers.</p>
<p>For Rails apps, our Rails authorization plugin <a title="The declarative_authorization Plugin" href="http://steffenbartsch.com/blog/2008/09/delclarative-authorization/">declarative_authorization</a> comes with  support of this kind. In the screenshot, controller authorization analysis is shown. Possible flaws are highlighted in yellow and red and the found problems are displayed in tool tips.</p>
<p><a href="http://steffenbartsch.com/blog/wp-content/uploads/2009/03/auth-usages.png"><img class="alignnone size-full wp-image-111" title="Authorization Usage Browser for declarative_authorization" src="http://steffenbartsch.com/blog/wp-content/uploads/2009/03/auth-usages.png" alt="Authorization Usage Browser for declarative_authorization" width="480" height="349" /></a></p>
<p>In the demo app, the authorization usage browser reveals which actions aren&#8217;t (properly) protected by authorization checks. For example, SessionsController#create is marked red for having no authorization check. This, of course, is intentional as this action allows users to login.</p>
<p>The yellow coloring of ConferencesController#index shows that this action is just generally protected and authorization constraints are not enforced. Again, this is intentional because index lists conferences and conference-specific authorization is checked at database query time. If other actions were marked in this way, the developer could easily make out the mistakes and correct potentionally highly critical bugs.</p>
<p>Try it out in the <a href="http://github.com/stffn/decl_auth_demo_app">declarative_authorization demo application</a>! And leave a note on whether this is of use to you.</p>
<p>For now, the tool analyzes authorization on controller level.  As declarative_authorization also comes with authorization for the model level and database query rewriting, a next step will be looking at issues in those areas as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2009/03/using-your-authorization-framework-correctly/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Graphically Browse Your Authorization Rules</title>
		<link>http://steffenbartsch.com/blog/2009/02/browse-your-authorization-rules-graphically/</link>
		<comments>http://steffenbartsch.com/blog/2009/02/browse-your-authorization-rules-graphically/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 21:34:13 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Authorization]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=99</guid>
		<description><![CDATA[It certainly helps to have the authorization rules in your Rails app defined in a clear DSL, such as the one offered by declarative_authorization. Still, with anything more than a few roles and models (let&#8217;s not even think about 200 models), it can be hard to maintain a good view of the whole rules set.
So, [...]]]></description>
			<content:encoded><![CDATA[<p>It certainly helps to have the authorization rules in your Rails app defined in a clear DSL, such as the one offered by <a title="The declarative_authorization Plugin" href="http://steffenbartsch.com/blog/2008/09/delclarative-authorization/">declarative_authorization</a>. Still, with anything more than a few roles and models (let&#8217;s not even think about <a title="Authorization for 90 Controllers, 200 Models (and Counting…)" href="http://steffenbartsch.com/blog/2008/09/authorization-for-90-controllers-200-models-and-counting/">200 models</a>), it can be hard to maintain a good view of the whole rules set.</p>
<p>So, how about a graphical browser of your authorization rules?  In particular inheritance between roles and privileges – and consequences thereof – may be much easier to grasp in a graphical way. This is how it looks in the <a title="decl_auth_demo_app Repo at Github" href="http://github.com/stffn/decl_auth_demo_app">declarative_authorization demo application</a>:</p>
<p><a href="http://steffenbartsch.com/blog/wp-content/uploads/2009/02/auth-rules-browser.png"><img class="alignnone size-full wp-image-100" title="Authorization Rules Browser" src="http://steffenbartsch.com/blog/wp-content/uploads/2009/02/auth-rules-browser.png" alt="Authorization Rules Browser" width="480" height="295" /></a></p>
<p>Roles are shown in colored ovals and are connected to privileges in the context boxes. Inheritance links between roles and privileges are displayed in black, with unfilled arrows. Filled circles on role-privilege links show additional rules that apply.</p>
<p>You can filter to dig deeper into the rules and limit the view to certain roles or contexts. Also, you can decide to only display those privileges that are explicitly stated in the authorization configuration or all privileges that the roles possess.</p>
<p><strong>If you are interested, give it a try. </strong> Either in the <a title="decl_auth_demo_app Repo at Github" href="http://github.com/stffn/decl_auth_demo_app">declarative_authorization demo application</a> or in your own application. The <a title="declarative_authorization Repo at Github" href="http://github.com/stffn/declarative_authorization">declarative_authorization README</a> tells you the one simple step to get it started. This feature requires graphviz for graph generation and Rails 2.3 for its Engine support.</p>
<p>On the long run, we&#8217;d like to integrate multiple abstraction levels for different viewing audiences and we might even add authorization rule editing capabilities.</p>
<p>What do you think? Does this help you as a developer or in discussions with non-technical customers about authorization?</p>
]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2009/02/browse-your-authorization-rules-graphically/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Discuss Usage of declarative_authorization at Google Groups</title>
		<link>http://steffenbartsch.com/blog/2008/12/discuss-usage-of-declarative_authorization-at-google-groups/</link>
		<comments>http://steffenbartsch.com/blog/2008/12/discuss-usage-of-declarative_authorization-at-google-groups/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 20:40:46 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=92</guid>
		<description><![CDATA[There now is a declarative_authorization discussion group at Google Groups. This group is a good place to discuss patterns of using the plugin. Thanks for setting it up, Mike.
]]></description>
			<content:encoded><![CDATA[<p>There now is a <a title="declarative_authorization at Google Groups" href="http://groups.google.com/group/declarative_authorization">declarative_authorization discussion group</a> at Google Groups. This group is a good place to discuss patterns of using the plugin. Thanks for setting it up, Mike.</p>
]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2008/12/discuss-usage-of-declarative_authorization-at-google-groups/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>declarative_authorization Issues Tracked at Lighthouse</title>
		<link>http://steffenbartsch.com/blog/2008/12/declarative_authorization-issues-tracked-at-lighthouse/</link>
		<comments>http://steffenbartsch.com/blog/2008/12/declarative_authorization-issues-tracked-at-lighthouse/#comments</comments>
		<pubDate>Tue, 02 Dec 2008 19:48:43 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=88</guid>
		<description><![CDATA[No more issue tracking in comments or direct e-mail!  To improve the development process and enable more collaborative development, I created a Lighthouse project for declarative_authorization.  Please direct all your suggestions and bug reports to there.
]]></description>
			<content:encoded><![CDATA[<p>No more issue tracking in comments or direct e-mail!  To improve the development process and enable more collaborative development, I created a <a title="declarative_authorization Lighthouse project" href="http://stffn.lighthouseapp.com/projects/20733-declarative_authorization">Lighthouse project for declarative_authorization</a>.  Please direct all your suggestions and bug reports to there.</p>
]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2008/12/declarative_authorization-issues-tracked-at-lighthouse/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Garlic: Plugin Tests against Various Rails Versions</title>
		<link>http://steffenbartsch.com/blog/2008/10/garlic-plugin-tests-against-various-rails-versions/</link>
		<comments>http://steffenbartsch.com/blog/2008/10/garlic-plugin-tests-against-various-rails-versions/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 20:52:16 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=80</guid>
		<description><![CDATA[With Rails 2.2 around the corner, I decided to implement a scalable testing infrastructure for the declarative_authorization plugin. One great thing to notice at the RailsConf Europe was Ian&#8217;s garlic.  Though only given as a side note in Ian&#8217;s talk on resources_controller, it provides a nice way of keeping your plugin tested against all those [...]]]></description>
			<content:encoded><![CDATA[<p>With <a title="Riding Rails: Rails 2.2 RC1: i18n, thread safety, docs, etag/last-modified, JRuby/1.9 compatibility" href="http://weblog.rubyonrails.com/2008/10/24/rails-2-2-rc1-i18n-thread-safety-docs-etag-last-modified">Rails 2.2 around the corner</a>, I decided to implement a scalable testing infrastructure for the <a href="http://github.com/stffn/declarative_authorization">declarative_authorization</a> plugin. One great thing to notice at the RailsConf Europe was Ian&#8217;s <a href="http://github.com/ianwhite/garlic">garlic</a>.  Though only given as a side note in Ian&#8217;s talk on resources_controller, it provides a nice way of keeping your plugin tested against all those Rails versions.</p>
<p>Very easy to set up.  Only add to your <a title="Rakefile from declarative_authorization at github" href="http://github.com/stffn/declarative_authorization/tree/master/Rakefile">Rakefile</a> a few lines that run garlic:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">directory</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#996600;">'garlic'</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#996600;">'garlic/lib/garlic_tasks'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span>, <span style="color:#996600;">'garlic'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
desc <span style="color:#996600;">&quot;clone the garlic repo (for running ci tasks)&quot;</span>
task <span style="color:#ff3333; font-weight:bold;">:get_garlic</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  sh <span style="color:#996600;">&quot;git clone git://github.com/ianwhite/garlic.git garlic&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And define the tasks that garlic should perform for you.  In the declarative_authorization case, garlic should retrieve the plugin from the current path and take a few Rails versions as targets. For the test run, garlic just needs to run &#8220;rake&#8221;. This is the necessary <a title="garlic_example.rb from declarative_authorization at github" href="http://github.com/stffn/declarative_authorization/tree/master/garlic_example.rb">recipe</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">garlic <span style="color:#9966CC; font-weight:bold;">do</span>
  repo <span style="color:#996600;">'rails'</span>, <span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'git://github.com/rails/rails'</span>
  repo <span style="color:#996600;">'declarative_authorization'</span>, <span style="color:#ff3333; font-weight:bold;">:path</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#996600;">'.'</span>
&nbsp;
  target <span style="color:#996600;">'edge'</span>
  target <span style="color:#996600;">'2.1-stable'</span>, <span style="color:#ff3333; font-weight:bold;">:branch</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'origin/2-1-stable'</span>
  target <span style="color:#996600;">'2.2.0-RC1'</span>, <span style="color:#ff3333; font-weight:bold;">:tag</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'v2.2.0'</span>
&nbsp;
  all_targets <span style="color:#9966CC; font-weight:bold;">do</span>
    prepare <span style="color:#9966CC; font-weight:bold;">do</span>
      plugin <span style="color:#996600;">'declarative_authorization'</span>, <span style="color:#ff3333; font-weight:bold;">:clone</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#0000FF; font-weight:bold;">true</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    run <span style="color:#9966CC; font-weight:bold;">do</span>
      cd <span style="color:#996600;">&quot;vendor/plugins/declarative_authorization&quot;</span> <span style="color:#9966CC; font-weight:bold;">do</span>
        sh <span style="color:#996600;">&quot;rake&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Thus, all that is needed to check my current declarative_authorization branch against all defined Rails versions is</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rake get_garlic <span style="color: #666666; font-style: italic;"># just once</span>
rake garlic:all</pre></div></div>

<p>Great, all declarative_authorization tests pass on 2.2.0-RC1!</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">All specified targets passed: edge, <span style="color: #000000;">2.1</span>-stable, 2.2.0-RC1</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2008/10/garlic-plugin-tests-against-various-rails-versions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Authorization for 90 Controllers, 200 Models (and Counting&#8230;)</title>
		<link>http://steffenbartsch.com/blog/2008/09/authorization-for-90-controllers-200-models-and-counting/</link>
		<comments>http://steffenbartsch.com/blog/2008/09/authorization-for-90-controllers-200-models-and-counting/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 18:41:27 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Authorization]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=51</guid>
		<description><![CDATA[One of the interesting comments on our RailsConf Europe presentation on declarative_authorization was offered by Timo Hentschel.  He stated that on the Rails CRM project with 90 Controllers and 200 Models that he is working on the declarative_authorization approach was simply not viable.  Projects of this size are currently not the target of [...]]]></description>
			<content:encoded><![CDATA[<p>One of the interesting comments on our RailsConf Europe <a href="http://steffenbartsch.com/blog/2008/09/from-rails-security-to-application-security/" title="RailsConf Europe presentation From Rails Security to Application Security">presentation</a> on <a href="http://github.com/stffn/declarative_authorization">declarative_authorization</a> was offered by Timo Hentschel.  He stated that on the Rails CRM project with 90 Controllers and 200 Models that he is working on the declarative_authorization approach was simply not viable.  Projects of this size are currently not the target of our plugin, though.  Currently, we focus on bringing maintainable authorization into small to medium applications.  Nevertheless, it is interesting to look into Timo&#8217;s points:</p>
<ul>
<li><strong>&#8220;Role definition is for admins not developers&#8221;</strong>: It certainly depends on the project size.  With small to medium apps (our primary target) admins might just be the developers. Still, our future plans include a possible move of the authorization rules to database, enabling a policy editing UI.</li>
<li><strong>&#8220;You&#8217;d need a UI for handling the policy development&#8221;</strong>: This might be true. But without further evaluation, I am not convinced of the superior performance of a UI when compared to a readable, concise policy syntax. Policy files still provide documentation and specification for free. We will look into UIs, especially to facilitate a test-driven policy development approach, though.</li>
<li><strong>&#8220;I can&#8217;t redeploy on every role modification&#8221;</strong>: In practice, engineering an application&#8217;s policy is certainly error prone. Missing permissions will have to be added to roles once taken into production.  Changing roles on a production system isn&#8217;t optimal either, though: role-permission assignments need to be carefully checked for side effects.  Thus, a QA workflow would be desirable, just as provided by a deployment cycle.  I would prefer to handle missing permission assignments just like other software bugs which need to be fixed asap.  Nevertheless, with the planned features (TDD, UI, policy in DB) and an integrated authorization workflow, online role modifications may be feasible.  In our self-service authorization approach we would even like end users to extend their permissions on their own, on a limited scope and in some environments.</li>
<li><strong>&#8220;With 90 Controllers, the authorization policy will become unmanageably long&#8221;</strong>: This is certainly true with the current syntax.  On the one hand, we will distribute rules to multiple files in order to group similar aspects.  Also, currently one context is used per model.  A hierarchy of contexts is planned to cut the number of specific rules and thus ease policy development and maintainability.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2008/09/authorization-for-90-controllers-200-models-and-counting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From Rails Security to Application Security</title>
		<link>http://steffenbartsch.com/blog/2008/09/from-rails-security-to-application-security/</link>
		<comments>http://steffenbartsch.com/blog/2008/09/from-rails-security-to-application-security/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 13:48:39 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Authorization]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=28</guid>
		<description><![CDATA[I&#8217;m in Berlin for RailsConf Europe currently where I&#8217;m talking together with Carsten Bormann about implementing application security in Agile development with Rails and announcing declarative_authorization.
Here is our presentation (will only really display nicely on Firefox 3, though, sorry; full window view):

]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in Berlin for RailsConf Europe currently where I&#8217;m talking together with Carsten Bormann about implementing application security in Agile development with Rails and announcing <a href="http://steffenbartsch.com/blog/2008/09/delclarative-authorization/">declarative_authorization</a>.</p>
<p>Here is our presentation (will only really display nicely on Firefox 3, though, sorry; <a href="http://www.tzi.org/~sbartsch/slides/railsconfeurope-2008/railsconfeurope-2008.html">full window view</a>):</p>
<p><iframe src="http://www.tzi.org/~sbartsch/slides/railsconfeurope-2008/railsconfeurope-2008.html" style="width:36em;height:27em"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2008/09/from-rails-security-to-application-security/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Declarative Authorization</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/</link>
		<comments>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 10:07:38 +0000</pubDate>
		<dc:creator>Steffen Bartsch</dc:creator>
				<category><![CDATA[Authorization]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[declarative_authorization]]></category>

		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26</guid>
		<description><![CDATA[Having looked through quite a few existing Rails authorization plugins, we decided, we were in need of a different approach.  Mainly, it was the missing separation of authorization logic from business logic in the evaluated plugins that caused us to implement a new plugin, declarative_authorization.
In our declarative approach, authorization rules are grouped in a policy [...]]]></description>
			<content:encoded><![CDATA[<p>Having looked through quite a few existing <a title="Rails Authorization Plugins" href="http://steffenbartsch.com/blog/2008/08/rails-authorization-plugins/">Rails authorization plugins</a>, we decided, we were in need of a different approach.  Mainly, it was the missing separation of authorization logic from business logic in the evaluated plugins that caused us to implement a new plugin, <a href="http://github.com/stffn/declarative_authorization">declarative_authorization</a>.</p>
<p>In our declarative approach, authorization rules are grouped in a policy file, while only privileges are used inside program code to enforce restrictions. We developed for flexibility and simplicity, requiring only very simple statements in rules and program code. So instead of</p>
<pre><span class="PreProc">class</span> <span class="Type">ConferenceController</span> &lt; <span class="Type">ApplicationController</span>
  access_control <span class="Constant">:DEFAULT</span> =&gt; [<span class="Constant">:admin</span>],
    [<span class="Constant">:index</span>, <span class="Constant">:show</span>]  =&gt; [...],
    [<span class="Constant">:edit</span>, <span class="Constant">:update</span>] =&gt; [<span class="Constant">:admin</span>, <span class="Constant">:conference_organizer</span>]
<span class="PreProc">end</span>

cond = permit?([<span class="Constant">:admin</span>, <span class="Constant">:conference_organizer</span>]) ?
           {} : {<span class="Constant">:published</span> =&gt; <span class="Constant">true</span>}
<span class="Type">Conference</span>.find(<span class="Constant">:all</span>, <span class="Constant">:conditions</span> =&gt; cond)

<span class="Special">&lt;%</span> restrict_to [<span class="Constant">:admin</span>, <span class="Constant">:conference_organizer</span>] <span class="Statement">do</span> <span class="Special">%&gt;</span>
  <span class="Special">&lt;%=</span> link_to <span class="Special">'</span><span class="Constant">Edit</span><span class="Special">'</span>, edit_conference_path(conference) <span class="Special">%&gt;</span>
<span class="Special">&lt;%</span> <span class="Statement">end</span> <span class="Special">%&gt;</span></pre>
<p>with all the authorization logic interweaved with your code, you only need this</p>
<pre><span class="PreProc">class</span> <span class="Type">ConferencesController</span> &lt; <span class="Type">ApplicationController</span>
  filter_access_to <span class="Constant">:all</span>

  <span class="PreProc">def</span> <span class="Identifier">index</span>
    <span class="Identifier">@conferences</span> = <span class="Type">Conference</span>.with_permissions_to(<span class="Constant">:read</span>)
  <span class="PreProc">end</span>
<span class="PreProc">end</span>

<span class="Special">&lt;%=</span> link_to <span class="Special">'</span><span class="Constant">Edit</span><span class="Special">'</span>, edit_conference_path(conference)
            <span class="Statement">if</span> permitted_to? <span class="Constant">:edit</span>, conference <span class="Special">%&gt;</span></pre>
<p>And, separated in one place the authorization rules:</p>
<pre>role <span class="Constant">:guest</span> <span class="Statement">do</span>
  has_permission_on <span class="Constant">:conferences</span>, <span class="Constant">:to</span> =&gt; <span class="Constant">:read</span>
<span class="Statement">end</span>

role <span class="Constant">:conference_organizer</span> <span class="Statement">do</span>
  has_permission_on <span class="Constant">:conferences</span>, <span class="Constant">:to</span> =&gt; <span class="Constant">:manage</span>
<span class="Statement">end</span></pre>
<p>So, the same rules are used in enforcing authorization in Model, View and Controller. Also, they are used for Query Rewriting to automatically constrain the retrieved records according to the authorization rules.  Thus, you just modify the rules on authorization requirement changes and you can also use the rules to talk to business owners of Agile projects.</p>
<p>For additional information and more examples, refer to the <a title="declarative_authorization documentation" href="http://www.tzi.org/~sbartsch/declarative_authorization/0.1/">README and the rdoc documentation</a>. Currently, we are using the plugin for an application with fairly complex authorization and it will be taking into production in the next iteration. So, look into it if you have authorization concerns in your application, it&#8217;s released under MIT license.</p>
]]></content:encoded>
			<wfw:commentRss>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
	</channel>
</rss>
