RightScale Blog - Permissionshttp://www.rightscale.com/blog/tag/permissions
enManaging Large-Scale User-Access Control with the RightScale APIhttp://www.rightscale.com/blog/cloud-management-best-practices/managing-large-scale-user-access-control-rightscale-api
<div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even" property="content:encoded"> <p><img alt="wall of checkboxes" class="media-image aligncenter size-full wp-image-2141" height="195" style="" width="480" typeof="foaf:Image" src="http://www.rightscale.com/blog/sites/default/files/styles/large/public/2013/01/screen-shot-2013-01-09-at-11-25-05-am_0.png?itok=M8wXhGHa" /></p><p><br>What's with the check boxes you ask? It's a partial visual representation of what it looks like to manage 83 users, 15 RightScale accounts, and 11 permissions for each user in each account. That's 13,695 check boxes I'd potentially need to click. So I decided that I needed to either hunker down with a carafe of coffee for a few days or find a better solution! <!--more--></p><h2>Mission Statement</h2><p>Now, before I go too much further, you should know what it was that I was trying to accomplish. I was tasked with getting user access to all of our RightScale demo accounts sorted out and standardized.</p><p>At RightScale we have a mix of sales staff, product management, marketing, and even some engineers who need some level of access to the demo accounts we use when showing prospective customers how RightScale works. Of course, not all users are created equal. A Cloud Solutions Engineer like me, for instance, would have very different permissions than a Sales Associate.</p><p>What I needed was to be able to group users into specific roles, assign permissions to those roles, and then apply those changes to the RightScale user access control. As I mentioned at the outset, that meant managing nearly 14,000 individual permissions (actually a bit more since there were more than 83 users to start with before I removed some).</p><p>To put the task ahead of me into perspective, consider that the image at the top of this blog post contains exactly 640 checkboxes. To see what 14,000 check boxes looks like, you can check out <a href="http://assets.rightscale.com/other/14k_checkboxes.html" target="_blank" title="this page">this</a> page.</p><p>Needless to say, there was no way I was going to manually go through the process of changing all of these permissions. It would take me hours, possibly days, and what would happen if I actually needed to change some of the user assignments at a later date? I didn't even want to consider the ongoing overhead.</p><h2>User Management at Scale</h2><p>Now, as daunting as changing so many permissions seemed at the time, our environment with 83 users and 15 accounts is actually fairly small by comparison to the IT footprint of a large enterprise. Imagine this same scenario with 100 accounts and several hundred users, all with very specialized access needs.</p><p>Now imagine that each of those users needed to access not just AWS, or Rackspace, or Google Compute Engine, but all three, as well as a dozen or so private cloud environments.</p><p>Next imagine that you were responsible for managing access control for all of those users across all of those resource pools and services. You'd have an exponentially larger number of check boxes, and you'd also have to interact with dozens of different API endpoints with varying degrees of user access control.</p><p>As you read on, remember that all of the user-access control that is being manipulated automatically applies to every resource pool that you manage with your RightScale account(s). Users are given one username, one password, and one URL to remember. They log in to RightScale and have consistent access (managed by and visible to the enterprise) to all of their cloud resource pools.</p><p>If you don't currently use RightScale and want to see how user-access control works (among many other things), you can <a href="http://bit.ly/WBhzr2" target="_blank" title="try our Free Edition">try our Free Edition</a>.</p><h2>TL;DR</h2><p>I'm going to go on to tell the (rather lengthy) story of how I arrived at a tool that allows me to easily update permissions across multiple users and RightScale accounts simultaneously. If you're looking for the short version...</p><p>I wrote a Ruby Gem named <a href="https://rubygems.org/gems/rs_user_policy" target="_blank">rs_user_policy</a> that consists of a library and a command line utility that ingests JSON files describing users and their associated permissions and then applies them to RightScale accounts via the <a href="http://reference.rightscale.com/api1.5/index.html" target="_blank">API</a>, using the <a href="https://rubygems.org/gems/right_api_client" target="_blank" title="right_api_client">right_api_client</a> Ruby Gem.</p><p>While the command line tool uses JSON files as it's input source, the library was designed to be extensible enough to use other sources for <a href="https://github.com/rgeyer/rs_user_policy/tree/master/lib/rs_user_policy/policy" target="_blank">role definitions</a> and <a href="https://github.com/rgeyer/rs_user_policy/tree/master/lib/rs_user_policy/user_assignments" target="_blank">user assignments</a>. For instance LDAP or AD are logical sources, which I'll elaborate on later in this post.</p><p>You can skip the rest of the story and go straight to the <a href="#conclusions">conclusions</a> now if you like.</p><h2>Automate Everything</h2><p>Fortunately everything we do here at RightScale revolves around automation. This becomes especially important when you start to operate at scale with many users, resource pools, and applications. Managing that scale simply can't be done through a UI. Instead a well-documented REST API becomes mandatory to reduce burden and eliminate human error.</p><p>With that in mind, everything that I was trying to accomplish to audit the user access to our sales demo accounts would be accomplished via the RightScale API, and I set out to create a simple tool to take care of the heavy lifting.</p><h2>Organizing and Categorizing</h2><p>My first task was to identify the types of users who needed access to the demo accounts and what they needed to do.</p><p>For most users, all they needed was to be able to log in to the account and view the deployments that were there. For them, only the "observer" and "billing" permissions were appropriate.</p><p>For other users, like the Cloud Solutions Engineer team and select folks from product management and engineering, a more expansive set of permissions was appropriate.</p><p>I set out to start documenting these "roles" and chose to express it in a JSON document. My first draft of this description looked something like the following:</p><p><br><img alt="policy1.json" class="media-image aligncenter size-full wp-image-2166" height="314" style="" width="480" typeof="foaf:Image" src="http://www.rightscale.com/blog/sites/default/files/styles/large/public/2013/01/screen-shot-2013-01-09-at-3-07-51-pm_1.png?itok=3A2i5vLN" /></p><p><br>This basically states that users assigned to the "Engineer" role get the "observer," "actor," "admin," "designer," "billing," "server_login," and "library" permissions on every sales demo account. For those assigned the role "SalesAssociate," only the "observer" and "billing" permissions are granted. Lastly, for the role "SalesAssociate," these people get slightly elevated privileges for the account with the ID 12345, namely gaining the "actor" permission.</p><p><i><b>* Note:</b> If you're wondering about the meaning of these RightScale permissions, take a look at <a href="http://support.rightscale.com/15-References/Tables/User_Role_Privileges" target="_blank">User Role Privileges</a></i></p><h2>Role Assignment</h2><p>With a basic mechanism for describing roles decided on, I then needed to assign the users who were already members of the sales demo accounts to the defined roles. This is where I started to actually produce some lines of Ruby code to call the RightScale API.</p><p>I wrote a few lines that would use the RightScale API to find all the child accounts for our sales demo enterprise account, iterate over them, and produce a list of all the existing users. Because I was going to assign those users to roles, I figured I'd assign a default role to newly discovered users. I chose "immutable" to describe existing users and to indicate that their role and permission set should not be changed. The output looked something like this:</p><p><br><img alt="user_assignments1" class="media-image aligncenter size-full wp-image-2157" height="82" style="" width="359" typeof="foaf:Image" src="http://www.rightscale.com/blog/sites/default/files/styles/large/public/2013/01/screen-shot-2013-01-09-at-2-18-23-pm-copy_1.png?itok=dvDIw_OZ" /></p><p><br>So then I could start to assign the roles to users who were found in the RightScale accounts by looking through the generated list and changing "immutable" to the role that is appropriate for the user. By way of example, I could assign "user1@rightscale.com" to the "Engineer" role, and "user2@rightscale.com" to the "SalesAssociate" role to indicate the permissions that those users should be granted.</p><p>Lastly, if I found a user who I no longer wanted to have any access to any accounts, I could assign the role "delete," and all their permissions would be revoked.<br><br><b>RightScale API calls used:</b></p><ul><li><a href="http://reference.rightscale.com/api1.5/resources/ResourceChildAccounts.html#index" target="_blank" title="ChildAccounts#index">ChildAccounts#index</a></li><li><a href="http://reference.rightscale.com/api1.5/resources/ResourceUsers.html#index" target="_blank" title="Users#index">Users#index</a></li></ul><h2>Policy Enforcement</h2><p>With user roles defined in one JSON file, and role assignments for each user in the accounts in another, it was time to actually compare existing users and their permissions to the policy these files defined.</p><p>I'll spare you the nitty gritty detail (you can dive into it <a href="https://github.com/rgeyer/rs_user_policy/blob/0.0.5/lib/rs_user_policy/user.rb#L91" target="_blank">here</a> if you're interested), but this process consisted of finding the permissions the user currently had, comparing that against the desired permissions for the users role, and removing or adding the appropriate permissions to enforce the policy.</p><p><b>RightScale API calls used:</b></p><ul><li><a href="http://reference.rightscale.com/api1.5/resources/ResourcePermissions.html#index" target="_blank" title="Permissions#index">Permissions#index</a></li><li><a href="http://reference.rightscale.com/api1.5/resources/ResourcePermissions.html#create" target="_blank" title="Permissions#create">Permissions#create</a></li><li><a href="http://reference.rightscale.com/api1.5/resources/ResourcePermissions.html#destroy" target="_blank" title="Permissions#destroy">Permissions#destroy</a></li></ul><h2>Plot Twist #1</h2><p>Satisfied with my accomplishment and self-assured that I'd solved the problem completely, I went ahead with assigning everyone whose role was obvious and then ran the tool.</p><p><b><i>Success!</i></b></p><p>All of the assigned users now had exactly the defined permissions across all of the demo accounts.</p><p>However, there were still plenty of users who legitimately required access to the demo accounts, but whose roles and associated permissions weren't readily apparent. I started to ask the users what they used the demo accounts for, and very quickly realized that I would likely have to create a different role for each person since they each had very specific requirements.</p><p>To accommodate this, each user needed to be able to be a member of more than one "role." Furthermore, roles could be defined a bit more abstractly since they could be combined. For instance, I could create roles that have elevated permissions for only a specific RightScale account and combine that with a general "SalesAssociate" role for the same user, effectively giving a user basic permissions on all accounts and elevated permissions for an account that is appropriate for that user.</p><p><br><img alt="generic roles" class="alignleft size-medium wp-image-2171" src="/blog/sites/default/files/2013/01/screen-shot-2013-01-09-at-3-21-22-pm.png?w=202" style="width: 202px; height: 300px;"> <img alt="multiple role user assignment" class="media-image alignnone size-medium wp-image-2170" height="386" style="" width="371" typeof="foaf:Image" src="http://www.rightscale.com/blog/sites/default/files/styles/large/public/2013/01/screen-shot-2013-01-09-at-3-19-04-pm_1.png?itok=eVvdNMLg" /></p><p>Difficult as it is to see in the resized images above (click on them to see the images full size), what's going on here is that I've added two new roles named "GCEPowerUser" and "AzurePowerUser," which give elevated permissions to specific RightScale accounts. In my user assignment file, I now have a property for each user named "roles," which is an array of one or more roles the user belongs to.</p><p>This allows me to assign two new users, a Google engineer and an Azure engineer, appropriate permissions for their roles.</p><h2>Plot Twist #2</h2><p>After interviewing all of the users with special role requirements and accommodating them, I once again ran my tool to align all of the permissions to the policy.</p><p><b><i>Success!</i></b></p><p>All of the appropriate permissions were set, and everyone had the access they needed. I decided that I would set this up to run on a regular basis (once a day) to make sure that the permissions remain in compliance with the policy.</p><p>Then it dawned on me...</p><p>The tool only acts upon users who are already added to one of the RightScale accounts it acts upon. As we hire new employees, they would have to be manually invited to one of the accounts. That would cause them to be discovered by the tool and assigned the "immutable" role, and their permissions would never be maintained by the tool.</p><p>So, I needed to allow the tool to add new users by specifying them in the user assignments file.<br><img alt="net-new user assignment" class="media-image aligncenter size-full wp-image-2179" height="186" style="" width="312" typeof="foaf:Image" src="http://www.rightscale.com/blog/sites/default/files/styles/large/public/2013/01/screen-shot-2013-01-09-at-3-41-04-pm_1.png?itok=DJ-mWPIp" /><br>Above is a snippet of a user assignment file that contains only a single net-new user. This could just as easily be mixed in with several other existing users. The "roles," "company," "first_name," "last_name," and "phone" fields are all required. You can also supply any other field defined by the <a href="http://reference.rightscale.com/api1.5/resources/ResourceUsers.html#create" target="_blank">User#create</a> call in the API, perhaps the most interesting of which is "password," because if no authentication information (password, or identity_provider_href and principal_uid) is supplied, a strong password will be automatically generated for the user and written back to the user assignments file.</p><p>With that, the user assignment file can be the authority for all users who should exist for the set of accounts that are maintained by the tool.</p><p><b>RightScale API calls used:</b></p><ul><li><a href="http://reference.rightscale.com/api1.5/resources/ResourceUsers.html#create" target="_blank">User#create</a></li></ul><h2 id="ldap_ad">LDAP or AD Integration</h2><p>With those use cases covered, I was satisfied that the tool could do the job I'd created it for. Namely to run on a regular basis and make sure that the existence and permissions of users was enforced across all of our sales demo accounts according to the content of a couple JSON files.</p><p>However, the tool was designed to be extensible regarding the authoritative source for users and permissions. There are effectively two types of information: the roles and their permissions and user information (role assignments, first and last name, phone, etc.).</p><p>In the Ruby Gem, there is an interface defined for the <a href="https://github.com/rgeyer/rs_user_policy/blob/0.0.5/lib/rs_user_policy/policy/policy.rb" target="_blank">policy</a> (the roles and permissions for those roles) and the <a href="https://github.com/rgeyer/rs_user_policy/blob/0.0.5/lib/rs_user_policy/user_assignments/user_assignments.rb" target="_blank">user assignments</a>. You need only implement that interface to pull from the data source of your choosing to leverage the rest of the functionality.</p><p>Keep an eye out for a future blog post from our product team, who will explore this idea some more.</p><h2>Audit History and Compliance</h2><p>In addition to automatically managing user permissions, the tool also produces an audit log after reach run. This audit log is also in JSON and records all of the actions it took. You can see an example of the output below:</p><p><br><img alt="rs_user_policy audit" class="aligncenter size-medium wp-image-2191" src="/blog/sites/default/files/2013/01/screen-shot-2013-01-10-at-9-54-23-am.png?w=300" style="width: 500px; height: 334px;"></p><p><br>When this tool runs against our demo accounts, I grab this output file and toss it in an S3 bucket so I can go back and see the changes the tool has made over time. A very valuable tool for audit and compliance.</p><h2 id="conclusions">Conclusions</h2><p>When I was first asked to clean up the user access to our demo accounts, I didn't think much of it. It wasn't until later that I realized the scale of the problem and knew that I needed to approach it differently.</p><p>Managing user-access control on a large scale with the RightScale API demonstrates how powerful it is. When I was faced with a seemingly insurmountable problem, I was able to leverage the API to not only perform the task just once, but to also implement a tool that would help me to enforce the changes I'd made on an ongoing basis.</p><p>As I mentioned before, my task of managing ~100 users and 15 accounts is peanuts compared to the challenge a large enterprise or managed service provider might be facing. When you reach that scale, having a unified user-access policy for all of your cloud resource pools and being able to automatically manage it through an API becomes an absolute business requirement, not just an academic exercise.</p><p>If you're facing the problem of managing a large-scale user base in RightScale, by all means, check out the <a href="https://rubygems.org/gems/rs_user_policy" target="_blank">rs_user_policy</a> gem I created.</p><p>If you're facing a different problem that seems daunting, consider taking a second look to see if you might be able to solve the problem more elegantly and easily using the RightScale API. To get started, you can <a href="https://www.rightscale.com/free-trial" target="_blank" title="try the free version of RightScale">get a RightScale free trial</a>.</p> </div></div></div><div class="easy_social_box clearfix vertical easy_social_lang_und">
<div class="easy_social-widget easy_social-widget-twitter first"><a href="http://twitter.com/share" class="twitter-share-button"
data-url="http://www.rightscale.com/blog/cloud-management-best-practices/managing-large-scale-user-access-control-rightscale-api"
data-count="vertical"
data-lang = "en"
data-via=""
data-related=":Check it out!"
data-text="Managing Large-Scale User-Access Control with the RightScale API">Tweet</a></div>
<div class="easy_social-widget easy_social-widget-facebook"><iframe src="//www.facebook.com/plugins/like.php?locale=en_US&amp;href=http%3A//www.rightscale.com/blog/cloud-management-best-practices/managing-large-scale-user-access-control-rightscale-api&amp;send=false&amp;layout=box_count&amp;width=48&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font=&amp;height=90&amp;appId=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:48px; height:90px;" allowTransparency="true"></iframe></div>
<div class="easy_social-widget easy_social-widget-googleplus"><div class="g-plusone" data-size="tall" data-annotation="bubble" data-href="http://www.rightscale.com/blog/cloud-management-best-practices/managing-large-scale-user-access-control-rightscale-api"></div></div>
<div class="easy_social-widget easy_social-widget-linkedin last"><script type="in/share" data-url="http://www.rightscale.com/blog/cloud-management-best-practices/managing-large-scale-user-access-control-rightscale-api" data-counter="top"></script></div>
</div> <!-- /.easy_social_box -->Thu, 10 Jan 2013 21:36:05 +0000Ryan Geyer154 at http://www.rightscale.com/bloghttp://www.rightscale.com/blog/cloud-management-best-practices/managing-large-scale-user-access-control-rightscale-api#comments