<?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: Don&#8217;t Do Role-Based Authorization Checks; Do Activity-Based Checks</title>
	<atom:link href="http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/</link>
	<description>Better Than Yesterday</description>
	<lastBuildDate>Thu, 13 Jun 2013 17:35:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Jason Dang</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-3225</link>
		<dc:creator>Jason Dang</dc:creator>
		<pubDate>Tue, 07 May 2013 12:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-3225</guid>
		<description>I dont agree with the author since the Enterprise Library has Unity block which allows us to inject the Authorization mechanism into the biz classes. That make our security mechanism very clear, loose-couple and easy to add custom roles. Your code seems to be outdated.</description>
		<content:encoded><![CDATA[<p>I dont agree with the author since the Enterprise Library has Unity block which allows us to inject the Authorization mechanism into the biz classes. That make our security mechanism very clear, loose-couple and easy to add custom roles. Your code seems to be outdated.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff Shurts</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-3033</link>
		<dc:creator>Jeff Shurts</dc:creator>
		<pubDate>Sat, 09 Feb 2013 20:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-3033</guid>
		<description>Software development is one of those disciplines where there always tend to be a thousand ways to solve a particular problem. Of those thousand, 990 are usually pretty bad, and any of the remaining ten will serve you pretty well.

Authorization (access to features) in an application, whether it&#039;s a web, desktop, or mobile app, is one of those problems that clearly has one best solution - tackling the problem any other way represents a compromise that you&#039;ll regret somewhere down the road.



That one best solution is the one Derick describes above. Just do this. If you don&#039;t, you (or those who have to maintain your code after you move on) will be forever frustrated.


For those of you wanting a more elaborate example, just go watch the Railscast on the CanCan gem (which is referenced above, and incidentally, was authored by Ryan Bates, the man who brings you Railscasts). Even if you&#039;re not a Rails person, you&#039;ll get the concept. It is, after all, quite simple:


NEVER INQUIRE ABOUT THE CURRENT USER&#039;S ROLE IN APPLICATION CODE. EVER.


Do not let complex and tedious authorization rules (&quot;who gets to do what?&quot;) become scattered throughout your code base, never again to be understood in their entirety. Because one day a new product owner will ask you for a list of said rules. You don&#039;t want to be scanning your code base looking for calls to User.getRole() or some such. There are far more entertaining ways to waste time.</description>
		<content:encoded><![CDATA[<p>Software development is one of those disciplines where there always tend to be a thousand ways to solve a particular problem. Of those thousand, 990 are usually pretty bad, and any of the remaining ten will serve you pretty well.</p>
<p>Authorization (access to features) in an application, whether it&#8217;s a web, desktop, or mobile app, is one of those problems that clearly has one best solution &#8211; tackling the problem any other way represents a compromise that you&#8217;ll regret somewhere down the road.</p>
<p>That one best solution is the one Derick describes above. Just do this. If you don&#8217;t, you (or those who have to maintain your code after you move on) will be forever frustrated.</p>
<p>For those of you wanting a more elaborate example, just go watch the Railscast on the CanCan gem (which is referenced above, and incidentally, was authored by Ryan Bates, the man who brings you Railscasts). Even if you&#8217;re not a Rails person, you&#8217;ll get the concept. It is, after all, quite simple:</p>
<p>NEVER INQUIRE ABOUT THE CURRENT USER&#8217;S ROLE IN APPLICATION CODE. EVER.</p>
<p>Do not let complex and tedious authorization rules (&#8220;who gets to do what?&#8221;) become scattered throughout your code base, never again to be understood in their entirety. Because one day a new product owner will ask you for a list of said rules. You don&#8217;t want to be scanning your code base looking for calls to User.getRole() or some such. There are far more entertaining ways to waste time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Nevill</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-3021</link>
		<dc:creator>Chris Nevill</dc:creator>
		<pubDate>Mon, 04 Feb 2013 16:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-3021</guid>
		<description>Excellent article. Would love to see a working solution.  


In my ideal world at the moment I&#039;m looking for something that allows me to have it such that all actions are not authorized until a combination of an activity has been defined for that action, a role has been given access to that activity.  A user assigned that role would then be authorized for that activity.  


I&#039;d like control of where the users credentials are stored, so that they can be stored in my database.  I&#039;d also like the database to tie the activity&#039;s and the rolls, so that I could simply change the database to change where users with a certain role can and can&#039;t go. 


I&#039;m sure there must be a nice &#039;simple&#039; solution for this somewhere.  I&#039;m not feeling confident about rolling my own yet.</description>
		<content:encoded><![CDATA[<p>Excellent article. Would love to see a working solution.  </p>
<p>In my ideal world at the moment I&#8217;m looking for something that allows me to have it such that all actions are not authorized until a combination of an activity has been defined for that action, a role has been given access to that activity.  A user assigned that role would then be authorized for that activity.  </p>
<p>I&#8217;d like control of where the users credentials are stored, so that they can be stored in my database.  I&#8217;d also like the database to tie the activity&#8217;s and the rolls, so that I could simply change the database to change where users with a certain role can and can&#8217;t go. </p>
<p>I&#8217;m sure there must be a nice &#8216;simple&#8217; solution for this somewhere.  I&#8217;m not feeling confident about rolling my own yet.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kkkk</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-2957</link>
		<dc:creator>kkkk</dc:creator>
		<pubDate>Mon, 31 Dec 2012 10:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-2957</guid>
		<description>In the end that is what RBAC is all about. http://csrc.nist.gov/rbac/rbac-std-ncits.pdf</description>
		<content:encoded><![CDATA[<p>In the end that is what RBAC is all about. <a href="http://csrc.nist.gov/rbac/rbac-std-ncits.pdf" rel="nofollow">http://csrc.nist.gov/rbac/rbac-std-ncits.pdf</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: likethesky</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-2811</link>
		<dc:creator>likethesky</dc:creator>
		<pubDate>Tue, 30 Oct 2012 22:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-2811</guid>
		<description>Sorry to resurrect a year-old thread, but YES!  I am about to implement a system similar to what @ttutko:disqus describes here, which is that Administrators are able to assign to new users what I call a &quot;sub-admin&quot; role (with that name being a role which is semantically the same or--most probably--*less* than &quot;Administrator&quot;, with a corresponding set of the same or less [data] items [as available to Administrator] and with the same or less permissions on those items--jointly, these last two [items &amp; permissions on them] define an &quot;activity&quot; [as @derickbailey:disqus defines it in the original post here--I think!] that then either can -or- can&#039;t be performed by that [sub-admin] user).

Then--in my system--this sub-admin user should be able to further sub-assign other sub-admins or sub-users (the only distinction between sub-admins &amp; sub-users being whether they can further assign users; sub-admins can assign *the same or less* rights they have to other users, sub-users cannot--it&#039;s really just another permission that is strictly on the User model/resource).  Anyway, I digress...

Anyone know of any GitHub projects that do something similar (or @ttutko, have you open-sourced any of your system--or do you plan to? Or could share some snippets of code for it)?  I&#039;d be most interested in anything done using CanCan/Rolify in Ruby/Rails, but am open to any solutions that implement some form of this nested system, with sub-admins able to further delegate the same or &#039;tighter&#039; permissions for resources (uh, I mean &#039;items&#039;) that they have those (or greater) permissions to already.

One question I have is--let&#039;s say there are a dozen &#039;items&#039; with the four main CRUD actions on them (defining 48 possible activities) and of course we will be adding more &#039;items&#039; to these dozen all the time.  Should I just create a &#039;custom role&#039; (hash into the 4 x 12 table of &#039;checkmarks&#039;) in Rolify for whatever permissions any particular user is given by a sub-admin (meaning, create a new &#039;custom&#039; role each time some combination of those 48 &#039;checkmarks&#039; are checked by a sub-admin for one of their sub-users/admins--we would share a combination that reoccurs, of course)?  Or better to just keep adding the &#039;items&#039; x 4 into a separate table linked to from the User table itself?  IOW, not use custom roles at all for these sub-permissions/activity-based authorizations, but simply make that &#039;hash of permissions on items&#039; a part of the identity of that user?

Thanks all!</description>
		<content:encoded><![CDATA[<p>Sorry to resurrect a year-old thread, but YES!  I am about to implement a system similar to what @ttutko:disqus describes here, which is that Administrators are able to assign to new users what I call a &#8220;sub-admin&#8221; role (with that name being a role which is semantically the same or&#8211;most probably&#8211;*less* than &#8220;Administrator&#8221;, with a corresponding set of the same or less [data] items [as available to Administrator] and with the same or less permissions on those items&#8211;jointly, these last two [items &amp; permissions on them] define an &#8220;activity&#8221; [as @derickbailey:disqus defines it in the original post here--I think!] that then either can -or- can&#8217;t be performed by that [sub-admin] user).</p>
<p>Then&#8211;in my system&#8211;this sub-admin user should be able to further sub-assign other sub-admins or sub-users (the only distinction between sub-admins &amp; sub-users being whether they can further assign users; sub-admins can assign *the same or less* rights they have to other users, sub-users cannot&#8211;it&#8217;s really just another permission that is strictly on the User model/resource).  Anyway, I digress&#8230;</p>
<p>Anyone know of any GitHub projects that do something similar (or @ttutko, have you open-sourced any of your system&#8211;or do you plan to? Or could share some snippets of code for it)?  I&#8217;d be most interested in anything done using CanCan/Rolify in Ruby/Rails, but am open to any solutions that implement some form of this nested system, with sub-admins able to further delegate the same or &#8216;tighter&#8217; permissions for resources (uh, I mean &#8216;items&#8217;) that they have those (or greater) permissions to already.</p>
<p>One question I have is&#8211;let&#8217;s say there are a dozen &#8216;items&#8217; with the four main CRUD actions on them (defining 48 possible activities) and of course we will be adding more &#8216;items&#8217; to these dozen all the time.  Should I just create a &#8216;custom role&#8217; (hash into the 4 x 12 table of &#8216;checkmarks&#8217;) in Rolify for whatever permissions any particular user is given by a sub-admin (meaning, create a new &#8216;custom&#8217; role each time some combination of those 48 &#8216;checkmarks&#8217; are checked by a sub-admin for one of their sub-users/admins&#8211;we would share a combination that reoccurs, of course)?  Or better to just keep adding the &#8216;items&#8217; x 4 into a separate table linked to from the User table itself?  IOW, not use custom roles at all for these sub-permissions/activity-based authorizations, but simply make that &#8216;hash of permissions on items&#8217; a part of the identity of that user?</p>
<p>Thanks all!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manfred Lange</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-2744</link>
		<dc:creator>Manfred Lange</dc:creator>
		<pubDate>Sun, 09 Sep 2012 02:24:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-2744</guid>
		<description>Derick, I like in particular your approach of thinking in terms of activities as opposed to roles. I gave it a try and it is driving the design of systems in a much better direction. Thank you for sharing!</description>
		<content:encoded><![CDATA[<p>Derick, I like in particular your approach of thinking in terms of activities as opposed to roles. I gave it a try and it is driving the design of systems in a much better direction. Thank you for sharing!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shurller</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-2696</link>
		<dc:creator>Shurller</dc:creator>
		<pubDate>Sat, 18 Aug 2012 18:35:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-2696</guid>
		<description>Can you explain further how you achieve this? Or better still if you can share your sample code.</description>
		<content:encoded><![CDATA[<p>Can you explain further how you achieve this? Or better still if you can share your sample code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spamme</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-2690</link>
		<dc:creator>Spamme</dc:creator>
		<pubDate>Thu, 16 Aug 2012 12:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-2690</guid>
		<description>Nice article, alas you don&#039;t give any sample project from where people can begin, it would be very useful.</description>
		<content:encoded><![CDATA[<p>Nice article, alas you don&#8217;t give any sample project from where people can begin, it would be very useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rbac_abac</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-2568</link>
		<dc:creator>rbac_abac</dc:creator>
		<pubDate>Sun, 24 Jun 2012 00:10:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-2568</guid>
		<description>Modern authorization architecture is based on XACML processing model (where the authorisation system provides distributed, embeddable PDP -- policy decision engine).
That engine must be consulted by the application before the end user gets to access a protected resouce:
checkAuthorisationAccess(user, activity, target_resource, application-context-attributes)  would return allow or deny
The application must not even be aware of the roles that a user has (storing the roles, and interpreting them is the job of PIP and PDP).  PDP engine also implements what&#039; is caled ABAC (attribute based access control, typically by embedding a light weight rules engine).</description>
		<content:encoded><![CDATA[<p>Modern authorization architecture is based on XACML processing model (where the authorisation system provides distributed, embeddable PDP &#8212; policy decision engine).<br />
That engine must be consulted by the application before the end user gets to access a protected resouce:<br />
checkAuthorisationAccess(user, activity, target_resource, application-context-attributes)  would return allow or deny<br />
The application must not even be aware of the roles that a user has (storing the roles, and interpreting them is the job of PIP and PDP).  PDP engine also implements what&#8217; is caled ABAC (attribute based access control, typically by embedding a light weight rules engine).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://lostechies.com/derickbailey/2011/05/24/dont-do-role-based-authorization-checks-do-activity-based-checks/#comment-2492</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Tue, 29 May 2012 13:06:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/derickbailey/?p=358#comment-2492</guid>
		<description>I share your sentiment here, we realized this problem years ago. Indeed I&#039;m very surprised that you didn&#039;t mention the biggest paing we had with role based security, what about dynamic roles?

What happens when the client wants to change dynamically roles and assign then different permissions overtime? The whole role based security fails when dynamic roles appear.

So, in essence we did the same as you, as we allowed dynamic roles to be created, we needed to check some other fixed point, so we decided to check directly for permissions.

As you did, our permissions represented activities in the systems, so we are doing the same here. 

I still think that the whole role based security is broken, and only works for very simple scenarios that do not change over time. But what scenario does not change over time?</description>
		<content:encoded><![CDATA[<p>I share your sentiment here, we realized this problem years ago. Indeed I&#8217;m very surprised that you didn&#8217;t mention the biggest paing we had with role based security, what about dynamic roles?</p>
<p>What happens when the client wants to change dynamically roles and assign then different permissions overtime? The whole role based security fails when dynamic roles appear.</p>
<p>So, in essence we did the same as you, as we allowed dynamic roles to be created, we needed to check some other fixed point, so we decided to check directly for permissions.</p>
<p>As you did, our permissions represented activities in the systems, so we are doing the same here. </p>
<p>I still think that the whole role based security is broken, and only works for very simple scenarios that do not change over time. But what scenario does not change over time?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
