<?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"
	>
<channel>
	<title>Comments for steffenbartsch</title>
	<atom:link href="http://steffenbartsch.com/blog/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://steffenbartsch.com/blog</link>
	<description>Security, Usability, Rails</description>
	<pubDate>Thu, 20 Nov 2008 20:13:41 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>Comment on Declarative Authorization by Steffen Bartsch</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-345</link>
		<dc:creator>Steffen Bartsch</dc:creator>
		<pubDate>Wed, 19 Nov 2008 09:10:12 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-345</guid>
		<description>Sarah,

&gt; This is great. I have a question about AND-ing if_attribute or
&gt; passing additional conditions. Is it possible?

following your example, the easiest way is to combine those attributes:
if_attribute :owner =&gt; is {user}, :color =&gt; "blue"

&gt; Or pass named_scopes as conditions
&gt; # if_attribute :named_scope?(user) =&gt; is{true}
&gt;
&gt; Or pass arguments to attributes
&gt; # if_attribute :find_this(user)

No, currently if_attribute is limited to attributes and associations.  Could you give me an extended, real-world example to convince me that this is actually necessary?

&gt; Also, could you say a bit more or give an example of the
&gt; :context option in use?

E.g. in
has_permission_on :employees, :to =&gt; :read
the context is :employees.  In controllers, the context is usually inferred from the controller name (e.g. EmployeesController).  If a different context should be employed for authorization checks, you can pass that with the :context option.

The documentation at
http://www.tzi.org/~sbartsch/declarative_authorization/0.1/
could be of additional help.

