<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: AcegiPluginDemo.zip</title>
	<atom:link href="http://bildtsen.com/2008/11/production-grade-acegi-security-for-grails/acegiplugindemo/feed/" rel="self" type="application/rss+xml" />
	<link>http://bildtsen.com/2008/11/production-grade-acegi-security-for-grails/acegiplugindemo/</link>
	<description>Flex, Groovy/Grails, Ext JS, and other neat stuff</description>
	<lastBuildDate>Wed, 04 Nov 2009 17:01:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Baha AS</title>
		<link>http://bildtsen.com/2008/11/production-grade-acegi-security-for-grails/acegiplugindemo/comment-page-1/#comment-289</link>
		<dc:creator>Baha AS</dc:creator>
		<pubDate>Fri, 09 Jan 2009 21:07:21 +0000</pubDate>
		<guid isPermaLink="false">http://bildtsen.com/wp-content/uploads/2008/10/acegiplugindemo.zip#comment-289</guid>
		<description>Thank you Ola,

I&#039;ll make sure we use the plugin.

You&#039;ve done a great job.

Kindest regards,

Baha</description>
		<content:encoded><![CDATA[<p>Thank you Ola,</p>
<p>I&#8217;ll make sure we use the plugin.</p>
<p>You&#8217;ve done a great job.</p>
<p>Kindest regards,</p>
<p>Baha</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ola Bildtsen</title>
		<link>http://bildtsen.com/2008/11/production-grade-acegi-security-for-grails/acegiplugindemo/comment-page-1/#comment-288</link>
		<dc:creator>Ola Bildtsen</dc:creator>
		<pubDate>Fri, 09 Jan 2009 20:54:25 +0000</pubDate>
		<guid isPermaLink="false">http://bildtsen.com/wp-content/uploads/2008/10/acegiplugindemo.zip#comment-288</guid>
		<description>Baha,

You definitely want to go with the 0.4 version of the plugin from the grails.org site -- it&#039;s come a long way since the original posting of this code.

Please check it out -- it has the fix in it for the &quot;narrowest mapping&quot; problem, I think you&#039;ll find it works as you&#039;d expect.  And please let me re-iterate: using /** mappings as a default path is a bad idea -- I would strongly recommend you to remove that and instead do all controller authorization mappings on the controller/action level.  You misunderstand the plugin if you think that putting up a default /** authorization for the app is the way to go.  That is precisely the thing the plugin is built to avoid...</description>
		<content:encoded><![CDATA[<p>Baha,</p>
<p>You definitely want to go with the 0.4 version of the plugin from the grails.org site &#8212; it&#8217;s come a long way since the original posting of this code.</p>
<p>Please check it out &#8212; it has the fix in it for the &#8220;narrowest mapping&#8221; problem, I think you&#8217;ll find it works as you&#8217;d expect.  And please let me re-iterate: using /** mappings as a default path is a bad idea &#8212; I would strongly recommend you to remove that and instead do all controller authorization mappings on the controller/action level.  You misunderstand the plugin if you think that putting up a default /** authorization for the app is the way to go.  That is precisely the thing the plugin is built to avoid&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Baha AS</title>
		<link>http://bildtsen.com/2008/11/production-grade-acegi-security-for-grails/acegiplugindemo/comment-page-1/#comment-287</link>
		<dc:creator>Baha AS</dc:creator>
		<pubDate>Fri, 09 Jan 2009 20:44:40 +0000</pubDate>
		<guid isPermaLink="false">http://bildtsen.com/wp-content/uploads/2008/10/acegiplugindemo.zip#comment-287</guid>
		<description>Hi Ola,

Actually I have seen the plugin under grails.org but my colleague on his end have read this blog and integrated the sample code from available here into our project. In my mind i thaught he have integrated your grails plugin but that was not the case. It&#039;s all right this is easily fixable.

The issue is this. In summary your code allows access by default to all pages hence the default path /** is mapped to all the roles and then the filter will restrict the mappings according to specific urlMappings first then controllerMapping filters get applied. So narrowestEntry.key is &#039;/**&#039; for the first iteration of :
&quot;controllerPathMap.findAll{ pathMatcher.match(it.key, url) }.each { entry -&gt;&quot;

which will never match any controller mapping entry (ie &#039;/**&#039; will not match &#039;controller/action&#039; path entries). So the problem is the if condition will never be true. What should have been done is test the condition of entry.key against the &#039;url&#039; string instead of &#039;narrowestEntry.key&#039;.

What do you think?

Thanks for your comment,

Baha</description>
		<content:encoded><![CDATA[<p>Hi Ola,</p>
<p>Actually I have seen the plugin under grails.org but my colleague on his end have read this blog and integrated the sample code from available here into our project. In my mind i thaught he have integrated your grails plugin but that was not the case. It&#8217;s all right this is easily fixable.</p>
<p>The issue is this. In summary your code allows access by default to all pages hence the default path /** is mapped to all the roles and then the filter will restrict the mappings according to specific urlMappings first then controllerMapping filters get applied. So narrowestEntry.key is &#8216;/**&#8217; for the first iteration of :<br />
&#8220;controllerPathMap.findAll{ pathMatcher.match(it.key, url) }.each { entry -&gt;&#8221;</p>
<p>which will never match any controller mapping entry (ie &#8216;/**&#8217; will not match &#8216;controller/action&#8217; path entries). So the problem is the if condition will never be true. What should have been done is test the condition of entry.key against the &#8216;url&#8217; string instead of &#8216;narrowestEntry.key&#8217;.</p>
<p>What do you think?</p>
<p>Thanks for your comment,</p>
<p>Baha</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ola Bildtsen</title>
		<link>http://bildtsen.com/2008/11/production-grade-acegi-security-for-grails/acegiplugindemo/comment-page-1/#comment-285</link>
		<dc:creator>Ola Bildtsen</dc:creator>
		<pubDate>Fri, 09 Jan 2009 15:07:03 +0000</pubDate>
		<guid isPermaLink="false">http://bildtsen.com/wp-content/uploads/2008/10/acegiplugindemo.zip#comment-285</guid>
		<description>Thanks for the comment.  Please note that you&#039;re working against old code -- this plugin has since been released as a Grails plugin in the Grails repository.  There are many upgrades and bug fixes with the latest release, so please start using that plugin instead.  Full documentation (including install guide) is here: http://www.grails.org/Stark+Security+Plugin

As for the problem you describe, let me first say that putting a mapping of &#039;/**&#039; in the config mappings effectively defeats the purpose of this plugin by setting an authorization mapping for the entire site.  The intention of the plugin is to have access control declared on the controller/method level and avoid such site-wide mappings.

But you do point out a defect: the &quot;narrowestEntry&quot; logic is incorrect because the args to AntPathMatcher are switched.  Where the code reads:

&lt;code&gt;if (!narrowestEntry &#124;&#124; pathMatcher.match(entry.key, narrowestEntry.key))&lt;/code&gt;

it should read

&lt;code&gt;if (!narrowestEntry &#124;&#124; pathMatcher.match(narrowestEntry.key, entry.key)) &lt;/code&gt;

I have opened a defect for this and will fix/release soon: http://jira.codehaus.org/browse/GRAILSPLUGINS-756</description>
		<content:encoded><![CDATA[<p>Thanks for the comment.  Please note that you&#8217;re working against old code &#8212; this plugin has since been released as a Grails plugin in the Grails repository.  There are many upgrades and bug fixes with the latest release, so please start using that plugin instead.  Full documentation (including install guide) is here: <a href="http://www.grails.org/Stark+Security+Plugin" rel="nofollow">http://www.grails.org/Stark+Security+Plugin</a></p>
<p>As for the problem you describe, let me first say that putting a mapping of &#8216;/**&#8217; in the config mappings effectively defeats the purpose of this plugin by setting an authorization mapping for the entire site.  The intention of the plugin is to have access control declared on the controller/method level and avoid such site-wide mappings.</p>
<p>But you do point out a defect: the &#8220;narrowestEntry&#8221; logic is incorrect because the args to AntPathMatcher are switched.  Where the code reads:</p>
<p><code>if (!narrowestEntry || pathMatcher.match(entry.key, narrowestEntry.key))</code></p>
<p>it should read</p>
<p><code>if (!narrowestEntry || pathMatcher.match(narrowestEntry.key, entry.key)) </code></p>
<p>I have opened a defect for this and will fix/release soon: <a href="http://jira.codehaus.org/browse/GRAILSPLUGINS-756" rel="nofollow">http://jira.codehaus.org/browse/GRAILSPLUGINS-756</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Baha AS</title>
		<link>http://bildtsen.com/2008/11/production-grade-acegi-security-for-grails/acegiplugindemo/comment-page-1/#comment-282</link>
		<dc:creator>Baha AS</dc:creator>
		<pubDate>Thu, 08 Jan 2009 21:06:58 +0000</pubDate>
		<guid isPermaLink="false">http://bildtsen.com/wp-content/uploads/2008/10/acegiplugindemo.zip#comment-282</guid>
		<description>Hi Ola,

We&#039;ve integrated your code in the springsecurity plugin of grails of our project but I found a tiny misbehavior when securing controller actions as posted in your code. There is a little issue in the lookupAttributes(String url) method in the PathFilterInvoicationDefinitionMap class.

The issue is about line 36 where the condition is checking for narrowestEntries among the controller&#039;s action entries:
if (!narrowestEntry &#124;&#124; pathMatcher.match(entry.key, narrowestEntry.key)) 

the problem here is narrowestEntry is preset to the default /** coming from urlMappingsPathMap class so it is never empty and thus the previous condition never becomes true.
I have added the following condition after the closure of the if condition of line 36 (after the if (...){...} ***here***)
which will check the action entries against the actual url :

if (pathMatcher.match(entry.key, url) &amp;&amp; entry.key.length()&gt;=narrowestEntry.key.length()) {
        		narrowestEntry = entry
        	}

the second condition after the &amp;&amp; operation allows to restrict narrowestEntry to strictest action mapping in case of similar action name prefixes, ie say we have the following action mapping in a controller:

product:[&#039;ROLE_USER&#039;], 
productList:[&#039;ROLE_ADMIN&#039;]

where accessing productList with ROLE_USER privilege will not match an entry of product action.

I hope this workaround might be useful for your article.

Regards and thanks for the code your provided, it&#039;s very useful.</description>
		<content:encoded><![CDATA[<p>Hi Ola,</p>
<p>We&#8217;ve integrated your code in the springsecurity plugin of grails of our project but I found a tiny misbehavior when securing controller actions as posted in your code. There is a little issue in the lookupAttributes(String url) method in the PathFilterInvoicationDefinitionMap class.</p>
<p>The issue is about line 36 where the condition is checking for narrowestEntries among the controller&#8217;s action entries:<br />
if (!narrowestEntry || pathMatcher.match(entry.key, narrowestEntry.key)) </p>
<p>the problem here is narrowestEntry is preset to the default /** coming from urlMappingsPathMap class so it is never empty and thus the previous condition never becomes true.<br />
I have added the following condition after the closure of the if condition of line 36 (after the if (&#8230;){&#8230;} ***here***)<br />
which will check the action entries against the actual url :</p>
<p>if (pathMatcher.match(entry.key, url) &amp;&amp; entry.key.length()&gt;=narrowestEntry.key.length()) {<br />
        		narrowestEntry = entry<br />
        	}</p>
<p>the second condition after the &amp;&amp; operation allows to restrict narrowestEntry to strictest action mapping in case of similar action name prefixes, ie say we have the following action mapping in a controller:</p>
<p>product:['ROLE_USER'],<br />
productList:['ROLE_ADMIN']</p>
<p>where accessing productList with ROLE_USER privilege will not match an entry of product action.</p>
<p>I hope this workaround might be useful for your article.</p>
<p>Regards and thanks for the code your provided, it&#8217;s very useful.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

