Skip to main content

Mercurial hgweb init support.

Project description

hgwebinit is a Mercurial extension for hgweb that allows for remote creation of repositories. At this time hgwebinit creates repositories implicitly if the requesting user has permission to do so. This can easily create repositories unintentionally if the user simply misspells a repo or path. The primary use is for creating new repositories within collections but it is not currently limited to that.

Note that there are better tools out there for create repositories. The goal of this extension is to provide an easy-to-use option that gets the basic job done. Feedback is certainly welcome as this is in an early stage.

The intent for future versions is to move to implementing tighter security measures in the permission model and to potentially implement an init command in the wire protocol. This would prevent some confusion on the part of the user and allow for more fine-grained authorization.

Installation and Configuration

hgwebinit is available on bitbucket (primary) and github (mirror):

hgwebinit may be installed from the Python Package Index using:

easy_install hgwebinit

or, via pip:

pip install hgwebinit

This will download the current version of hgwebinit and get you ready. Next you will want to configure your hgweb installation to also use hgwebinit. Here is an hgweb.ini for example:

[paths]
/trunk=/repos/*

[web]
allow_push = *
push_ssl = false
allow_create = *
implicit_init = true

[extensions]
hgwebinit=

hgwebinit will allow for creation of new repositories within collections or as sub-repositories. A direct conflict or a path outside of configure paths is denied. In the above configuration, all users are allowed to create new repositories. Set allow_create to a list of users a la allow_push to let those users create new repositories.

Security and Implementation Considerations

Although there are security implications in doing this, they are not the ones that most people think of. When searching for ways to create repositories remotely you are presented a couple options. One is to use hg via ssh. The others basically consist of using bitbucket’s web interface or similar. New comers then often ask “what if I want to create a repository via http?” They are almost always confronted with the answer of “you can’t do that because it would be insecure.”

Please understand that whenever you put a server up on the Internet you must be conscious of security. The mechanisms provided by this extension are useful but not complete. Please take precautions to lock down your server and ensure the right people are doing only things you have allowed them to do.

Security: User permissions (authorization)

hgweb runs as the web server user (e.g. www-data under many Apache configurations) and file system-level permissions are only checked for that user. hgweb then does some permissions processing on top of that.

hgweb handles read and push permissions on a per-user basis given that the user was authenticated at all. What is needed is a permission model for repository creation in addition to the current read and push permissions. This extension adds a configuration for allow_create and deny_create. These are similar to the existing allow_push and deny_push configurations. In fact, at present a user must have both read and create permission in order to create a repository implicitly.

Note that when considering user permissions it is important to recognize the roll of hgweb. When using a repository via SSH or locally, authorization is delegated to the file system on which the repository is stored. If the user cannot use hg to read/write the repository then that is it - mission failed.

In the case of hgweb, relying on file system permissions is insufficient. Instead hgweb implements its read and push permissions. hgweb is acting as an authorization layer for hy. This is an important distinction because it is unique to repositories hosted for HTTP access. For that reason, hgwebinit includes permission for initializing a new repository.

Lastly consider that a user who is accessing a repository locally (this also applies to many SSH-based cases) has more access to the repository than they would when accessing that same repository via HTTP. In particular, hgweb provides no method that would destroy information in the repository. An authenticated user can push new information and can read existing information but they cannot remove commits or delete the repository. Conversely any user with file-system permissions to the repository can actually delete it entirely. In this sense hgweb actually provides more protection for the repository.

Security: User identity (authentication)

When using a remote repository it is important to consider that the authenticated user may not be the one identified in the commit log. This is true of mercurial in general and is not specific to hgweb or hgwebinit. Consider that authenticating via SSH gives someone full access to the repository. They can then commit using whatever name and email they wish. If this poses major risk for your project or organization then please consider the extension for mercurial that allows for signing commits using gpg. Alternatively an extension that verifies that the commit identity matches the authenticated user would be quite handy.

Side Effects

In the current state hgwebinit allows for creating new repositories but does so implicitly. When a properly authorized user tries to push to or read from a path that doesn’t match a repository, a new repository is created on the fly. The requested operation is then completed as normal. This means that any properly authorized user who misspells a repository path is going to create a new repository.

This comes back to the topic of destructive edits because removing the problematic repository is now necessary. With direct repository access one can simply delete it. Allowing such destructive access from the Internet is probably not wise and it is not the intent of this extension to allow such actions. Repairing that situation should be handled by someone with sufficient repository access.

Roadmap

Protocol Complexity

The roadmap for this extension includes an addition to the hg protocol in order to support explicit creation of repositories. In other words, we want a user with this extension installed to be able to type hg init https://server.com/remote_repo, get authenticated and authorized and end up with a new repository, just as they asked.

Although this adds to the HTTP protocol it would essentially close a feature gap when compared to the functionality afforded by SSH connections. Consider that a user with sufficient file system permissions is able to initialize a new repository anywhere.

Hg Scope Creep

The issue with adding commands an functionality like this is that it could open a door for new feature requests.

First consider that it would be a great problem to have. Users desiring functionality either provides input to Hg developers or provides ideas for extension authors.

Secondly, that scope creep could be prevented or controlled through the dissemination of information. The goal of hgwebinit is essentialy to gain parity with the SSH implementation while retaining a reasonable level of security. Given that, other crazy-cool authorization mechanisms are outside the scope of this extension and should be considered for development as new projects.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hgwebinit-0.1.0.zip (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hgwebinit-0.1.0-py2.7.egg (17.7 kB view details)

Uploaded Egg

File details

Details for the file hgwebinit-0.1.0.zip.

File metadata

  • Download URL: hgwebinit-0.1.0.zip
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hgwebinit-0.1.0.zip
Algorithm Hash digest
SHA256 e9af947e1037b9212de98a05ffe753d2576c1946a8f145047bf0e4db6c15d41e
MD5 42880047f19e120c64dfefb52bb7874d
BLAKE2b-256 43e3713a45baaad8582068fcac99bb8f36511905c20e5c7ea016ca9cd98dea2f

See more details on using hashes here.

File details

Details for the file hgwebinit-0.1.0-py2.7.egg.

File metadata

  • Download URL: hgwebinit-0.1.0-py2.7.egg
  • Upload date:
  • Size: 17.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for hgwebinit-0.1.0-py2.7.egg
Algorithm Hash digest
SHA256 dbf19b1434f61df4196ff2be5ca9ff7f11539bd8f319affe0f284c8fb1a7af40
MD5 9f0745ca1ed3a0af7df60f29e9412a70
BLAKE2b-256 6c585f18963a4b874f4c50360db9dfea929b9f3200479410e012e4138655a50c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page