Multiple user hgwebdir possible?
Aldo Brucale
brucale at dm.unibo.it
Mon Oct 12 09:01:33 UTC 2009
You can specify allow_read/deny_read directives in .hg/hgrc for each
repository:
[web]
allow_read = user1 user2
deny_read = non_user
hgwebdir won't show the repositories to users with no permission.
Yung-Yu Chen wrote:
> On Sat, Oct 10, 2009 at 11:14, Stephen Rasku <mercurial at srasku.net
> <mailto:mercurial at srasku.net>> wrote:
>
> On Fri, Oct 9, 2009 at 10:10, Eric Arseneau <Eric.Arseneau at sun.com
> <mailto:Eric.Arseneau at sun.com>> wrote:
> > I just upgraded to Snow Leopard Server last night. With this new
> > version, I now have unlimited users and intend to use this feature.
> > Previously, I had 10 users and therefore created a single hg user
> that
> > everyone connected to.
> >
> > I would like to set things up such that each user can have their own
> > set of repos, but dont really want them to have to setup hgwebdir
> > config for each of their own.
> >
> > Is there a recommended practice for doing this?
>
> I am not aware of any way to configure separate repositories for
> separate users using hgwebdir. If there is I would like to hear about
> it.
>
>
> It's straight-forward to setup multiple repos for multiple (http) users
> through a slightly modified CGI script:
>
> #!/usr/bin/env python
> from mercurial import demandimport; demandimport.enable()
> import cgitb; cgitb.enable()
> import os; os.environ["HGENCODING"] = "UTF-8"
>
> from mercurial.hgweb.hgwebdir_mod import hgwebdir
> from mercurial.hgweb.request import wsgiapplication
> import mercurial.hgweb.wsgicgi as wsgicgi
>
> # setup shared reposet.
> allset = {
> }
> # setup reposet by username.
> usersets = {
> 'guest': {
> },
> 'user1': {
> 'repo1': '/path1',
> 'repo2': '/path2',
> },
> 'user2': {
> 'repo3': '/path3',
> },
> }
>
> # get webapp_maker by username.
> username = os.environ.get('REMOTE_USER', None)
> reposet = usersets.get(username, None)
> if reposet is not None:
> # load shared reposet.
> for key in allset:
> if key not in reposet:
> reposet[key] = allset[key]
> # launch wsgi.
> wsgicgi.launch(wsgiapplication(lambda: hgwebdir(reposet)))
> else:
> import sys
> out = sys.stdout.write
> out("Content-Type: text/html\n")
> out("Status-Code: 404 Not Found\n") # no use for CGI.
> out("\n")
> out("<title>Repository not found</title>\n")
> out("<h1>Repository not found</h1>\n")
> out("<p>I am sorry, but there are no repositories you ")
> out("(<strong>%s</strong>) " % username)
> out("at the specified location.</p>\n")
>
>
>
> It may be easier to configure ssh access instead. You can create
> different shells for different users (or different groups for that
> matter) and you can use permissions to permit/forbid access to the
> repositories.
>
> ...Stephen
>
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com <mailto:Mercurial at selenic.com>
> http://selenic.com/mailman/listinfo/mercurial
>
>
More information about the Mercurial
mailing list