Steffen</description>
		<content:encoded><![CDATA[<p>Sarah,</p>
<p>> This is great. I have a question about AND-ing if_attribute or<br />
> passing additional conditions. Is it possible?</p>
<p>following your example, the easiest way is to combine those attributes:<br />
if_attribute :owner => is {user}, :color => &#8220;blue&#8221;</p>
<p>> Or pass named_scopes as conditions<br />
> # if_attribute :named_scope?(user) => is{true}<br />
><br />
> Or pass arguments to attributes<br />
> # if_attribute :find_this(user)</p>
<p>No, currently if_attribute is limited to attributes and associations.  Could you give me an extended, real-world example to convince me that this is actually necessary?</p>
<p>> Also, could you say a bit more or give an example of the<br />
> :context option in use?</p>
<p>E.g. in<br />
has_permission_on :employees, :to => :read<br />
the context is :employees.  In controllers, the context is usually inferred from the controller name (e.g. EmployeesController).  If a different context should be employed for authorization checks, you can pass that with the :context option.</p>
<p>The documentation at<br />
<a href="http://www.tzi.org/~sbartsch/declarative_authorization/0.1/" rel="nofollow">http://www.tzi.org/~sbartsch/declarative_authorization/0.1/</a><br />
could be of additional help.</p>
<p>Steffen</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Declarative Authorization by Sarah</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-337</link>
		<dc:creator>Sarah</dc:creator>
		<pubDate>Tue, 18 Nov 2008 22:11:12 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-337</guid>
		<description>Hi Steffen, 

This is great. I have a question about AND-ing if_attribute or passing additional conditions. Is it possible? 

These are all pseudo-code, but hopefully get the gist across. 
 
Something like
if_attribute :owner =&#62; is{user} and if_attribute :color =&#62; is{"blue"}

Or pass named_scopes as conditions
# if_attribute :named_scope?(user) =&#62; is{true}

Or pass arguments to attributes
# if_attribute :find_this(user)

Also, could you say a bit more or give an example of the :context  option in use? 

Thanks, 
Sarah</description>
		<content:encoded><![CDATA[<p>Hi Steffen, </p>
<p>This is great. I have a question about AND-ing if_attribute or passing additional conditions. Is it possible? </p>
<p>These are all pseudo-code, but hopefully get the gist across. </p>
<p>Something like<br />
if_attribute :owner =&gt; is{user} and if_attribute :color =&gt; is{&#8221;blue&#8221;}</p>
<p>Or pass named_scopes as conditions<br />
# if_attribute :named_scope?(user) =&gt; is{true}</p>
<p>Or pass arguments to attributes<br />
# if_attribute :find_this(user)</p>
<p>Also, could you say a bit more or give an example of the :context  option in use? </p>
<p>Thanks,<br />
Sarah</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Declarative Authorization by Steffen Bartsch</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-47</link>
		<dc:creator>Steffen Bartsch</dc:creator>
		<pubDate>Mon, 22 Sep 2008 07:36:47 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-47</guid>
		<description>Brian,

actually I implemented ignore_access_control for the test environment where I frequently need to setup objects and don't like the access control hassle there.  But you are right, there are other use cases for such a feature.  I'm not sure how to separate that properly from the day-to-day business of the application, though. I'd prefer to don't have such an option there.

As for without_access_control, I have such a method in my test helper.  I plan to integrate it as test infrastructure into the plugin in the future.  Looks like this in my helper:

&lt;code&gt;
  def without_access_control
    Authorization.ignore_access_control(true)
    yield
  ensure
    Authorization.ignore_access_control(false)
  end
  
  def with_user (user)
    prev_user = Authorization.current_user
    Authorization.current_user = user
    yield
  ensure
    Authorization.current_user = prev_user
  end
&lt;/code&gt;

Steffen</description>
		<content:encoded><![CDATA[<p>Brian,</p>
<p>actually I implemented ignore_access_control for the test environment where I frequently need to setup objects and don&#8217;t like the access control hassle there.  But you are right, there are other use cases for such a feature.  I&#8217;m not sure how to separate that properly from the day-to-day business of the application, though. I&#8217;d prefer to don&#8217;t have such an option there.</p>
<p>As for without_access_control, I have such a method in my test helper.  I plan to integrate it as test infrastructure into the plugin in the future.  Looks like this in my helper:</p>
<p><code><br />
  def without_access_control<br />
    Authorization.ignore_access_control(true)<br />
    yield<br />
  ensure<br />
    Authorization.ignore_access_control(false)<br />
  end</p>
<p>  def with_user (user)<br />
    prev_user = Authorization.current_user<br />
    Authorization.current_user = user<br />
    yield<br />
  ensure<br />
    Authorization.current_user = prev_user<br />
  end<br />
</code></p>
<p>Steffen</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Declarative Authorization by Brian Langenfeld</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-46</link>
		<dc:creator>Brian Langenfeld</dc:creator>
		<pubDate>Sun, 21 Sep 2008 21:04:22 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-46</guid>
		<description>Steffen -- Really digging your security implementation here.  Nicely done.

using_access_control is really cool, but for me, it can get in the way at times.  (For example, when working with objects in the console, or setting up that all-important first admin user.)  To help with this problem, I made a couple of changes to authorization.rb.

Modified one existing method:

&lt;code&gt;
  # Modified this method to return @@ignore_access_control without also checking RAILS_ENV.  This
  # was done to allow us to switch access control on and off as needed.
  def self.ignore_access_control (state = nil) # :nodoc:
    @@ignore_access_control = state unless state.nil?
    @@ignore_access_control
  end
&lt;/code&gt;

And added one new method:

&lt;code&gt;
  # Executes a given block, bypassing all access control.  Useful for legitimate cases where access
  # control "gets in the way" (e.g., bootstrapping that first admin user, console work).
  def self.without_access_control( &#38;block )
    state = self.ignore_access_control
    raise AuthorizationError unless self.ignore_access_control( true )
    yield
    self.ignore_access_control( state )
    nil
  end
&lt;/code&gt;

It's probably not a very good solution (I'm definitely NOT the expert here), but it gets the job done.  Any better ideas?</description>
		<content:encoded><![CDATA[<p>Steffen &#8212; Really digging your security implementation here.  Nicely done.</p>
<p>using_access_control is really cool, but for me, it can get in the way at times.  (For example, when working with objects in the console, or setting up that all-important first admin user.)  To help with this problem, I made a couple of changes to authorization.rb.</p>
<p>Modified one existing method:</p>
<p><code><br />
  # Modified this method to return @@ignore_access_control without also checking RAILS_ENV.  This<br />
  # was done to allow us to switch access control on and off as needed.<br />
  def self.ignore_access_control (state = nil) # :nodoc:<br />
    @@ignore_access_control = state unless state.nil?<br />
    @@ignore_access_control<br />
  end<br />
</code></p>
<p>And added one new method:</p>
<p><code><br />
  # Executes a given block, bypassing all access control.  Useful for legitimate cases where access<br />
  # control "gets in the way" (e.g., bootstrapping that first admin user, console work).<br />
  def self.without_access_control( &amp;block )<br />
    state = self.ignore_access_control<br />
    raise AuthorizationError unless self.ignore_access_control( true )<br />
    yield<br />
    self.ignore_access_control( state )<br />
    nil<br />
  end<br />
</code></p>
<p>It&#8217;s probably not a very good solution (I&#8217;m definitely NOT the expert here), but it gets the job done.  Any better ideas?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Declarative Authorization by Steffen Bartsch</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-45</link>
		<dc:creator>Steffen Bartsch</dc:creator>
		<pubDate>Fri, 19 Sep 2008 08:28:16 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-45</guid>
		<description>Mike,

&gt; I’m attempting to use the advanced permission rule to allow 
&gt; the current_user to :manage their own message, but only :read 
&gt; everyone else’s.
&gt;
&gt; In my case I am using a Person model instead of User.
&gt;
&gt; However, the current_user always gets the manage permission
&gt; has_permission_on :messages, :to =&gt; :read
&gt; has_permission_on :messages do
&gt;   to :manage
&gt;   if_attribute :person_id =&gt; is {user.id}
&gt; end

has_permission_on :messages, :to =&gt; :read
has_permission_on :messages do
  to :manage
  if_attribute :person =&gt; is {user}
end

is perfectly correct.  I have similar code working here.  Could you verify that

  message.person != person_object_of_the_request

for the request?  Also, does it help to remove the second has_permission_on statement?  In the rails console, you could also try:

engine = Authorization::Engine.instance
engine.permit!(:manage, 
       :context =&gt; :messages, 
       :user =&gt; person_object_of_the_request, 
       :object =&gt; message_object)

to drill down on the problem.

Steffen</description>
		<content:encoded><![CDATA[<p>Mike,</p>
<p>> I’m attempting to use the advanced permission rule to allow<br />
> the current_user to :manage their own message, but only :read<br />
> everyone else’s.<br />
><br />
> In my case I am using a Person model instead of User.<br />
><br />
> However, the current_user always gets the manage permission<br />
> has_permission_on :messages, :to => :read<br />
> has_permission_on :messages do<br />
>   to :manage<br />
>   if_attribute :person_id => is {user.id}<br />
> end</p>
<p>has_permission_on :messages, :to => :read<br />
has_permission_on :messages do<br />
  to :manage<br />
  if_attribute :person => is {user}<br />
end</p>
<p>is perfectly correct.  I have similar code working here.  Could you verify that</p>
<p>  message.person != person_object_of_the_request</p>
<p>for the request?  Also, does it help to remove the second has_permission_on statement?  In the rails console, you could also try:</p>
<p>engine = Authorization::Engine.instance<br />
engine.permit!(:manage,<br />
       :context => :messages,<br />
       :user => person_object_of_the_request,<br />
       :object => message_object)</p>
<p>to drill down on the problem.</p>
<p>Steffen</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Declarative Authorization by Steffen Bartsch</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-44</link>
		<dc:creator>Steffen Bartsch</dc:creator>
		<pubDate>Fri, 19 Sep 2008 08:25:30 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-44</guid>
		<description>&gt; Looking through the tests, I see options for :context, but no 
&gt; examples on how to use it, or what the “title” should be in the 
&gt; database?

:context options just directly set the context for the authorization evaluation, see the rdoc documentation for more information on that.

I suppose with "title" you are referring to the Role model proposed in the README.  Here, title is just the name of the role as specified in the authorization rules.

Steffen</description>
		<content:encoded><![CDATA[<p>> Looking through the tests, I see options for :context, but no<br />
> examples on how to use it, or what the “title” should be in the<br />
> database?</p>
<p>:context options just directly set the context for the authorization evaluation, see the rdoc documentation for more information on that.</p>
<p>I suppose with &#8220;title&#8221; you are referring to the Role model proposed in the README.  Here, title is just the name of the role as specified in the authorization rules.</p>
<p>Steffen</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Declarative Authorization by Steffen Bartsch</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-43</link>
		<dc:creator>Steffen Bartsch</dc:creator>
		<pubDate>Fri, 19 Sep 2008 07:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-43</guid>
		<description>Mike,

on your question concerning the error on PeopleController, I just checked a fix into github to prevent the unnecessary second pluralization.  That should fix it.

Steffen</description>
		<content:encoded><![CDATA[<p>Mike,</p>
<p>on your question concerning the error on PeopleController, I just checked a fix into github to prevent the unnecessary second pluralization.  That should fix it.</p>
<p>Steffen</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Declarative Authorization by Steffen Bartsch</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-42</link>
		<dc:creator>Steffen Bartsch</dc:creator>
		<pubDate>Fri, 19 Sep 2008 07:02:35 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-42</guid>
		<description>Hi Mike,

the role would be "admin" for an overall admin and  "project_admin" for one limited to assigned projects.  For restricting access to the assigned projects, use the if_attribute context restriction.  E.g.

  role :project_admin
    has_permissions_on :project, :to =&gt; :manage do
      if_attribute :admin_users =&gt; contains { user }
    end
  end

Provided, that your Project model has a project#admin_users collection (has_many :admin_users, :through ...).

Does this help?
Steffen</description>
		<content:encoded><![CDATA[<p>Hi Mike,</p>
<p>the role would be &#8220;admin&#8221; for an overall admin and  &#8220;project_admin&#8221; for one limited to assigned projects.  For restricting access to the assigned projects, use the if_attribute context restriction.  E.g.</p>
<p>  role :project_admin<br />
    has_permissions_on :project, :to => :manage do<br />
      if_attribute :admin_users => contains { user }<br />
    end<br />
  end</p>
<p>Provided, that your Project model has a project#admin_users collection (has_many :admin_users, :through &#8230;).</p>
<p>Does this help?<br />
Steffen</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Declarative Authorization by Mike Larkin</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-41</link>
		<dc:creator>Mike Larkin</dc:creator>
		<pubDate>Fri, 19 Sep 2008 06:11:55 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-41</guid>
		<description>I'm attempting to use the advanced permission rule to allow the current_user to :manage their own message, but only :read everyone else's.

In my case I am using a Person model instead of User.

However, the current_user always gets the manage permission
    has_permission_on :messages, :to =&#62; :read
    has_permission_on :messages do
      to :manage
      # user refers to the current_user when evaluating
      if_attribute :person_id =&#62; is {user.id}
    end

I've also tried:
if_attribute :person =&#62; is {user}
if_attribute :person.id =&#62; contains {user.id}
if attribute :person =&#62; is {person}

but none of these actually deny the manage permission.  What am I doing wrong?

Thanks!</description>
		<content:encoded><![CDATA[<p>I&#8217;m attempting to use the advanced permission rule to allow the current_user to :manage their own message, but only :read everyone else&#8217;s.</p>
<p>In my case I am using a Person model instead of User.</p>
<p>However, the current_user always gets the manage permission<br />
    has_permission_on :messages, :to =&gt; :read<br />
    has_permission_on :messages do<br />
      to :manage<br />
      # user refers to the current_user when evaluating<br />
      if_attribute :person_id =&gt; is {user.id}<br />
    end</p>
<p>I&#8217;ve also tried:<br />
if_attribute :person =&gt; is {user}<br />
if_attribute :person.id =&gt; contains {user.id}<br />
if attribute :person =&gt; is {person}</p>
<p>but none of these actually deny the manage permission.  What am I doing wrong?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Declarative Authorization by Mike Larkin</title>
		<link>http://steffenbartsch.com/blog/2008/09/delclarative-authorization/#comment-40</link>
		<dc:creator>Mike Larkin</dc:creator>
		<pubDate>Fri, 19 Sep 2008 05:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://steffenbartsch.com/blog/?p=26#comment-40</guid>
		<description>Sorry to keep posting, but I noticed a bug regarding pluralization.  I have a People model, and permissions like

has_permission_on :people, :to =&#62; :manage

I'm getting a permission denied...

:context =&#62; :peoples</description>
		<content:encoded><![CDATA[<p>Sorry to keep posting, but I noticed a bug regarding pluralization.  I have a People model, and permissions like</p>
<p>has_permission_on :people, :to =&gt; :manage</p>
<p>I&#8217;m getting a permission denied&#8230;</p>
<p>:context =&gt; :peoples</p>
]]></content:encoded>
	</item>
</channel>
</rss>
