Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > ba9fe7781d529b2e7b31d8489f5e0b8e > files > 16

gitolite-1.5.3-2.fc14.noarch.rpm

<h1>delegating access control responsibilities</h1>

<p>[Thanks to jeromeag for forcing me to think through this...]</p>

<hr />

<p>In this document:</p>

<ul>
<li><a href="#lots_of_repos_lots_of_users">lots of repos, lots of users</a></li>
<li><a href="#splitting_up_the_set_of_repos_into_groups">splitting up the set of repos into groups</a></li>
<li><a href="#delegating_ownership_of_groups_of_repos">delegating ownership of groups of repos</a></li>
<li><a href="#security_philosophy_note">security/philosophy note</a></li>
</ul>

<hr />

<p><a name="lots_of_repos_lots_of_users"></a></p>

<h3>lots of repos, lots of users</h3>

<p>Gitolite tries to make it easy to manage access to lots of users and repos,
exploiting commonalities wherever possible.  (The example in <a href="http://github.com/sitaramc/gitolite/blob/pu/doc/3-faq-tips-etc.mkd#simpler_syntax">this
section</a> should give you an idea).  As you can see, it lets you specify
bits and pieces of the access control separately -- i.e., <em>all</em> the access
specs for a certain repo need not be together; they can be scattered, which
makes it easier to manage the sort of slice and dice needed in that example.</p>

<p>But eventually the config file will become too big.  If you let only one
person have control, he could become a bottleneck.  If you give it to multiple
people, they might make mistakes or stomp on each others' work accidentally.</p>

<p>The best way is to divide up the config file and give parts of it to different
people.</p>

<p>Ideally, we would delegate authority for <em>groups</em> of repos, not individual
repos, otherwise it doesn't scale.  It would also be nice if we could prevent
an admin from creating access rules for <em>any</em> repo in the system -- i.e., set
limits on what repos he can control.  This would be a nice "security" feature.</p>

<p>Delegation offers a way to do all that.  Note that delegated admins cannot
create or remove users, not can they define new repos.  They can only define
access control rules for a set of repos they have been given authority for.</p>

<hr />

<p>It's easier to show how it all works with an example instead of long
descriptions.</p>

<p><a name="splitting_up_the_set_of_repos_into_groups"></a></p>

<h3>splitting up the set of repos into groups</h3>

<p>To start with, recall that gitolite allows you to specify <strong>groups</strong> (of users
or repos, same syntax).  So the basic idea is that the main config file
(<code>conf/gitolite.conf</code> in your admin repo clone) will specify some repo groups:</p>

<pre><code># group your projects/repos however you want
@webbrowser_repos           = firefox lynx
@webserver_repos            = apache nginx
@malware_repos              = conficker storm

# any other config as usual, including access control lines for any of the
# above projects or groups
</code></pre>

<p><a name="delegating_ownership_of_groups_of_repos"></a></p>

<h3>delegating ownership of groups of repos</h3>

<p>Once the repos are grouped, give each person charge of one or more groups.
For example, Alice may be in charge of all web browser development projects,
Bob takes care of web servers, and Mallory, as <a href="http://en.wikipedia.org/wiki/Alice_and_Bob#List_of_characters">tradition</a> dictates, is
in charge of malware ;-)</p>

<p>You do this by adding branches to the <code>gitolite-admin</code> repo:</p>

<pre><code># the admin repo access was probably like this to start with:
repo gitolite-admin
    RW+                                         = sitaram
# now add these lines to the config for the admin repo
    RW                                          = alice bob mallory
    RW+ NAME/                                   = sitaram
    RW  NAME/conf/fragments/webbrowser_repos    = alice
    RW  NAME/conf/fragments/webserver_repos     = bob
    RW  NAME/conf/fragments/malware_repos       = mallory
</code></pre>

<p>This uses gitolite's ability to restrict pushes by file/dir name being changed
-- the syntax you see above ensures that, while "sitaram" does not have any
NAME based restrictions, the other 3 users do.  See <code>conf/example.conf</code> for
syntax and notes.</p>

<p>As you can see, <strong>for each repo group</strong> you want to delegate authority over,
there's a rule for a <strong>corresponding file</strong> in <code>conf/fragments</code> in the
<code>gitolite-admin</code> repo.  If you have write access to that file, you are allowed
to define rules for repos in that repo group.</p>

<p>In other words, we use gitolite's file/dir NAME-based permissions to "enforce"
the separation between the delegated configs!</p>

<p>Here's how to use this in practice:</p>

<ul>
<li><p>Alice clones the <code>gitolite-admin</code> repo, and adds a file called
<code>conf/fragments/webbrowser_repos.conf</code></p></li>
<li><p>she writes in this file any access control rules for the "firefox" and
"lynx" repos.  She should not write access rules for any other project --
they will be ignored</p></li>
<li><p>Alice then commits and pushes to the <code>gitolite-admin</code> repo</p></li>
</ul>

<p>Naturally, a successful push invokes the post-update hook that the admin repo
has, which eventually runs the compile script.  The <strong>net effect</strong> is as if
you appended the contents of all the "fragment" files, in alphabetical order,
to the bottom of the main file.</p>

<hr />

<p><a name="security_philosophy_note"></a></p>

<h3>security/philosophy note</h3>

<p>The delegation feature is meant only for access control rules, not pubkeys.
Adding/removing pubkeys is a much more significant event than changing branch
level permissions for people already on staff, and only the main admin should
be allowed to do it.</p>

<p>Gitolite's "userids" all live in the same namespace.  This is unlikely to
change, so please don't ask -- it gets real complicated to do otherwise.
Allowing delegated admins to add users means username collisions, which also
means security problems (admin-A creates a pubkey for Admin-B, thus gaining
access to all of Admin-B's stuff).</p>

<p>If you feel the need to delegate even that, please just go the whole hog and
give them separate gitolite instances!  It's pretty easy to setup the
<em>software</em> itself system-wide, so that many users can use it without all the
"easy install" fuss.  See the "system install / user setup" section in
doc/0-INSTALL.mkd for details.</p>